Here is a setup that looks like it should just work. A policy decides where each joint of an SO-101 arm should be, LeRobot sends those angles to the servos 30 times a second, and each servo, being a position controller, drives its joint to the angle it was given. Run a recorded motion (it is called cat) on a real arm this way, and on average the joints end up 22.5 mrad away from where they were asked to be. That is about 1.3°, on an arm whose gripper reaches about 30 cm.
So the servo is told an angle and goes somewhere else. I like this puzzle because we get just one number to work with: the angle we send. How much can we fix with that? To answer, we need to pull apart four angles that the default setup treats as one:
- target q*: where we want the joint, from the policy or a planned path;
- goal g: the angle we actually send to the servo;
- physical angle q: where the joint really is;
- reading q̂: what the encoder reports, in integer ticks.
The default controller (LeRobot's direct) sets g = q* at every update. Tracking error is how far the joint ends up from q*. The question for this article: what g should we send instead?
direct controller at 30 Hz, replaying the recorded cat joint angles. The statistics cover a 16 s window. The arm overlay magnifies deviations ×10 and compresses large ones; the plots show true errors in mrad on shared scales.Units on this page
1 mrad is 0.001 rad. One degree is 17.45 mrad, or about 11.4 encoder ticks, and one tick is 1.534 mrad (0.088°). A torque divided by a stiffness is an angle: N·m ÷ (N·m/rad) = rad. A damping divided by a stiffness is a time: (N·m·s/rad) ÷ (N·m/rad) = s.
A position servo is a spring you can move
Start with the simplest servo there is: proportional control. It looks at the gap between the goal and the joint and pushes with a torque proportional to it, τ = kp (g − q). That is a torsional spring. You hold one end at angle g, the other end is bolted to the joint, and moving g drags the joint along. The stiffness kp is in N·m/rad. For the worked example I'll use the simulator's model of the STS3215 servo (fitted for the 12 V motor by the open-source BAM project, at LeRobot's setting P = 16), where kp = 13.64 N·m/rad. The simulator lets us switch physics on and off one term at a time. The real servo differs, and we'll line the two up near the end.
Predict. Target and goal are both −0.321 rad, friction is zero, and gravity pulls on the shoulder with 0.391 N·m. Where does the joint settle?
Answer
28.7 mrad on the gravity side, which is G/kp.
Now hold the shoulder out in the air, where gravity pulls on it with G = 0.391 N·m. A spring only pushes when it is stretched, so for the joint to stand still the gap has to be G/kp = 0.391 / 13.64 = 0.0287 rad, or 28.7 mrad. With g = q*, all of that stretch comes out of the joint: it sags 28.7 mrad below the target and stays there. The servo is doing its job perfectly. It's a spring, and a loaded spring stretches.
And now the fix is obvious: aim high. Send g = q* + G/kp and the spring gets its 28.7 mrad of stretch with the joint sitting exactly on target (as long as we know G and there is no friction, which we'll come back to). Keep this move in mind, because the rest of the article repeats it. Every torque the joint needs, to hold, to accelerate or to push through friction, has to come from a gap, and on this servo a gap costs about 73 mrad per N·m (that is 1/kp). If we know a torque in advance, we can put its angle into the goal. If we don't, it shows up as tracking error.
Inside the servo, and the one knob we get
Why not just make the servo try harder? An STS3215 is a small closed box: motor, gearbox, encoder and an embedded controller. The embedded controller runs a fast loop (its exact rate is not documented) that compares the encoder with the goal and sets motor power. Our code runs a second, slower loop outside the box, at 30 or 60 Hz, and the only thing it can do is write a new goal. Everything in this article happens through g.
The inner loop is a PID controller, and each part has a physical meaning. P is the spring stiffness we just met. D opposes velocity, so it behaves like damping. I adds up error over time, and given time it would remove the gravity sag by itself. LeRobot connects every motor with P = 16, I = 0, D = 32 (and caps the gripper's torque at 50%, which its code attributes to burnout protection). With I = 0, nothing inside the box removes sag, so that job is ours. The reason for I = 0 is not documented. My guess is that it avoids integral windup on a gripper squeezing an object, which would hold full torque and heat the motor.
What P, D and I do to a gravity-loaded step
This is a teaching model, not an identification of the hardware. The P torque is 13.64(g − q); P+D subtracts the velocity v; P+I adds 20∫e dt. P alone oscillates and keeps its sag. Adding D settles smoothly but keeps the sag. Adding I removes the sag eventually, with oscillation on the way.
Predict. Which of these can a controller read from the arm's calibration file?
Answer
Only the geometry: the zero position and the range.
What about calibration? The calibration file, hadrien_follower.json, holds five integers per motor: id, drive_mode, homing_offset, range_min and range_max. For shoulder_lift the homing offset is 941 ticks and the range runs from 844 to 3214 ticks. That is geometry: where zero is and how far the joint may go. Nothing in it describes this arm's stiffness, damping, friction, delay or gravity, and every motor gets the same servo settings. The physics is ours to supply.
The whole joint in one line
Follow one goal around the loop:
target q* → goal g that we send → after dead time D, servo torque kp [g − q̂] → joint angle q → encoder reading q̂ in ticks → back to the servo
Now write the spring idea out for everything the shoulder has to pay for:
kp [ g(t − D) − q̂ ] = M(q) q̈ + G(q) + d q̇ + f sign(q̇) + C(q, q̇) q̇
The left side is the servo: a spring of stiffness kp stretched between the goal and the encoder reading, except that the goal it acts on was sent D seconds ago. That D is dead time, the pause before the servo responds at all. On the right is everything the spring pays for. We already know it has to hold the arm against gravity, G(q). Moving adds more work. We have to get the links accelerating, push against damping and dry friction, and handle the forces that one moving link puts on another. Those are the other terms on the right. We'll take them one at a time. Two actuator effects, the dead band and the torque limit, don't fit inside the equality, and they get their own section.
Now do what we did with gravity. If we know the target path q*(t), we know its velocity and acceleration too. Put the target in place of the joint on the right side and solve for the goal:
g(t) = q*(t + D) + [ M q̈* + G + d q̇* + f sign(q̇*) + C q̇* ] / kp
The bracket is the torque the target motion needs, turned into angle. The shift to t + D sends each goal early so that it lands on time. This is feedforward: it uses only what we know about the target, and it is exact when the model terms are exact. The derivatives come from the planned path, never from the encoder (the encoder section shows why). Whatever the model misses still shows up as measured tracking error, and correcting that is the job of feedback.
The terms come in three families that fail in different ways: the actuator, the mechanics and the sensing. Here is each one with its size on the shoulder (in mrad at 0.7035 rad/s where it has a share of the budget) and a link to its section:
Three different kinds of late
Watch the real arm follow a smooth path and the reading trails the target by roughly 100 ms. That 100 ms is three different effects stacked together, and each one has its own fix.
direct control at 30 Hz, 6 s trace. The reading trails the target by about 100 ms.Dead time is the pause before anything moves. Jump the goal on the hardware and the first visible motion comes 31–36 ms later. Fitting whole motions, with lag and dead band fitted jointly, gives 15.6–26.6 ms per joint instead. The two methods disagree and I haven't pinned down why. The simulator we started from has roughly zero. Feedback can't remove dead time, because every correction it computes is itself D late, and strong late corrections overshoot. A faster outer loop doesn't remove it either: with D = 33 ms the servo is 33 ms late at 30, 60 or 100 Hz. What works is preview. If you know the target, send q*(t + D).
Try it. This is a teaching model, not the hardware: the simulator's shoulder spring and damping (13.64 N·m/rad, 1.058 N·m·s/rad), an illustrative inertia of 0.06 kg·m², gravity 0.391 N·m, goals at 30 Hz and D = 33 ms. The target makes a smooth 0.3 rad move. Three goals race: the target itself, the target plus an outer correction that adds up the measured error at a chosen gain, and the predictive goal q*(t + D) plus the torque terms. With scripts on, you can change D and the gain. Look for this: the plain target sags and trails, a weak correction removes the sag slowly, a strong one overshoots because each correction lands D late, and the predictive goal stays close to the path.
The dead-time estimates side by side
Command hold
At 30 Hz the goal changes every 33.3 ms and sits still in between. While the target moves, the goal the servo chases is on average half a period old, Δt/2 = 16.7 ms. At 60 Hz that drops to 8.3 ms. This is the one timing effect that a faster loop shrinks. LeRobot's 30 Hz comes from its cameras and policy; how fast the serial bus, the USB adapter and Python overhead would let the goal loop run has not been measured.
Damping is a lag in disguise
The third one is the biggest. Damping is a torque proportional to speed, τ = d v, and the simulator's d is 1.058 N·m·s/rad (motor back-EMF is folded into it). To move at speed v the spring must supply d v, which takes a gap of d v / kp. That gap is v times a constant, and the constant has units of seconds: d / kp = 1.058 / 13.64 = 77.6 ms. At steady constant speed, the damping gap equals the distance traveled in 77.6 ms: angular error = speed × lag.
Predict. In the simulator (almost no dead time), d/kp = 77.6 ms and goals update at 30 Hz. Roughly how far behind a moving target does the joint trail?
Answer
About 94 ms: 77.6 ms of damping lag plus 16.7 ms of average goal age.
Add the 16.7 ms of command age and the simple estimate is about 94 ms. At 0.7 rad/s that is around 66 mrad of error, with about 32 mrad of gravity sag on top (G = 0.442 N·m in that pose). The simulated arm's measured lag is 105.5–108.4 ms, so the simple estimate comes out about 12% short. Fitting a servo model to the hardware gives a lag of 87–105 ms. That is close to the roughly 100 ms we see in the real trace, but the fit and the trace estimate lag differently, so I wouldn't treat the agreement as a validation.
Try it. Lag = d/kp + Δt/2, error = speed × lag, and gravity adds G/kp on top. With scripts on, change the damping, the stiffness, the update rate and the speed.
Where the spring stops being a spring
The spring picture has two edges. Near zero gap the real servo has a dead band: if the gap is inside it, the motor does nothing. Fits on the hardware put it at 8.1–21.0 mrad depending on the joint, about 5 to 14 ticks, and outside it the servo pushes as if the gap were shorter by the band. So a goal offset that works while the joint moves one way must change by twice the band when it reverses. The simulator we started from has no dead band.
Torque limit
At the other edge, torque saturates. The simulator clamps it at 5.107 N·m, about 5.1. Past that point, pushing the goal further changes nothing, so no choice of g produces more torque. The defense is to plan motions that never ask for it, for example by braking earlier and more gently. As an illustration, on a joint with J = 0.06 kg·m², a late stop might need 7 N·m where an early one needs 3.
Heat
Heat lowers the clamp. Copper's resistance rises about 0.4% per °C, so at a fixed supply voltage the current and the torque fall, and the magnets weaken as they warm. An illustrative servo delivers about 82% of its 25 °C torque at 80 °C. The STS3215 also has an over-temperature cutoff. None of this was measured on the arm, and the simulator has no temperature model. In practice it means a stiffness you identify on a cold servo drifts down as the servo works.
Braking against the clamp, and torque against temperature
Gravity depends on how far the arm reaches
The G = 0.391 N·m we used belongs to one pose. The gravity torque at a joint comes from the horizontal distance between the joint and the weight of every link beyond it. Stretch the arm out flat and the shoulder carries the most. Stack the links straight up over it and, in the ideal case, it carries nothing.
The real arm shows this clearly. With direct control at 60 Hz and small shoulder_lift steps, the mean error is −3.8 mrad with the arm tucked (the servo reports about 1% load) and +42 mrad with it extended (about 11% load). Same servo, same controller, and the pose alone moves the mean by 46 mrad. The scatter around each mean comes from static friction, which gets its own section. The goal offset has to follow the pose: G(q)/kp.
direct control at 60 Hz, small shoulder_lift steps in the tucked and extended poses. Overlay deviations ×10 and compressed; plots in true mrad.One thing I can't explain yet: the elbow sits about 70 mrad (4°) off while its target is held fixed, in both poses and across the single-joint recordings. Gravity would change with pose and this offset doesn't, so I suspect a fixed calibration offset. I haven't checked it.
How a gravity model sees the pose
Gravity torque depends on the angle of each link from vertical: qshoulder, qshoulder + qelbow, and qshoulder + qelbow + qwrist. A fitted gravity model uses the sines and cosines of these three angles as its features.
Pick something up
A payload adds to both gravity and inertia. In a MuJoCo SO-101 held at the real arm's reach pose, with the arm's own weight precompensated, an unmodeled 200 g load appears at t = 2 s. shoulder_lift sags about 40 mrad and the elbow about 33. At the home pose, a 150 g tool adds about 0.38 N·m of shoulder gravity torque and 200 g adds about 0.50 N·m, which at 73 mrad per N·m is about 37 mrad.
The inertia M(q) also grows as the arm extends or carries more, but it only costs anything while the arm accelerates. In the moving example at the end it is worth 2.1 mrad. Holding still, the added weight is what matters. Now reverse the motion. At the same pose, gravity still pulls the same way, but friction switches direction. Our goal offset has to account for that.
Static friction turns a point into a band
While the joint moves, dry friction is easy: a constant f = 0.196 N·m against the velocity, the same at any speed, added on top of damping. Standing still is where it gets interesting. The friction on a stuck joint is whatever torque between −f and +f keeps it stuck.
Put that into the balance at rest, kp · gap + F = G with F anywhere in [−f, +f], and the gap becomes a range: (G − f)/kp to (G + f)/kp, or 14.3 to 43.0 mrad. The frictionless 28.7 sits in the middle. Where the joint stops depends on how it arrived. Come down onto the target and friction, which opposes the downward motion, helps hold the arm up, so the joint stops at the lower edge, 14.3 mrad. Come up and friction resists the spring, so it stops at 43.0. That is hysteresis, and a single fixed offset can't serve both approaches: aim at the middle and you miss by about 14 mrad from either side.
Try it. The band runs from (G − f)/kp to (G + f)/kp at kp = 13.64 N·m/rad. With scripts on, change G and f and watch where each approach stops.
Simulators get this part wrong in an instructive way. With the goal already compensating the arm's own weight, start the shoulder on target and ramp in a 200 g payload between 1 and 3 s, adding 0.614 N·m at the shoulder. Without friction it should settle at 0.614/kp ≈ 45 mrad. With ideal sticking friction it should stop at (0.614 − f)/kp ≈ 31 mrad and stay there forever. Frictionless gives 44.8 mrad at both 4 s and 12 s, and exact stick/slip gives 31.3 at both. The simulator's own friction gives 33.9 at 4 s, about 38 at 6 s and 43.4 at 12 s.
Predict. The soft-friction hold drifts from 33.9 to 43.4 mrad. Which statements fit? Pick all that apply.
Answer
The first two. The simulator has no temperature model, and nobody measured real-servo sticking on this arm.
The creep is numerical. Exact sticking needs a decision at every step: is the joint stuck (friction anything up to ±f) or sliding (friction exactly f)? MuJoCo instead treats friction as a soft constraint that allows a small nonzero velocity, set here by solref = 0.02 s, and Genesis regularizes it in a similar way. That small velocity, integrated over seconds, walks the joint toward the frictionless answer. Whether a real geared servo sticks as firmly as the exact model is unmeasured on this arm.
The exact version has its own trap. The first discrete implementation almost never saw a velocity of exactly zero, so friction flipped sign every step and the joint stopped 37 mrad off. Treating any change in the sign of the velocity as a stop restored the 31 mrad endpoint.
More friction holds better and tracks worse
Back to our original shoulder, with G = 0.391 N·m, holding still in the simulator. Friction initially helps hold it up: at 0.17 s the error is only 14.0 mrad, near the lower edge of the band. But the simulator lets it creep. By 6 s the error is 23.45 mrad and still heading toward the frictionless 28.7.
Now wear the arm out. In the worn simulation, dry friction is 2.5 times higher and damping is 1.5 times higher. The friction f becomes 0.49 N·m, more than gravity's 0.391, and at 0.17 s the hold error drops to 0.7 mrad. Friction does the holding (the soft model still creeps, to 17.2 mrad at 6 s).
Then the arm moves at 0.7 rad/s and the picture flips. The Coulomb contribution grows from 14.4 to 36 mrad and the damping contribution from 54 to 81. The worn arm's error is 64.8 mrad on a multisine trajectory and 73.4 on one shaped like policy output. Moving paths dominate a tracking score, so the worn arm is worse overall even though it holds better.
Richer friction models
Low-speed friction is richer than Coulomb's constant. Breakaway torque (stiction) can exceed what sliding needs. Right after breakaway, friction can dip before viscous friction takes over: that dip is the Stribeck effect. The joint can also move a little before it starts sliding, and its friction can depend on how it moved a moment ago. LuGre models that behavior by keeping an internal state. And friction can grow with load, F = Fc + μ|τ|.
Does the extra machinery help? A Genesis model was fitted to real logs, then evaluated in simulation on recorded motions excluded from fitting. With Coulomb friction alone, the shoulder_lift error is 21.8 mrad. Adding load dependence brings it to 18.9–19.2 mrad. Adding LuGre as well brings it to 15.9–16.2, level with the 15.9 of the fitted servo-model reference. Stribeck gave no reported improvement, and LuGre alone gave 3–8%. Settings differed between runs, so the ranking is preliminary.
Friction compensation near zero speed is also where controllers go unstable if they overcompensate (Canudas de Wit et al., 1991). A controller built on this model needs smoothed friction compensation near zero speed, and it must not chase small reversals across the dead band.
The friction curves
Teaching values, not identified hardware constants: Coulomb f = 0.196 with viscous d = 1.058; Stribeck fs = 0.3, fc = 0.196, vs = 0.02 plus the viscous term; LuGre σ0 = 100, σ1 = 1 with a slow reversal; load-dependent curves at |τ| = 0, 0.5 and 1 N·m. Torque is in N·m and speed in rad/s.
With scripts on, pick a model to draw its torque against speed. The vertical segment at zero speed is the range a stuck joint can supply.
The speed-squared terms are tiny here
The last mechanical term is coupling, C(q, q̇) q̇. Spin the shoulder and the forearm wants to fling outward with a centrifugal force m ω₁² r. Move the elbow at the same time and a sideways Coriolis force 2 m ω₁ v joins in. Both grow with speed squared. On the full simulated arm, extended, spinning the base at 1.1 rad/s moves shoulder_lift by 0.38 mrad, about a quarter of a tick, and lifting with shoulder and elbow together at that speed costs 1.5 mrad, about one tick. Gravity sag in the same setup is 43 mrad. Since 1.1 rad/s is about the fastest the recorded real motions go, I drop this term. Doubling the speed would quadruple it, to about 6 mrad.
Try it. Coupling error scales as (speed / 1.1 rad/s)². With scripts on, drag the speed and compare the error with one tick and with the 43 mrad of gravity sag.
The two-link teaching model
A horizontal two-link mechanism at SO-101 scale, with gravity excluded. Shoulder speed ω₁ gives the elbow a torque h sin(q₂) ω₁², with h = m₂ l₁ lc2. Elbow speed ω₂ gives the shoulder a coupling torque h sin(q₂)(2ω₁ω₂ + ω₂²). The signs follow the figure's convention. At 1.1 rad/s these torques are a few mN·m.
The encoder counts in ticks
So far we have pretended to know q. What we know is q̂. The encoder has 4096 ticks per revolution, so one tick is 1.534 mrad. Rounding to the nearest tick adds 0.443 mrad RMS, which is small. The trouble starts when you differentiate: difference a one-tick blip twice at 30 Hz and it looks like 1.4 rad/s² of acceleration. That is why the feedforward goal takes q̇* and q̈* from the target path. Estimating the state more finely than the sensor reads is its own problem, and part 2 takes it on.
The simulator's servo is a different servo
Every constant in the worked example came from the simulator's servo model, and none of them were measured on this arm. Step tests and servo-model fits on the real hardware disagree with it on almost every line of the board. The real servo is a little stiffer (15.6–16.5 against 13.64 N·m/rad) and much more damped, with a damping ratio of 1.15–1.20 against the model's 0.68. A ratio below 1 overshoots a step and a ratio above 1 settles without overshoot, so the two servos respond to a goal jump differently. The real one also has 31–36 ms of dead time and an 8.1–21.0 mrad dead band that the model lacks.
Two lessons come from this table. A controller tuned on the model expects overshoot that the arm doesn't produce, and it ignores a delay that the arm does have. And a parameter is only as good as the experiment behind it: the step test and the fit give different dead times for the same servo.
Adding it all up
Predict. The simulated shoulder moves at 0.7 rad/s. Which term costs it the most angle?
Answer
Damping, at 54.6 mrad.
Now the payoff. Take the simulated shoulder_lift moving at 0.70 rad/s (0.7035 precisely), where the measured tracking error is 115.2 mrad. Convert each torque to angle at kp = 13.64 N·m/rad and add the command hold:
| term | torque | angle |
|---|---|---|
| gravity G | 0.442 N·m | 32.4 mrad |
| damping d v | 1.058 × 0.7035 ≈ 0.744 N·m | 54.6 mrad |
| dry friction f | 0.196 N·m | 14.4 mrad |
| inertia J a | 0.028 N·m | 2.1 mrad |
| command hold | 12.0 mrad | |
| sum | 115.3 mrad (measured 115.2) |
Damping is the largest piece by far: at this speed it costs more than gravity. As a formula, with all the torques pushing the same way as they do in this example:
e ≈ (G + d v + f + J a) / kp + v Δt / 2
Would a stiffer servo fix it?
The formula says what stiffness buys: the torque part shrinks like 1/kp and the hold part doesn't move. A different simulated test, with the default controller on another motion, checks this. The nominal error there is 37.2 mrad at kp = 13.64. A stiffer servo at 22.1 N·m/rad (×1.62) gives 24.8 mrad, where scaling all of the error by 1/kp would predict about 23. Fit those two results with one part that shrinks as stiffness rises and a fixed part left over: 32.2 × 13.64/kp + 5.0 mrad. Now test the fit on a weaker supply, with stiffness 12.31 N·m/rad: it predicts 40.6 mrad, and the simulation gives 40.5. The 5 mrad that refuses to scale is the command-hold floor.
Turning the stiffness up further runs into everything else. Dead time stays. Torque saturates at 5.1 N·m. Each encoder tick becomes a torque step of kp × 1.534 mrad. Delayed feedback turns high gain into alternating overshoot and chatter: in one reported test, an outer gain of 4 was stable and a gain of 100 oscillated. Past a point, more gain buys less accuracy and then buys instability.
So, which goal?
Send the target shifted D ahead, plus every torque the motion needs divided by the stiffness. Sending goals more often trims the 12 mrad of command hold, and you can drop the speed-squared terms. The error that remains tells you what is missing: terms you left out of the model, parameters you got wrong, the encoder's ticks, and the distance between the simulated servo and the real one. Part 2 reads the joint more finely than the sensor, part 3 builds this goal formula into a controller and chooses which terms to compensate, and part 4 learns what the physics misses.