Skip to main content

velocity_loops

Function velocity_loops 

Source
pub fn velocity_loops(
    entry: &MachineEntry,
    cfg: &Config,
    targets: &Targets,
) -> Result<Tuned, ConfigError>
Expand description

Tunes every motor’s velocity loop: for each motor, in the order the machine lists them, the largest velocity gain at which the least phase margin and the least gain margin over all poses of margin_poses meet targets and the loop is LoopMargins::stable at every pose (the other motors as they are at that point). Tn stays and Kv follows as with_gain says. Then, where targets.notch is set and the notch is off, for each motor in turn: if the gain margin is what stops its gain, at a resonance (the sensitivity of the gain that fails peaks at a mode of the machine, Machine::modes at that pose, or up to PEAK_OVER_MODE times above it), a notch is put on that mode (the highest such) with NOTCH_WIDTH times its frequency as its width, the gain is searched again, and the notch stays only where the gain is NOTCH_MIN_GAIN times higher. The switch is the whole machine’s: where a notch stays it is on, and every motor without one gets notch_frequency_hz = 0 (no notch). A final call of velocity_loop_margins on the whole tuned config verifies all motors; a motor that fails there is lowered by JOINT_FACTOR, at most JOINT_ROUNDS times, and says so (lowered_in_joint_check). The gains returned are those of the last verification. Every measurement is taken with friction as configured and with it off (measure). Where no gain meets the targets met is false and the gains are the best found. One search takes at most BRACKET + BISECTIONS + 1 calls per motor (and as many for the notch).