Skip to main content
NewEpisode 3a is out: Carry the conversation onWatch →

This part is for members

Membership opens soon. Leave your email and we'll tell you the day it does. Founding members get the launch price.

Keep watching the free parts
Motion modes · 27c

MIT mode 3: the spring behind a gearbox

MIT mode, part three: what the master's Kp and Kd mean when the joint has a gearbox. It opens with the whole episode on one framework page: the master speaks joint units, mit_ctl runs on the motor, and MitModeRun carries every number across the gearbox each tick. Angles go × N and torques / N, so stiffness and damping must go / N²; the code divides by N once, so the joint is N times stiffer. On the page, the joint side on the left, the motor side on the right, and one row per number with the factor the code uses: the position, the speed and the set torque are right, Kp and Kd are wrong; underneath, the joint position comes back (motor counts / N). Running example: the SIL's gim6010 (8:1, 2^21 counts, Kt 1.2, no joint encoder); the master sends Kp 1 and Kd 0.05 at the joint and 0.8 N·m pushes the joint. Guess first: a spring of 1 should give way 0.8 rad; it gives way 0.1002 rad. Five stops follow the last tick of a 6 s run: where the joint is (no joint encoder: get_app_Position_actual_value_inc divides the motor's −267,563 counts by 8 with PosUnitMotorToLoad, −33,446 → episode 12c); angles × 8 (L57–59: 33,445 × 8 × 1 + (−267,563) = a motor target of −3; the motor is 0.8016 rad off, eight times the joint); torques / 8 (L66 is right: with the master's set torque at 0.8 from the push, both builds end within 0.003 rad of the target); the gains / 8 too (guess; worked out it should be 1/64 = 0.015625, the code gives 0.125: the joint gets a spring of 8 and a damper of 0.4); the formula on the motor side (0.8016 × 0.125 = 0.1002 N·m, / 1.2 = 0.0836 A as the bench prints, × 8 holds the 0.8 push; stiffness 7.98, and no error). The fix: the course fork's branch fix/mit-gain-gear-ratio divides by the ratio twice (labelled patched): 0.8007 rad, stiffness 0.999; at 1:1 both builds are byte-identical; the damping drops 8 times too, the patched joint swings to 1.26 rad first and the pinned one to 0.122 (measured: this motor's current loop lags as it speeds up → episode 10b), so choose Kd again the 27b way. Not shown: a joint encoder → 12d; halt and quick stop → 27d. Your turn: with the firmware unchanged, the master sends Kp/8 and Kd/8, and the result matches the patched build number for number. The bench sil-mac/ep27 gained --every; servohub is unchanged.

Up next27d · MIT mode 4: stopping→