pub struct Controller {
pub payload_attached: bool,
pub valves: Vec<f64>,
pub drives: Vec<Drive>,
pub set_pos: Vec<f64>,
pub set_vel: Vec<f64>,
pub set_acc: Vec<f64>,
pub tool_error: Vec<f64>,
pub setpoint_offset: Vec<f64>,
pub fault: Option<Fault>,
/* private fields */
}Fields§
§payload_attached: bool§valves: Vec<f64>The command of each valve of Machine::valves (+1 extend, -1 retract, 0 centre), set by the cycle’s segments;
the simulation hands them to the machine every step.
drives: Vec<Drive>§set_pos: Vec<f64>Tool-side setpoints and following error.
set_vel: Vec<f64>§set_acc: Vec<f64>§tool_error: Vec<f64>§setpoint_offset: Vec<f64>Added to the position setpoint only, not to the feedforward: a test signal for the closed loop (step response, frequency response).
fault: Option<Fault>The first trip since the drives were last enabled (effects.drive_monitoring).
Implementations§
Source§impl Controller
impl Controller
Sourcepub fn new(
cfg: &Config,
machine: &dyn Machine,
state: &[f64],
) -> Result<Self, ConfigError>
pub fn new( cfg: &Config, machine: &dyn Machine, state: &[f64], ) -> Result<Self, ConfigError>
A controller at rest at the machine’s current state.
Sourcepub fn apply_config(
&mut self,
cfg: &Config,
machine: &dyn Machine,
) -> Result<(), ConfigError>
pub fn apply_config( &mut self, cfg: &Config, machine: &dyn Machine, ) -> Result<(), ConfigError>
Re-reads gains, switches, cycle times and the cycle; keeps the loops’ running state. A config with a refused value changes nothing.
pub fn command( &mut self, command: Command, machine: &dyn Machine, ) -> Result<(), CommandError>
Sourcepub fn set_drive_mode(
&mut self,
k: usize,
mode: DriveMode,
machine: &dyn Machine,
state: &[f64],
) -> Result<(), CommandError>
pub fn set_drive_mode( &mut self, k: usize, mode: DriveMode, machine: &dyn Machine, state: &[f64], ) -> Result<(), CommandError>
Puts motor k’s drive in mode (DriveMode), state the machine’s. Refused while the drives are off or
stopping after a trip, and out of position mode while a move, cycle or path runs; while a drive is out of position
mode, the plan commands are refused. A drive coming back to position mode takes the plan with it: the plan stands
where the motors stand, at rest, and every drive starts its PI from the torque it asked for last
(Drive::set_mode), so the torque does not jump; at speed, the position loop then brings the motors back to
where they were at the switch. Enabling the drives puts them all in position mode.
Sourcepub fn step_brake(&mut self, dt: f64)
pub fn step_brake(&mut self, dt: f64)
One base step of dt of the holding brakes’ command: they engage brake.engage_delay_s after they are asked to
hold and release release_delay_s after they are asked to let go (effects.brake_delay; at once without it).
Sourcepub fn brake_engaged(&self) -> bool
pub fn brake_engaged(&self) -> bool
Whether the holding brakes hold (step_brake).
Sourcepub fn halting(&self) -> bool
pub fn halting(&self) -> bool
Whether a category 2 stop (StopCategory::Two) is braking the plan.
Sourcepub fn fault_reaction(&self, k: usize) -> Reaction
pub fn fault_reaction(&self, k: usize) -> Reaction
Each drive’s fault reaction (effects.drive_monitoring).
Sourcepub fn plan_path(
&self,
machine: &dyn Machine,
pieces: &[Piece],
time_optimal: bool,
) -> Result<Vec<(f64, Vec<f64>)>, CommandError>
pub fn plan_path( &self, machine: &dyn Machine, pieces: &[Piece], time_optimal: bool, ) -> Result<Vec<(f64, Vec<f64>)>, CommandError>
The timing for a path of lines and arcs from where the setpoint stands, as the poses that
Command::Trajectory runs: within the axis limits, or as fast as the motors allow (see path).
Sourcepub fn plan_program(
&self,
machine: &dyn Machine,
runs: &[Run],
time_optimal: bool,
) -> Result<Vec<(f64, Vec<f64>)>, CommandError>
pub fn plan_program( &self, machine: &dyn Machine, runs: &[Run], time_optimal: bool, ) -> Result<Vec<(f64, Vec<f64>)>, CommandError>
The timing for a program (program::read) from where the setpoint stands, as the poses Command::Trajectory
runs: each run planned from where the one before ends, at rest between them, within the corner tolerance of its
G61 or G64. A run with a feed is planned within the axis limits with the speed along the path of each piece
capped at its own feed times profile.feed_override (path::plan_feeds); one without as plan_path plans it, as
fast as the motors allow with time_optimal. A dwell (G4) holds the last pose for its time, in whole profile
cycles, as a cycle segment’s dwell does. A program without a move is refused (error-path).
Sourcepub fn path_deviation(
&self,
machine: &dyn Machine,
pieces: &[Piece],
time_optimal: bool,
) -> Result<f64, CommandError>
pub fn path_deviation( &self, machine: &dyn Machine, pieces: &[Piece], time_optimal: bool, ) -> Result<f64, CommandError>
How far the path plan_path plans for these pieces is from the pieces as given, at most (see
path::deviation): zero unless profile.path_tolerance_m allows transition curves. The time-optimal plan’s
curves are as long as the motors’ speeds need, so its deviation can differ. A path plan_path refuses is
refused here the same way (it is planned for that).
Sourcepub fn program_deviations(
&self,
machine: &dyn Machine,
runs: &[Run],
time_optimal: bool,
) -> Result<Vec<f64>, CommandError>
pub fn program_deviations( &self, machine: &dyn Machine, runs: &[Run], time_optimal: bool, ) -> Result<Vec<f64>, CommandError>
path_deviation per run of a program (plan_program: each run from where the one before ends, a run with a
feed within the axis limits). A run with a feed reads as without its feeds (path::deviation): never lower
than its own path’s.
pub fn cycle_segment(&self) -> Option<usize>
Sourcepub fn conveyor(&self) -> Option<(&Conveyor, Option<&Pass>)>
pub fn conveyor(&self) -> Option<(&Conveyor, Option<&Pass>)>
The conveyor of [conveyor], where the config has one, and the pass of its cycle under way or last run.
Sourcepub fn cycle_passes(&self) -> u64
pub fn cycle_passes(&self) -> u64
How often the cycle has started its first segment since the controller was made. The segment index alone does not tell one pass from the next when the cycle has a single segment.
Sourcepub fn cam_master(&self) -> f64
pub fn cam_master(&self) -> f64
Where an electronic cam’s master stands (Machine::cam), in its units; kept between runs.
Sourcepub fn torque_curve(&self, speed: f64) -> (f64, f64)
pub fn torque_curve(&self, speed: f64) -> (f64, f64)
The torque the drives can give at a motor speed: (lowest, highest).
Sourcepub fn motor_torque_curve(&self, k: usize, speed: f64) -> (f64, f64)
pub fn motor_torque_curve(&self, k: usize, speed: f64) -> (f64, f64)
The torque motor k’s drive can give at a motor speed: (lowest, highest).
Sourcepub fn dwell_progress(&self) -> Option<f64>
pub fn dwell_progress(&self) -> Option<f64>
How far a dwell of the cycle has run, from 0 to 1; None outside a dwell.
Sourcepub fn gripper_acting(&self) -> bool
pub fn gripper_acting(&self) -> bool
Whether the gripper is closing or opening (effects.gripper_time).
Sourcepub fn planned_pos(&self) -> &[f64]
pub fn planned_pos(&self) -> &[f64]
The setpoint as planned, before input shaping: during a dwell, the target.
Sourcepub fn external_setpoint(&self) -> &[f64]
pub fn external_setpoint(&self) -> &[f64]
Where a setpoint from outside would leave from: the target of the one the controller still interpolates towards, else where the plan stands. A link to a PLC shows this as its setpoint, so that an axis the PLC does not write stays where it is.
Sourcepub fn rated_torque(&self) -> f64
pub fn rated_torque(&self) -> f64
The torque the motors can give continuously.
Sourcepub fn drive_params(&self) -> &DriveParams
pub fn drive_params(&self) -> &DriveParams
Motor and drive data, for the analysis.
Sourcepub fn plan_limits(&self) -> &PlanLimits
pub fn plan_limits(&self) -> &PlanLimits
The limits the time-optimal plan keeps beside the motors’ (path::PlanLimits), as the config gives them.
Sourcepub fn dc_link_room(&self, k: usize) -> Option<f64>
pub fn dc_link_room(&self, k: usize) -> Option<f64>
Motor k’s DC link room above the bus, J: 1/2 C (U_threshold^2 - U_bus^2) of its own ratings; None without them.
Sourcepub fn drive_params_of(&self, k: usize) -> &DriveParams
pub fn drive_params_of(&self, k: usize) -> &DriveParams
Motor and drive data of motor k: drive_params with that motor’s own values (catalog::motor_config).
Sourcepub fn unrounded_encoders(&mut self)
pub fn unrounded_encoders(&mut self)
Every motor encoder without its rounding to counts and its noise, the speed still their difference per cycle
(DriveParams::speed_from_positions): for the small-signal loop measurement
(analysis::velocity_loop_response), whose test swing at high frequencies is a fraction of a count (a mover’s
3 N swings it 0.03 um at 1.6 kHz against 1 um counts): with them the rounding, not the loop, is measured.
Sourcepub fn motor_drives(&self, machine: &dyn Machine) -> Vec<&DriveParams>
pub fn motor_drives(&self, machine: &dyn Machine) -> Vec<&DriveParams>
Each motor’s own drive and motor data (drive_params_of), in the order of Machine::motors.
Sourcepub fn motors_shifted(&mut self, shift: &[f64])
pub fn motors_shifted(&mut self, shift: &[f64])
The motors stand shift from where they stood without having turned there: the machine’s model was
exchanged, and belt stretch and gear twist came or went with it, or its ratio changed. The encoders’
last readings move along, so that the step does not read as speed, and so do the position setpoints
at the drives and on the fieldbus, so that it does not read as following error. The next profile
cycle works them out anew.
Sourcepub fn update(
&mut self,
step: u64,
machine: &dyn Machine,
state: &[f64],
torque: &mut [f64],
)
pub fn update( &mut self, step: u64, machine: &dyn Machine, state: &[f64], torque: &mut [f64], )
One base step: runs whichever loops are due and sets the voltages the windings get over the step. Enabled, the
simulation then takes windings and mechanics through the step together and hands the windings back
(winding_stepped). Disabled, the drives give no torque, their windings cool and their DC links discharge,
and torque is zero.
Sourcepub fn plan_now(&self, time: f64, out: &mut [f64])
pub fn plan_now(&self, time: f64, out: &mut [f64])
The tool setpoint at time: the last profile cycle’s run on by its speed and acceleration, as the drives’ fine
interpolation runs the motors’ on (at most one profile cycle). What the analysis measures the tool against.
Sourcepub fn setpoint_age(&self, time: f64) -> f64
pub fn setpoint_age(&self, time: f64) -> f64
How long ago, at time, the profile cycle set set_pos, set_vel and set_acc (the signal setpoint_age):
plan_now is those run on by it.
Sourcepub fn winding_stepped(
&mut self,
windings: &[f64],
angle: &[f64],
speed: &[f64],
)
pub fn winding_stepped( &mut self, windings: &[f64], angle: &[f64], speed: &[f64], )
The base step done (see update): per drive the current at its end and the electrical energy, copper loss and
work on the shaft over it, WINDING_STATES numbers per drive in their order, and the rotors’ angles and speeds at
its end. Then the shared DC link, and the trip.
Sourcepub fn shaper_halves(
&self,
machine: &dyn Machine,
pose: &[f64],
) -> Option<(f64, f64)>
pub fn shaper_halves( &self, machine: &dyn Machine, pose: &[f64], ) -> Option<(f64, f64)>
Half the period in profile cycles of the first shaper and of the second (0 without one) with the plan at pose:
as configured, or, when the shaper follows the pose, that of the resonance the machine reports there for the
first and that of its second mode (Machine::sway_modes) for the second; one the machine does not report stays as
configured. None with the shaper off.
Sourcepub fn shaper_span(&self, machine: &dyn Machine, pose: &[f64]) -> f64
pub fn shaper_span(&self, machine: &dyn Machine, pose: &[f64]) -> f64
How many profile cycles the shaped setpoint arrives after the plan with the plan at pose: the longest of the
axes’ shapers; on the ramp to a changed machine’s period (shape) with the longer of the two. 0 with the shaper
off.
Sourcepub fn shaper_delays(
&self,
machine: &dyn Machine,
pose: &[f64],
) -> (Vec<f64>, f64)
pub fn shaper_delays( &self, machine: &dyn Machine, pose: &[f64], ) -> (Vec<f64>, f64)
With the plan at pose: per axis how far the shaped setpoint lags a plan at a constant speed (the mean of the
shaper’s delays, s), and how long after the plan it arrives (shaper_span, s). Zeros with the shaper off.
Trait Implementations§
Source§impl Clone for Controller
impl Clone for Controller
Source§fn clone(&self) -> Controller
fn clone(&self) -> Controller
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more