Skip to main content

optimise_cycle

Function optimise_cycle 

Source
pub fn optimise_cycle(
    entry: &MachineEntry,
    cfg: &Config,
    max_runs: usize,
) -> Result<Optimised, ConfigError>
Expand description

Shortens the cycle of a config without breaking a verdict. Tries corner blending, then raises speed, acceleration and jerk of all axes together in steps for as long as the cycle gets shorter and every verdict of verdicts still passes, among them the settling tolerance, so a faster move that leaves the tool swinging at the pick does not count. Input shaping makes no cycle shorter by itself (every stop waits one period of the shaper), so it is tried where it can help: a faster setting that fails on “settling” alone is run again with the shaper, and with the shaper following the pose where the machine reports a resonance, and is taken if it then passes and is shorter. A setting with the shaper that still fails on “settling” alone is run again with a second shaper convolved with it, at profile.shaper2_frequency_hz where the config has one, else at the machine’s second mode at the start pose (Machine::modes), else at the one resonance it reports there where that is more than 10 % off the first shaper’s frequency (no second shaper is tried where none of these is). Where a shaper is on already, switching it off is tried too. Simulates at most max_runs cycles.

The geometry of the cycle is a variable too. Each lift, traverse and lower (see lifts) is tried first with all lifts as low as profile.min_clearance_m allows (that far beyond the farther of pick and place), then each alone at that height and halfway down to it. Last, once no other step helps, the corners of a lift are rounded: the three segments become one path up to the lift height, through a via point and down (control::via_pieces, timed by the path planner with the transition curves of profile.path_tolerance_m), the via point at the middle and a half, a quarter and an eighth of the width above the lift height; then moved by an eighth and a thirty-second of the width along each axis, or the rounding dropped. A via point whose planned path comes nearer to pick and place than the clearance between them is not run. Where the config has obstacles, a setting whose run comes nearer to one than the clearance fails the verdict “collision” and is not taken; the cycle as configured is refused if it does.

A search by trial, not a proof of the optimum: it stops at the first setting from which no single step is an improvement. Judged on the verdicts as configured, at most max_runs cycles: optimise_cycle_with for the error bands and the energy front.