Where you are. You can compute where the hand ends up from a set of joint angles, and you know which points the arm can reach at all. This lesson answers the question sitting between those two: turn one joint a little, and which way and how far does the hand actually go?
Two knobs and a circle
Somebody hands you an Etch A Sketch and asks for a circle.
You know how this goes. The left knob drags the stylus horizontally, the right knob drags it vertically. A horizontal line is one knob. A diagonal at forty-five degrees is both knobs turning at the same rate. A circle is both knobs turning at rates that vary smoothly and are never equal, which is why hardly anyone can draw one.
Hard as it is, it is learnable, because the map from knob to motion never changes. Left is always horizontal, right is always vertical, and wherever the stylus happens to be, the same turn of the same knob does the same thing.
Now bolt the stylus to the end of a two-link arm and replace the knobs with the two joints.
Turning the shoulder does not drag the pen sideways. It swings the pen along an arc centred on the base. Turning the elbow swings it along a different arc, centred on the elbow. Neither arc is horizontal or vertical. Neither direction stays put: move the arm a hand’s width and both have rotated. And the two arcs are not at right angles to each other, so the knobs interfere with each other in a way that changes as you draw.
Before you can steer that, you need one small table. At this instant, in this pose: if I turn this joint, which way does the hand go, and how fast? That table is the subject of this lesson, and most of the rest of the module is built out of it.
The idea in one paragraph
The Jacobian is that table, written as a matrix with one column per joint. Column j says: if joint j alone turns at one radian per second while every other joint holds still, this is the hand’s velocity - a direction and a speed. That is the whole concept. For the two-link arm, two joints and a hand position in the plane make it a two-by-two block of numbers, and it has to be recomputed at every pose, because the answer moves as the arm moves. Formally it is the matrix of partial derivatives of forward kinematics, which makes it the arm’s local linear model: . Practically it is a sensitivity table, and once you have it you can predict hand motion from joint motion, run the relation backwards to get inverse kinematics, and turn a desired fingertip force into motor torques, all out of the same matrix.
Build one column with no calculus at all
Take the arm this module keeps returning to: , , shoulder at , elbow at . Forward kinematics puts the hand at .
Freeze the elbow and turn the shoulder. With the elbow locked the whole arm is one rigid stick pivoting about the base, so the hand travels on a circle centred on the base. Two facts about circular motion finish the job, and you already own both: the velocity points perpendicular to the line from the centre to the moving point, and its size is radius times angular rate.
The radius here is the distance from base to hand, which is 1.4799. So one radian per second at the shoulder moves the hand at 1.4799 units per second, at right angles to the base-to-hand line. In friendlier units, one degree of shoulder moves the hand 25.83 mm.
That vector is column one. No derivatives were involved; it was a circle.
Column two is the same argument one link further down. Freeze the shoulder, turn the elbow, and the hand travels on a circle centred on the elbow, of radius . One degree of elbow moves the hand 12.22 mm, perpendicular to link two.
Wider than the screen; scroll it sideways.
Stack the two columns and you have at this pose:
Both ways of reading it are true and they answer different questions. Down a column is one joint’s contribution, and that is the reading roboticists reach for. Across a row is how every joint contributes to one coordinate of the hand. The second row here says the elbow contributes exactly nothing to the hand’s vertical speed at this pose, which you can see in the figure, because column two is horizontal.
Two structural facts fall out of the circle argument, and they hold at every pose. They were checked over 10,000 random configurations, and both held to within 1.1e-16, which is machine noise.
- The length of column one is exactly the distance from the base to the hand, and the column is exactly perpendicular to that line.
- The length of column two is exactly , and the column is exactly perpendicular to link two.
So the shoulder’s authority over the hand grows the further out the hand reaches, and the elbow’s authority never changes at all. That asymmetry is not special to this arm: on any chain of revolute joints, a column’s length is the perpendicular distance from that joint’s axis to the hand, which is why the joints near the base tend to be the coarse knobs and the ones near the gripper the fine ones.
The same matrix, from the derivative
The circle argument is the intuition. The derivative is the mechanism, and it gives you a formula you can code.
Forward kinematics for this arm:
Differentiate each coordinate with respect to each joint and collect the four answers:
In words: every entry says how much one hand coordinate changes per radian of one joint. Substituting 30° and 60° reproduces the matrix above, which it must, because the two derivations are the same statement said twice.
Two joints at once: just add
Written out, says . Moving both joints produces the sum of what each produces alone. That linearity is what makes a matrix rather than a lookup table, and it is the property that the next several lessons live on.
At the pose above, turning both joints one degree moves the hand 36.35 mm, and the sum-of-columns prediction misses by 0.52 mm.
Which brings us to the catch.
It is a snapshot, and it expires
describes the arm at an instant. Step any finite distance and the arm rotates underneath you, the columns swing round, and the prediction drifts away from the truth.
Wider than the screen; scroll it sideways.
Turning the shoulder from the pose above, and comparing the straight-line prediction against real forward kinematics:
| shoulder turns by | hand actually moves | prediction is off by | share of the move |
|---|---|---|---|
| 1° | 25.83 mm | 0.23 mm | 0.9% |
| 5° | 129.10 mm | 5.63 mm | 4.4% |
| 10° | 257.96 mm | 22.52 mm | 8.7% |
| 30° | 766.03 mm | 201.32 mm | 26.3% |
Checking it without trusting your calculus
You should never ship a hand-derived Jacobian without a second opinion, and the second opinion is almost free. Nudge each joint by a tiny amount, run forward kinematics, and divide by the nudge:
def jacobian_numeric(t1, t2, eps=1e-6):
base = fk(t1, t2)
return np.column_stack([(fk(t1 + eps, t2) - base) / eps,
(fk(t1, t2 + eps) - base) / eps])
That is the definition of a partial derivative with the limit left un-taken. Over 10,000 random configurations, this and the analytic formula agreed to a largest absolute difference of 8.5e-7.
Stare at that number for a second, because it is not machine precision and it should not be. A one-sided difference carries an error roughly proportional to eps itself, so with eps = 1e-6 you should expect an error near 1e-6, and that is exactly what turned up. The agreement is not “as good as floating point”; it is “as good as the method allows”, which is the stronger result, because it means both sides are right.
The transpose does forces
One more thing falls out of the same matrix, and it is the reason the Jacobian outlives this module.
Turn on its side and it maps in the opposite direction, and between different quantities: a force you want at the hand becomes the joint torques that produce it.
In plain words: to push the hand in some direction with some force, each motor must supply this much twist. It is the same sensitivity table read backwards. A joint that barely moves the hand in a direction also barely helps push in it, so it contributes little torque; a joint with lots of leverage over that direction carries most of the load.
Wider than the screen; scroll it sideways.
Press straight down with 5 N and watch the bill change as the arm extends. Shoulder held at 0°, elbow varied:
| elbow angle | shoulder torque | elbow torque |
|---|---|---|
| 90° | 5.00 N·m | 0.00 N·m |
| 60° | 6.75 N·m | 1.75 N·m |
| 30° | 8.03 N·m | 3.03 N·m |
| 2° | 8.50 N·m | 3.50 N·m |
Same force, same arm, and the shoulder’s load rises 70% purely because the arm straightened out and the hand moved further from the base. The elbow’s torque goes from nothing at all - at 90° the force points straight along link two, so it has no leverage about the elbow at all - to 3.5 N·m. This is why motor sizing is done over the whole workspace rather than at one convenient pose, and it is the seed of the force budget you work out on your own hardware in Module 4.
Review
A sensitivity table, one column per joint
The Jacobian is a table written as a matrix with one column per joint. Column j says: if joint j alone turns at one radian per second while every other joint holds still, this is the hand’s velocity, a direction and a speed. That is the whole concept. You can build a column with no calculus at all. Freeze the elbow and turn the shoulder, and the whole arm is one rigid stick pivoting about the base, so the hand travels on a circle. Two facts about circular motion finish it: the velocity points perpendicular to the line from the centre to the moving point, and its size is radius times angular rate. Formally it is the matrix of partial derivatives of forward kinematics, which makes it the arm’s local linear model. It has to be recomputed at every pose, because the answer moves as the arm moves.
It is a snapshot, and it expires
The Jacobian is a straight-line prediction of a curved motion, so it is honest only near the pose where you built it. Turning the shoulder from one worked pose, one degree moves the hand about twenty-six millimetres and the prediction is off by two tenths of a millimetre, under one percent. Five degrees is off by four percent, ten degrees by nearly nine, and thirty degrees by twenty-six percent, which is twenty centimetres of error. How many degrees you can trust it for is not a property of the Jacobian. It is a property of how much error your task tolerates: two tenths of a millimetre is nothing for most tasks, and twenty centimetres is the difference between picking the cup up and knocking it over.
The transpose does forces
Turn the matrix on its side and it maps in the opposite direction, between different quantities: a force you want at the hand becomes the joint torques that produce it. In plain words, to push the hand in some direction with some force, each motor must supply this much twist. It is the same sensitivity table read backwards. A joint that barely moves the hand in a direction also barely helps push in it, so it contributes little torque, and a joint with lots of leverage over that direction carries most of the load. That is why the Jacobian outlives this module: one matrix predicts hand motion from joint motion, runs backwards for inverse kinematics, and converts a desired fingertip force into motor torques.
Check yourself
1. What does a column of J mean physically, and what does a row mean?
Column j is the hand’s velocity when joint j alone turns at one radian per second: a direction and a speed, at this pose only. Row i is how every joint contributes to hand coordinate i. The column reading is the one to keep in your head, because a column corresponds to a thing you can physically do - turn one motor - while a row corresponds to a coordinate you chose.
2. Why is column one longer than column two at almost every pose, and when are they equal?
Column one’s length is the distance from the base to the hand; column two’s is , always. So column one is longer whenever the hand is further from the base than , which is about 86% of the reachable ring by area. They are equal only where the hand sits exactly from the base, which for needs the elbow folded back to roughly 136° so the hand lands on the circle of radius 0.7. The practical reading: the shoulder is a coarse knob whose authority grows with reach, the elbow is a fine knob whose authority is fixed.
3. Your analytic and finite-difference Jacobians agree to 8.5e-7 with eps = 1e-6. Is that a pass or a fail?
A pass, and a more informative one than machine precision would have been. A one-sided finite difference has truncation error proportional to eps, so agreement at roughly eps is exactly what a correct pair of implementations produces. Agreement at 1e-15 would actually be suspicious: it would suggest the “numeric” version is not independent, for instance because it calls the analytic one somewhere. Disagreement at 1e-3 would say one of them is wrong. Test the size of the error against the method, not against zero.
4. You take a single 30-degree joint step using J and land 20 cm from where J said you would. What is broken?
Nothing is broken. is the derivative at one pose, so it is exact only in the limit of a vanishing step. Over 30 degrees the arm swings far enough that the columns themselves have rotated substantially, and the straight-line prediction departs from the true arc by 26% of the distance travelled. The fix is not a better Jacobian, it is a smaller step followed by a recomputation. This is the same reason a single large gradient step overshoots in optimization.
5. Pressing down with a fixed 5 N, why does the shoulder torque change as the elbow angle changes?
Because and depends on the pose. Straightening the elbow moves the hand further from the base, which lengthens column one, which increases the shoulder’s share of the load: 5.00 N·m with the elbow at 90°, 8.50 N·m with it at 2°. Physically it is leverage - the same force applied at the end of a longer moment arm. Practically it means the worst-case torque is a property of the workspace, not of a pose, so motors get sized against the whole reachable set.
6. The elbow torque is exactly zero when the elbow sits at 90° and the force points straight down. Why?
At that pose link two points straight up, so a downward force at the hand points straight along link two, directly at the elbow joint. A force whose line of action passes through a pivot exerts no moment about it. In the matrix, the same fact appears as , which zeroes the entry of that the vertical force multiplies. Geometry and arithmetic agreeing is the check you want.
Do this
Open code/ik_2link.py. Two functions in it are the whole of this lesson.
1. Fill in jacobian_analytic(t1, t2) from the four-entry formula above. Four lines.
2. Fill in jacobian_numeric(t1, t2, eps=1e-6) by finite differences, without looking at the analytic version while you write it. Independence is what makes the check worth anything.
3. Run python ik_2link.py. The check_jacobians function compares the two over 1000 random configurations. It should pass. Then change the assertion tolerance from atol=1e-4 down to atol=1e-9 and watch it fail - and make sure you can say why it fails without changing your mind about whether your code is correct.
4. Sweep eps through 1e-2, 1e-4, 1e-6, 1e-8, 1e-10, 1e-12 at a single pose and print the largest error at each. You are looking for the U-shape in the table above: truncation error falling, rounding error rising, a minimum near 1e-8.
5. Print the two columns’ lengths at a few random poses alongside np.linalg.norm(fk(t1, t2)) and . They should match exactly, every time. When they do, you have verified the circle argument that opened this lesson without taking a single derivative.
Solution: solutions/ik_2link.py.
What you can now do
You can build a 2-link arm’s Jacobian two independent ways - from circular motion, and from the derivative of forward kinematics - and say what each column and each row means physically. You can check it against finite differences and judge the result against the method’s own error rather than against zero. You can say how far a single Jacobian step can be trusted before it needs recomputing, and you can use to turn a desired fingertip force into the torque each motor has to supply.