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: f64What 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: f64The 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: boolWhether the machine’s friction and losses follow the parts’ rises (effects.thermal_feedback).
warm_start: booleffects.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: booleffects.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: f64profile.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: f64The 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: PlanCheckThe 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: boolWhether 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: f64The obstacles’ force on the machine over the last step (at its end), N.
refined_steps: u64How many base steps were cut finer for the machine (cuts above 1) since the start.
Implementations§
Source§impl Sim
impl Sim
Sourcepub fn new(entry: &MachineEntry, cfg: &Config) -> Result<Self, ConfigError>
pub fn new(entry: &MachineEntry, cfg: &Config) -> Result<Self, ConfigError>
The machine at rest at its configured start pose.
Sourcepub fn reconfigure(
&mut self,
entry: &MachineEntry,
cfg: &Config,
) -> Result<(), ConfigError>
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.
pub fn time(&self) -> f64
Sourcepub fn snapshot(&self) -> Snapshot
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.
Sourcepub fn restore(&mut self, s: &Snapshot) -> Result<(), ConfigError>
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.
pub fn command(&mut self, command: Command) -> Result<(), CommandError>
Sourcepub fn set_drive_mode(
&mut self,
k: usize,
mode: DriveMode,
) -> Result<(), CommandError>
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).
Sourcepub fn plan_configured_path(
&self,
) -> Option<Result<Vec<(f64, Vec<f64>)>, CommandError>>
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.
Sourcepub fn plan_path(
&self,
pieces: &[Piece],
time_optimal: bool,
) -> Result<Vec<(f64, Vec<f64>)>, CommandError>
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.
Sourcepub fn plan_program(
&self,
runs: &[Run],
time_optimal: bool,
) -> Result<Vec<(f64, Vec<f64>)>, CommandError>
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.
Sourcepub fn check_plan(&self, poses: &[Vec<f64>]) -> Option<PlanCheck>
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.
Sourcepub fn path_deviation(
&self,
pieces: &[Piece],
time_optimal: bool,
) -> Result<f64, CommandError>
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.
Sourcepub fn program_deviations(
&self,
runs: &[Run],
time_optimal: bool,
) -> Result<Vec<f64>, CommandError>
pub fn program_deviations( &self, runs: &[Run], time_optimal: bool, ) -> Result<Vec<f64>, CommandError>
path_deviation per run of a program (Controller::program_deviations).
Sourcepub fn step(&mut self)
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).
Sourcepub fn machine_torque(&self) -> Vec<f64>
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.
Sourcepub fn feed_temperatures_back(&mut self)
pub fn feed_temperatures_back(&mut self)
With effects.thermal_feedback, tells the machine its parts’ rises (Machine::set_part_temperatures).
pub fn run(&mut self, seconds: f64, each: impl FnMut(&Self))
Sourcepub fn signal_infos(&self) -> Vec<SignalInfo>
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.
Sourcepub fn sample(&self, out: &mut Vec<f64>)
pub fn sample(&self, out: &mut Vec<f64>)
The current value of every signal, in the order of signal_infos.
Sourcepub fn sample_base(&self, out: &mut Vec<f64>)
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.
Sourcepub fn signal_index(&self, id: &str) -> Option<usize>
pub fn signal_index(&self, id: &str) -> Option<usize>
Position of a signal in a sample.
Sourcepub fn scene(&self, out: &mut Scene)
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.
Sourcepub fn tool_point(&self) -> Option<[f64; 3]>
pub fn tool_point(&self) -> Option<[f64; 3]>
Where the tool is in the scene right now; None where the machine has no mapping.