Skip to main content

Sim

Struct Sim 

Source
pub struct Sim {
Show 25 fields pub machine: Box<dyn Machine>, pub control: Controller, pub state: Vec<f64>, pub torque: Vec<f64>, pub step: u64, pub dt: f64, pub payload_energy: f64, pub crash_energy: f64, pub pick_refused: Option<&'static str>, pub limit_violations: Vec<LimitViolation>, pub heated: Vec<HeatedPart>, pub part_heating: bool, pub thermal_feedback: bool, pub warm_start: bool, pub obstacles: Vec<Obstacle>, pub crash: bool, pub min_clearance: f64, pub path: Option<PathRun>, pub clearance: f64, pub least_clearance: f64, pub contact: Option<Contact>, pub own_parts: PlanCheck, pub crashed: bool, pub contact_force: f64, pub refined_steps: u64, /* private fields */
}

Fields§

§machine: Box<dyn Machine>§control: Controller§state: Vec<f64>§torque: Vec<f64>§step: u64§dt: f64§payload_energy: f64

What switching the payload has added to the machine’s energy since the start: a payload picked up brings its energy along, one put down takes it away, unless the machine keeps it as a free body (the crane’s with the hook block and the floor: letting go books the sling’s elastic energy alone, a pick of it where it lies nothing).

§crash_energy: f64

The work the obstacles’ pushes took out of the machine since the start (effects.crash, pushes): what the contacts’ damping lost and their springs hold. For the energy budget.

§pick_refused: Option<&'static str>

Why the last pick was refused at the moment of the grip (Machine::refuses_pick at the tool’s real pose).

§limit_violations: Vec<LimitViolation>

Axis limits that exceed what the drives allow, found when the config was applied.

§heated: Vec<HeatedPart>

The parts that warm with their losses, and whether they do (effects.part_heating, or effects.thermal_feedback, which feeds back what this computes: heats). Their rises are signals whether or not; switched off they stay as they are.

§part_heating: bool§thermal_feedback: bool

Whether the machine’s friction and losses follow the parts’ rises (effects.thermal_feedback).

§warm_start: bool

effects.thermal_warm_start: the cycle analysis measures its pass with the windings and parts at the rises they settle at (analysis::analyse_cycle_with), not from cold.

§obstacles: Vec<Obstacle>

The obstacles of the config (collision::obstacles), each marked while a part of the machine touches it.

§crash: bool

effects.crash: an obstacle pushes back on a part that goes into it, with its contact stiffness and damping (pushes), so that the axes in contact are blocked; what trips the drives then is their monitoring (effects.drive_monitoring).

§min_clearance: f64

profile.min_clearance_m: the least clearance to the obstacles a time-optimal path may keep (plan_path).

§path: Option<PathRun>

The path the config’s [path] gives in place of the cycle (with_path): what the analysis of the cycle runs instead (analysis::analyse_cycle_with), and so the verdicts, the search and the optimiser. None: the cycle.

§clearance: f64

The clearance to the nearest obstacle after the last step, and the least since the start, m; infinite without obstacles. Checked every base step.

§least_clearance: f64§contact: Option<Contact>

The first contact with an obstacle since the start.

§own_parts: PlanCheck

The machine’s own parts against each other (collision::PlanCheck::own): joined as they are at the start pose, looked at after the first base step and then every OWN_PARTS_EVERY_S, in the simulated state (a load that swings, a machine that coasts); its least since the start is the verdict “self-collision”.

§crashed: bool

Whether the drives tripped (effects.drive_monitoring) while a part touched an obstacle, and have not been enabled since. Which monitor, and the stopping distances, are in control.fault.

§contact_force: f64

The obstacles’ force on the machine over the last step (at its end), N.

§refined_steps: u64

How many base steps were cut finer for the machine (cuts above 1) since the start.

Implementations§

Source§

impl Sim

Source

pub fn new(entry: &MachineEntry, cfg: &Config) -> Result<Self, ConfigError>

The machine at rest at its configured start pose.

Source

pub fn reconfigure( &mut self, entry: &MachineEntry, cfg: &Config, ) -> Result<(), ConfigError>

Applies a changed config to the running simulation: parameters and effect switches take effect from the next step, without a restart.

Source

pub fn time(&self) -> f64

Source

pub fn snapshot(&self) -> Snapshot

Everything but the machine, to go back to with restore: a copy, as long as the simulation’s state takes to copy.

Source

pub fn restore(&mut self, s: &Snapshot) -> Result<(), ConfigError>

Back to a snapshot of a simulation of the same machine and config (this one, or one built as it was): its next steps are bit for bit those the snapshot’s simulation took. A snapshot of another machine (other state, motor, part or obstacle counts) is refused and changes nothing. What a machine works out per step for its signals alone (a belt tooth jump’s loss) reads as the machine has it until the next step: sample before restoring if the signals at the snapshot are wanted.

Source

pub fn command(&mut self, command: Command) -> Result<(), CommandError>

Source

pub fn set_drive_mode( &mut self, k: usize, mode: DriveMode, ) -> Result<(), CommandError>

Puts motor k’s drive in mode: torque or speed setpoints from an outside controller (Controller::set_drive_mode).

Source

pub fn plan_configured_path( &self, ) -> Option<Result<Vec<(f64, Vec<f64>)>, CommandError>>

The config’s [path] (with_path) planned from where the machine stands, as sim-cli run --path plans a file: one run at the axes’ limits as a path, a program with feeds run by run (plan_program). None without one.

Source

pub fn plan_path( &self, pieces: &[Piece], time_optimal: bool, ) -> Result<Vec<(f64, Vec<f64>)>, CommandError>

The timing for a path from where the machine stands, to run with Command::Trajectory. A time-optimal path that comes nearer to an obstacle than profile.min_clearance_m, or touches one, is refused (error-path-collision), and so is one that brings two of the machine’s own parts as near (error-path-self-collision); one timed within the axis limits is planned all the same, and check_plan tells.

Source

pub fn plan_program( &self, runs: &[Run], time_optimal: bool, ) -> Result<Vec<(f64, Vec<f64>)>, CommandError>

The timing for a program (program::read) from where the machine stands (Controller::plan_program), refused as plan_path refuses a time-optimal path near an obstacle.

Source

pub fn check_plan(&self, poses: &[Vec<f64>]) -> Option<PlanCheck>

The path through poses checked against the obstacles before it runs, with the payload as it is now (collision::check_path), and the machine’s own parts against each other (PlanCheck::own, joined as at the start pose). None without obstacles where nothing of the machine’s own was checked.

Source

pub fn path_deviation( &self, pieces: &[Piece], time_optimal: bool, ) -> Result<f64, CommandError>

How far that planned path is from the pieces as given, at most.

Source

pub fn program_deviations( &self, runs: &[Run], time_optimal: bool, ) -> Result<Vec<f64>, CommandError>

path_deviation per run of a program (Controller::program_deviations).

Source

pub fn step(&mut self)

One base step: the controller sets the windings’ voltages, then windings and mechanics go through the step together (with the drives disabled, the mechanics alone without torque).

Source

pub fn machine_torque(&self) -> Vec<f64>

The torques the machine’s mechanics take at the end of the last step: the drives’ plus the obstacles’ pushes (push_torques), as the step integrated them. What a machine works out of its torques (a guide’s load from the acceleration they command, its friction and so its loss) is to be sampled with these, or the losses booked and those the motion had part ways while a part touches an obstacle.

Source

pub fn feed_temperatures_back(&mut self)

With effects.thermal_feedback, tells the machine its parts’ rises (Machine::set_part_temperatures).

Source

pub fn run(&mut self, seconds: f64, each: impl FnMut(&Self))

Source

pub fn signal_infos(&self) -> Vec<SignalInfo>

Every signal of the simulation. Scopes, CSV columns and PLC variables are generated from this list, never written per machine.

Source

pub fn sample(&self, out: &mut Vec<f64>)

The current value of every signal, in the order of signal_infos.

Source

pub fn sample_base(&self, out: &mut Vec<f64>)

The signals of sample up to the end of the machine’s base_signals, in the same places: without those of the effect views (which cost about one more evaluation of the machine) and the parts’ temperatures after them.

Source

pub fn signal_index(&self, id: &str) -> Option<usize>

Position of a signal in a sample.

Source

pub fn scene(&self, out: &mut Scene)

The machine’s scene, with where the tool is in it. Where the windings warm (effects.winding_heating), the k-th motor housing (scene::MOTOR_PART) is coloured by motor k’s winding rise over its rise at rated current; where the parts warm, each heated part by its rise over its rated rise.

Source

pub fn tool_point(&self) -> Option<[f64; 3]>

Where the tool is in the scene right now; None where the machine has no mapping.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Sim

§

impl !Sync for Sim

§

impl !UnwindSafe for Sim

§

impl Freeze for Sim

§

impl Send for Sim

§

impl Unpin for Sim

§

impl UnsafeUnpin for Sim

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.