Kinematics and control
A policy (a neural network that picks the robot's next action from what it sees) outputs a target: "gripper — over here" or "joints — to these angles." A motor, though, understands only torque: how hard to turn the joint. Between the target and the torque sits a layer of classical methods, and in this lesson we walk through it step by step: kinematics turns a gripper pose into joint angles, a controller turns angles into torques, impedance sets how hard to push on contact, and planning over a horizon helps avoid driving into a dead end. Without this layer it is unclear what neural network policies output and who executes their commands. If the topic is familiar, you can skip the lesson.
Joint angles and gripper pose
Ada reaches for a cup with a two-link arm. The policy says: "gripper — to the cup." But the motors sit in the joints and rotate the links. So we need to find the joint angles that put the gripper at the cup.
Ada is a home humanoid on a wheeled base; the course labs are built around her. Read more about her in lesson 0.1.
Why is this hard? Each joint moves the gripper along its own arc, and the gripper position depends on all the angles at once. Going the other way is easy: given the angles, the gripper position is just the link vectors added together. This is forward kinematics. On the left scene, try to hit the target with the gripper by moving only the angles.
It is more convenient to solve the inverse problem: from the desired gripper pose, find the angles right away. This is inverse kinematics, and for a two-link arm a formula solves it. On the right scene, drag the target and the arm will show all the solutions. Check whether there is always just one.
Angles → pose
Top view of Ada's two-link arm. The shoulder is fixed at the center, the gripper is at the end of the arm. The crosshair is the target, for example a cup. The gripper only reaches points between the two dashed circles.
Pose → angles
Under the hood: formulas for the two-link arm
Forward kinematics:
Inverse kinematics:
The sign gives two solutions. If the right-hand side of the first line is greater than one in absolute value, the target is out of reach. On the outer and inner boundary of the workspace the solutions merge into one. In this lesson m and m. To make the boundary easier to catch, the target on the right scene snaps to it within 2 cm.
Real arms have more solutions: a PUMA with a spherical wrist has 8, a general six-link arm up to 16, a seven-link arm infinitely many. See chapters 4–6 of Lynch and Park's "Modern Robotics" for the details.
So picking angles by hand is awkward, while the formula finds them at once. There can be two solutions: the elbow can bend one way or the other. On the boundary of the workspace there is one solution, and beyond it there is none.
The formula puts the gripper at a single point. But a policy usually guides the gripper along a path and says many times a second where to move it next. How does a small joint rotation shift the gripper, and in which direction does the arm move more easily?
Where the arm moves easily
To guide the gripper along a path, we need to know where it will shift from a small rotation of each joint. The answer depends on the arm's pose.
This relationship is described by the Jacobian: it maps joint velocities to gripper velocity. Rotate both joints by a small angle in every combination and mark where the gripper ends up. You get an ellipse: along the long axis the arm moves easily, along the short one with difficulty. If the ellipse has flattened into a segment, there is a direction in which no joint rotation can move the gripper. This is a singularity.
Drag the gripper. Each position lands as a point on the plot: how round the ellipse is at that distance from the shoulder. Find where the arm moves most easily and where it loses a direction.
Horizontal axis: distance from shoulder to gripper, m. Vertical axis: roundness of the ellipse, the short axis divided by the long one.
Under the hood: the Jacobian, velocities and forces
For a two-link arm the Jacobian is a matrix. Its determinant vanishes when the arm is stretched out () or folded (). The ellipse on the scene is the image of the unit circle of joint velocities; its semi-axes are the singular values of . Roundness is the ratio of the smaller one to the larger. It depends only on , and therefore on the distance between shoulder and gripper, so the points fall on a single curve. For the arm in this lesson the roundness never exceeds 0.84: the maximum is at , 0.36 m from the shoulder. The ellipse would be perfectly round if the second link were times shorter than the first.
The same Jacobian works for forces too: to press the gripper against a table with force , the joints need torques . It will come in handy in the impedance lab. Singularities are not only at the edge of reach: a six-link arm has a wrist singularity inside the workspace.
The arm is most agile 0.36 m from the shoulder. Toward the edges of the workspace the ellipse flattens: a stretched or folded arm has a direction in which the gripper cannot move.
For a two-link arm, the kinematics and the Jacobian take a few lines of formulas. A six-link arm has up to 16 solutions of the inverse problem, a seven-link arm infinitely many. Can we skip the formulas and learn kinematics from examples?
A neural network learns kinematics
For a complex arm the inverse kinematics formulas can be hard to derive, and for every new arm they have to be derived all over again.
So we can train a network instead: gripper pose in, joint angles out. Training examples are easy to get. Take random angles, compute the gripper pose with forward kinematics and record the pair "pose → angles". You can collect as many pairs as you like.
Let's test this: train two identical networks side by side on different data and send their arms to the same target.
Under the hood: the data, the network and where the average comes from
- Data. 6,000 pairs. The angles are drawn uniformly from −180° to 180°, from −175° to 175°. Network B keeps only the poses with .
- Input and output. Input: the gripper coordinates divided by 0.9 m. Output: , so the angle does not jump at the ±180° boundary.
- Network. 2 → 48 → 48 → 4 with Leaky ReLU, Adam, 900 steps of 64 examples each, learning rate 0.005 and 0.0015 at the end. Both networks start from the same weights.
Why the average. For the two solutions of one pose, is the same, while is equal in magnitude and opposite in sign. The minimum of the mean squared error is the average of the answers, that is . So the network outputs or : the arm is stretched out or folded and points at the target. The miss is the difference between the distance to the target and the length of such an arm. That is why the training loss of network A never drops below 0.8, while network B's goes down to 0.01.
The networks have the same amount of data, yet their misses differ: on average 23.5 cm for network A and 2 cm for network B. For network A, one gripper pose has two correct answers, and it outputs their average. Regression gives a wrong answer when one input has several correct answers. This is multimodality, and lesson 1.3 is devoted to it.
Joint angles can now come from a formula or from a network. But how do you turn a joint to the required angle if the motor only produces torque?
Controller: spring and damper
The motor produces torque, but we need an angle. The torque has to be computed so that the joint arrives at the required angle and stays there.
Why is this hard? An arm that has picked up speed overshoots the target by inertia. And an arm holding a cup is also pulled down by the weight all the time.
A PD controller solves it like this: it computes the torque for each joint from two parts. The proportional part pulls toward the target like a spring: the farther from the target, the harder. The derivative part damps the velocity, like a damper.
The arm hangs in a vertical plane holding a cup, and it needs to lift the cup to a shelf. The controller knobs appear one at a time, mission by mission.
Under the hood: PD with gravity compensation
are the target angles, and the current angles and velocities, the torques that, according to the model, balance the weight of the arm. is the stiffness of the virtual spring in N·m/rad, is the damper. With exact gravity compensation a PD controller reaches the target from any initial position (Takegaki and Arimoto, 1981).
Without compensation, at equilibrium : the spring is stretched just enough to hold the weight. So the sag is inversely proportional to : roughly cm. The integral part of a PID controller removes the sag without a weight model: it accumulates the error and builds up the torque.
How the criteria are computed. Each run lasts 4 s. Sag is the largest gripper error over the last 0.5 s, swing is the difference between the largest and smallest error over the last second, settling time is the moment after which the error stays within 1 cm of its final value.
In the lab the links are 0.5 and 0.4 m, masses of 1.2 and 0.9 kg are concentrated at the link ends, the simulation step is 1 ms. For comparison, in real systems: in legged_gym for the A1 robot N·m/rad and ; for ANYmal and .
A spring without a damper keeps swinging; the damper kills the swing. Stiffness only reduces the sag under the weight: 12.6 cm at Kp = 60, 3.8 cm at Kp = 190. Gravity compensation removes it, and then a moderate Kp is enough.
Such a controller brings the gripper precisely to the target, and in free motion that is exactly what we want. But the gripper target is often computed from a camera, and cameras make mistakes. What happens if, because of an error, the target ends up inside the table?
Impedance: how hard to push
Ada is wiping a table. She takes the table height from the camera, and the camera is off by 4 cm: the gripper target ended up below the surface.
In lab 2 we made the controller hold the target precisely. A stiff position controller pulls the gripper to the given point at any cost. Here the point is under the table: the table does not let the gripper reach it, and the controller keeps pulling.
The way out is an impedance controller. It behaves like a spring of a given stiffness in gripper space: the force grows with the distance to the target, and that is all. We choose the stiffness ourselves, so we know in advance what force an error will produce.
Two arms wipe the same table and reach for the same wrong target. The left one is driven by a position controller, the right one by an impedance controller.
Side view. The crosshair is the target toward which the controller pulls the gripper with the cloth.
The plot shows each arm's contact force against the table, N, over 3 seconds: the black line is the position arm, the blue one is the impedance arm.
Under the hood: the impedance controller
The controller imitates a spring of stiffness and a damper in gripper space, and gets the joint torques through the transposed Jacobian. In the lab is set by the slider (400 N/m at first), , and the table is a stiff spring of 6,000 N/m with a damper. The position controller is a PD on the angles with and gravity compensation. The target lies 2 cm below the table so that the cloth is pressed down, plus the camera error. The contact force at rest is the mean force over the last 0.5 s of the three-second run.
The idea was formulated by Neville Hogan in 1985: "Control of position or force alone is inadequate; control of dynamic behavior is also required." Learned policies also learn to set compliance: VICES (2019) outputs controller parameters at 20 Hz, and ACP (2025) varies the stiffness in space and time.
With a 4 cm camera error the position arm hits the table with 299 N, the impedance arm with 76 N. Impedance turns a perception error into a predictable force, roughly . The stiffness is chosen for the task: the higher it is, the closer impedance gets to a position controller.
The controllers in this lesson pull the gripper straight to the target. What if the straight path to the target leads into a dead end?
Receding horizon
A controller looks only at the current error and pulls straight toward the target. If the straight path runs into a wall, it gets stuck: to go around the wall you first have to move away from the target, and a controller will not do that.
We need to look ahead using a model. The planner tries out motion options a few seconds ahead, picks the best one, executes only the first step and plans again from the new place. This is how MPC, model predictive control, works. The plan is recomputed at every step, so pushes and model errors are taken into account right away.
Let's take a simpler example: two robots drive across the floor toward a target, and a U-shaped trap stands in the way. Their planners are the same, their horizons differ. How far ahead do you need to look to get out?
Under the hood: how this planner works
A point moves at 0.5 m/s and at every step (0.1 s) picks a heading. The heading over the horizon is set by 5 control values with linear interpolation between them. The best plan is found by the cross-entropy method: 4 iterations of 64 candidates, 20 of them random headings around the full circle, and the 8 best define the distribution for the next iteration. The cost of a plan is the distance to the target at its end, plus the mean distance along the way with weight 0.3, plus a penalty of 2 for a collision. The warm start is the previous step's plan shifted one step forward. The randomness of the search comes from a generator with seed 11, so every run repeats exactly.
When you change the trap, the "path exists" check looks for a passage from start to goal on a grid with a 2 cm step. Cheetah 3 solves a convex quadratic program instead of a search: the model is simplified so that the optimum is found in a fraction of a millisecond.
With a 0.6 s horizon the robot gets stuck in the trap; with a 3 s horizon it finds a way around. The shortest horizon with which it gets out is 2.1 s. A long horizon costs computation, and for any horizon there is a trap longer than it.
In legged robots MPC runs at 20–100 Hz. MIT Cheetah 3 has a horizon of up to 0.5 s, and the problem is solved in under a millisecond. The idea "plan a chunk of actions, execute the beginning and plan again" will return in lesson 1.7: that is how action chunking works.
Now we have the whole classical layer: kinematics, controller, impedance and MPC. How does it connect to neural network policies in real robots?
Who executes the network's commands
In real robots the network and the classics usually connect the same way. A neural network policy almost never outputs motor current. It outputs targets, joint angles or gripper poses, and the layer from this lesson executes them: controllers, kinematics, MPC. Pick a system and see where the network ends and the classics begin.
Sort by frequency
The layers also differ in frequency. All the frequencies you need are in the tabs of the diagram above. Sort the cards into bins: drag a card, or tap it and then a bin.
Eight common misconceptions
Lesson takeaways
- Forward kinematics is geometry. The inverse problem can have two solutions, one or none.
- The Jacobian links joint and gripper velocities, and through , forces and torques. At a singularity the arm loses a direction of motion.
- A network trained on kinematics fails when one input has several correct answers: regression outputs their average.
- A PD controller is a spring and a damper. Sag under the weight is removed by gravity compensation, not by endlessly raising Kp.
- Impedance sets how hard to push: a perception error turns into a moderate force rather than an impact.
- MPC plans over a horizon and recomputes the plan at every step.
- Neural network policies usually output targets, and this layer executes them. The closer a layer is to the motor, the faster it runs.
Open questions
Why is soft impedance better for pushing a plug into a socket, while stiff impedance is better for holding a heavy pot?
The clearance between plug and socket is a fraction of a millimeter, and the camera is off by more than that. A soft gripper will yield and slide into the hole on its own; a stiff one will jam and produce a large force. The pot is heavy: under its weight a soft spring will sag noticeably, so you need high stiffness or weight compensation.
The network outputs target angles 50 times a second, the controller runs at 1 kHz. What happens if we remove the controller and feed torques straight from the network?
20 ms pass between network calls, and all that time the torque does not change: the arm cannot damp the pushes in time and starts swinging. The network would have to run much more often and learn to stabilize the joints itself. This is rarely done: for example, in the 2022 paper by Chen et al. the policy for the A1 robot output torques directly at 200 Hz.
Paper guide
N. Hogan, "Impedance Control: An Approach to Manipulation: Part I — Theory", ASME JDSMC, 1985.
- Read closelyWhy controlling only position or only force is not enough, and what it means that "the manipulator should behave as an impedance".
- Can skipThe detailed derivations and proofs.
- Question along the wayThe environment accepts force and responds with motion. Why does it follow that the robot should respond to motion with force?
Resources
- Modern Robotics: Mechanics, Planning, and ControlK. Lynch, F. Park, 2017 — free book and videos; kinematics in chapters 4–6, control in chapter 11
- Robotic ManipulationR. Tedrake's MIT course — chapters 3 and 8
- legged_gymCode by Rudin et al.: the walking policy outputs target angles, a PD computes the torques
What's next: where the robot is and where to go. In every lab of this lesson the controller knew the exact position of the arm, and the planner knew the exact map of the walls. A real robot's sensors are noisy, and there is no map of an unfamiliar home. Before driving the robot to a target, you need to estimate where it is and find a path. That is lesson 0.4, "State estimation and planning".