Skip to main content

plan_time_optimal

Function plan_time_optimal 

Source
pub fn plan_time_optimal(
    machine: &dyn Machine,
    drives: &[&DriveParams],
    limits: &PlanLimits,
    start: &[f64],
    pieces: &[Piece],
    cycle: f64,
    tolerance: impl Into<Tolerance>,
    slack: f64,
) -> Result<Vec<(f64, Vec<f64>)>, CommandError>
Expand description

Plans the timing of a path as fast as the motors allow, within the jerk limits of the axes, point by point.

The path is the one plan times (transition curves included, their lengths for the speeds the motors allow per piece, motor_limits), with its look-ahead over the junctions, the speed at a junction and the stop at a corner. Within a piece the limits are read at places about 2 mm apart (piece_limits): at each the rigid model gives how fast each motor turns per speed along the path, and its torque as c a + d v^2 + e for the acceleration a and the speed v along the path (with the centripetal and Coriolis torque of the speed, Machine::feedforward_torque_moving, and e the torque that holds the tool there). Each motor is judged by its own drive and motor (drives, in the order of Machine::motors): it may turn up to its maximum speed (DriveParams::max_speed) and give reserve times its torque-speed curve at the speed it turns (level up to the rated speed, falling above it: MotorCurve), or of the torque of the drive’s maximum current where that is lower (effects.drive_current_limit), each way as gravity pushes and as it drives or brakes. The rest is for friction and elasticity, which the rigid model leaves out. Each axis keeps its jerk limit: on a line the ramps use it in full, on a curve 0.4 of it, and the rest is for the jerk that speed and acceleration make on the curve.

A gearbox (PlanLimits::gearbox) keeps reserve times its output torque rating: the output torque is the ratio times the motor’s torque less what turns the inertia at the input, again of the form c a + d v^2 + e. A guide keeps its load rating (PlanLimits::guide): the machine gives each guide’s load as a load at rest plus the size of a part linear in the acceleration (Machine::rigid_guide_loads).

Each piece then follows the highest speed its places allow (smoothed: the places’ top speeds, lowered where the speed could not come down in time or would bend too sharply for the jerk) from below, as fast as the jerk and the acceleration there allow, from its start and from its end (follow), and the two runs meet at a top speed at which both have no acceleration (piece_timing): the highest that fits. The velocity and acceleration limits of the axes play no part.

The belt is a limit of the plan too: tension is the lowest and the highest tension a belt section may have (ratings.belt_min_tension_n and belt_max_tension_n, each less profile.tension_margin_n; -inf and inf where the config has none) and the share of the room to them the plan may use (profile.tension_reserve). The rigid model gives each section’s tension at each place as c + g . acceleration (Machine::rigid_tensions_moving: c a + b v + d v^2 along the path, as the checks’ fit), so each section and place is one more bound: |g . acceleration| <= share * min(highest - c, c - lowest), the same room both ways. The rest of the room is for what the rigid model leaves out: the margin for the guide friction the belt pulls, the share (0.5 in the shipped configs) for the belt’s vibration, which after a quick ramp of acceleration overshoots by up to the rigid model’s change of tension, either way.