From where to how fast, and how hard
Inverse kinematics told us how to put a tool somewhere. Most tasks also say how it should move and how hard it should push. A robot spraying lacquer on a guitar body in Guangzhou must keep the nozzle moving at a steady m/s along the curve, or the coat will be uneven. A rehabilitation robot in Lyon guides a patient's hand along a straight line at walking-pace speeds. A polishing arm in Pune must press a pad onto a turbine blade with N, no more and no less.
All three need two conversions that position-level kinematics does not give: from a desired tool velocity to the joint velocities that produce it, and from a desired tool force to the joint torques that produce it. A single matrix does both, the Jacobian . It also diagnoses the arm: where loses rank the robot has a singularity, a configuration in which some direction of tool motion is impossible, nearby motions in that direction demand huge joint speeds, and the arm can resist forces in that direction with no motor torque at all.
This lesson derives the Jacobian for planar and spatial arms, computes singularities and the manipulability ellipse, proves the statics relation , and simulates resolved-rate control, the oldest way of driving a tool along a line, including what goes wrong near a singularity and how damped least squares fixes it.
Each joint contributes a velocity
Hold an arm still and turn just one joint at rad/s. Everything beyond that joint rotates rigidly about the joint's axis, so the tool tip moves on a circle around the axis: its velocity is perpendicular to the line from the joint to the tip, with magnitude equal to the tip's distance from the axis. Turn a different joint and you get a different velocity. Turn several joints at once and, for small motions, the effects simply add. So the tool velocity is a weighted sum of one vector per joint, weighted by the joint speeds:
The vectors are the columns of the Jacobian. Each depends on the configuration , because the geometry changes as the arm moves.
Now the key question for control. To move the hand with a chosen velocity , we need with : a linear system, unlike the nonlinear equations of inverse kinematics. That is the great simplification of working with velocities. The catch is visible in the figure: if the arm were straight, both columns would be perpendicular to the same line, so both would point the same way, and no combination of joint speeds could move the hand along the arm. That is a singularity.
Definitions
Definition— Jacobian (analytic)
For forward kinematics with and (a position, or a position and some orientation coordinates), the analytic Jacobian is the matrix of partial derivatives , so that .
Definition— twist and geometric Jacobian
The velocity of a rigid body (the tool) is a twist : the linear velocity of a chosen reference point on the body and the body's angular velocity , both expressed in a chosen frame. The geometric Jacobian is the matrix with . If joint has unit axis through the point and the reference point is , its column is
Definition— singular configuration
A configuration is singular if has rank less than its largest possible rank, , for that arm. At a singular configuration there is a direction of tool motion that no joint velocity produces. For a square Jacobian, is singular exactly when .
Definition— manipulability
The manipulability ellipsoid at is the set of tool velocities . If is the singular value decomposition, its principal axes are the columns of , with semi-axis lengths equal to the singular values . Yoshikawa's manipulability measure is , proportional to the ellipsoid's volume; for a square it equals .
The analytic and geometric Jacobians agree in their linear-velocity rows. They differ in the angular rows: the analytic one differentiates whatever orientation coordinates you chose (roll–pitch–yaw angles, say), while the geometric one gives , which is not the derivative of any three angles. As the rotations lesson showed, angle rates and are related by a configuration-dependent matrix, which itself becomes singular at gimbal lock. Robotics software almost always means the geometric Jacobian.
The planar arm: Jacobian, singularities and ellipses
Differentiate the two-link arm's forward kinematics, writing , and so on:
The second column is the elbow's contribution: the second link, of length , rotated by . The first column is the whole arm's tip, rotated by . Both match the figure.
Theorem— Singularities of the planar 2R arm
. So the arm is singular exactly when (stretched) or (folded), whatever is, and at a singularity the hand cannot move along the line through the shoulder and the hand.
Proof
Expand the determinant: With it vanishes exactly when . Then the second link is parallel to the first, the tip lies on the line through the shoulder along the arm, and each column (the vector from its joint to the tip, rotated by ) is perpendicular to that line. So the column space, every achievable hand velocity, is the perpendicular direction only; the radial direction is missing.
∎
This explains the workspace of the previous lesson: singular configurations put the hand exactly on the boundaries and , which the hand cannot cross. It also shows that is irrelevant: the shoulder angle merely rotates the whole picture. The code computes the Jacobian, checks it against finite differences, and watches the arm become singular as the elbow straightens.
import numpy as np
L1, L2 = 0.5, 0.4
def fk(q):
return np.array([L1 * np.cos(q[0]) + L2 * np.cos(q[0] + q[1]),
L1 * np.sin(q[0]) + L2 * np.sin(q[0] + q[1])])
def jacobian(q):
s1, c1 = np.sin(q[0]), np.cos(q[0])
s12, c12 = np.sin(q[0] + q[1]), np.cos(q[0] + q[1])
return np.array([[-L1 * s1 - L2 * s12, -L2 * s12],
[ L1 * c1 + L2 * c12, L2 * c12]])
# 1. The analytic Jacobian agrees with finite differences.
q = np.radians([30.0, 60.0])
h = 1e-6
J_fd = np.column_stack([(fk(q + h * e) - fk(q - h * e)) / (2 * h) for e in np.eye(2)])
print("J(30 deg, 60 deg) =", np.round(jacobian(q), 4).tolist(),
f" max difference from finite differences: {np.abs(jacobian(q) - J_fd).max():.1e}")
# 2. How singular is the arm as the elbow straightens? (For a square J, w = |det J|.)
print("\n q2 (deg) det J sigma_max sigma_min condition number")
for q2 in [90, 60, 30, 10, 2, 0]:
J = jacobian(np.radians([30.0, q2]))
s = np.linalg.svd(J, compute_uv=False)
cond = s[0] / s[1] if s[1] > 1e-12 else float("inf")
print(f"{q2:9d} {np.linalg.det(J):8.4f} {s[0]:11.4f} {s[1]:11.4f} {cond:14.1f}")
# 3. Statics: joint torques that make the hand press down on a table with 20 N.
q = np.radians([-30.0, 75.0])
F = np.array([0.0, -20.0]) # force the hand applies to the table (N)
tau = jacobian(q).T @ F
print("\nhand at", np.round(fk(q), 3), "m, pressing with F =", F, "N")
print("joint torques tau = J^T F =", np.round(tau, 3), "N m")The determinant column is , as the theorem says. The condition number is the more useful warning light: it measures how lopsided the arm's abilities are, and it climbs from at a right-angled elbow to at .
The singular values have a picture. A unit ball of joint velocities maps to an ellipse of hand velocities, the manipulability ellipse, with semi-axes and . As the elbow straightens, the ellipse flattens into a line segment perpendicular to the arm.
Manipulability is a design tool as well as a warning. For this arm is largest at , and for a fixed total length its largest possible value, , comes with equal links; Yoshikawa remarked that human upper arms and forearms are roughly equal too. Designers map (or the condition number) over the workspace to place a robot so that its usual tasks sit in well-conditioned regions.
A spatial arm and its three classic singularities
For a six-axis arm, the geometric Jacobian is built column by column from the frames that forward kinematics already computes: for revolute joint , take its axis and a point on it from , and form . The code below describes a six-axis arm with a spherical wrist by a standard Denavit–Hartenberg table, as in forward kinematics: each joint turns about its own axis, followed by a fixed offset to the next joint. It is a simplified cousin of that lesson's Lumen-6, without the small shoulder and elbow offsets, so that its singularities sit at angles that are easy to state. The code builds column by column, checks it against finite differences of the pose, and finds the singularities.
import numpy as np
def rot_z(t):
c, s = np.cos(t), np.sin(t)
T = np.eye(4)
T[:2, :2] = [[c, -s], [s, c]]
return T
def fixed(d, a, alpha):
"""The fixed offset after a joint (one standard DH row): up d along z, out a along x, twist alpha about x."""
c, s = np.cos(alpha), np.sin(alpha)
return np.array([[1, 0, 0, a], [0, c, -s, 0], [0, s, c, d], [0, 0, 0, 1.0]])
# A six-axis arm with a spherical wrist: shoulder 0.40 m up, upper arm 0.45 m, forearm 0.40 m, flange 0.08 m.
OFFSETS = [fixed(0.40, 0, np.pi / 2), fixed(0, 0.45, 0), fixed(0, 0, np.pi / 2),
fixed(0.40, 0, -np.pi / 2), fixed(0, 0, np.pi / 2), fixed(0.08, 0, 0)]
def frames(q):
"""Poses 0T0 ... 0T6; joint i+1 turns about the z axis of frame i."""
T, out = np.eye(4), [np.eye(4)]
for qi, F in zip(q, OFFSETS):
T = T @ rot_z(qi) @ F
out.append(T)
return out
def geometric_jacobian(q):
Ts = frames(q)
p_e = Ts[-1][:3, 3]
cols = []
for i in range(6): # every joint is revolute
z, p = Ts[i][:3, 2], Ts[i][:3, 3]
cols.append(np.concatenate([np.cross(z, p_e - p), z]))
return np.column_stack(cols) # rows: v_x, v_y, v_z, w_x, w_y, w_z
def numeric_twist_jacobian(q, h=1e-6):
"""Finite differences: linear velocity from d(p)/dq, angular from dR R^T."""
J = np.zeros((6, 6))
for j in range(6):
dq = np.zeros(6)
dq[j] = h
Tp, Tm = frames(q + dq)[-1], frames(q - dq)[-1]
J[:3, j] = (Tp[:3, 3] - Tm[:3, 3]) / (2 * h)
W = (Tp[:3, :3] - Tm[:3, :3]) / (2 * h) @ frames(q)[-1][:3, :3].T # skew-symmetric
J[3:, j] = [W[2, 1], W[0, 2], W[1, 0]]
return J
q = np.radians([20.0, 50.0, -30.0, 40.0, 60.0, 10.0])
print("geometric vs numerical Jacobian, max difference:",
f"{np.abs(geometric_jacobian(q) - numeric_twist_jacobian(q)).max():.1e}")
shoulder_q3 = np.pi / 6 + np.arccos(-0.45 * np.cos(np.pi / 3) / 0.40) # puts the wrist centre on axis 1
for name, qq in [("ordinary pose", q),
("wrist: q5 = 0", np.radians([20, 50, -30, 40, 0, 10])),
("elbow: arm stretched", np.radians([20, 50, 90, 40, 60, 10])),
("shoulder: wrist over axis 1", np.array([0.35, np.pi / 3, shoulder_q3, 0.7, 1.0, 0.2]))]:
J = geometric_jacobian(qq)
U, s, Vt = np.linalg.svd(J)
print(f"{name:28} rank {np.linalg.matrix_rank(J, tol=1e-9)} singular values {np.round(s, 3)}")
if s[-1] < 1e-9:
print(f"{'':28} joint motion that moves nothing: {np.round(Vt[-1] * np.sign(Vt[-1][np.argmax(abs(Vt[-1]))]), 3) + 0.0}")The two Jacobians agree to about . Then each of the three classic singularities of a six-axis arm drops the rank to 5, and the last row of names the joint motion that moves nothing:
- Wrist singularity (): the axes of joints 4 and 6 line up, so turning them equally in opposite directions, , leaves the tool still. It occurs anywhere in the workspace, which makes it the one programmers meet most often, typically when a straight-line move points the tool along the forearm.
- Elbow singularity: the arm is fully stretched, the spatial version of in the planar arm, at the boundary of the workspace.
- Shoulder singularity: the wrist centre lies on the axis of joint 1. Turning the base then only spins the wrist centre in place, and a combination of base and wrist motion leaves the tool still.
Statics: τ = Jᵀ F
The Jacobian also converts forces. Suppose the tool presses on the world with a force (or, in 3-D, a wrench: a force and a moment), and the arm is at rest. What joint torques hold it there?
Theorem— Statics of a serial arm
If an arm in static equilibrium exerts the wrench on its environment, ignoring gravity and friction in the arm, the joint torques (forces, for prismatic joints) are , where is the Jacobian whose twist uses the same reference point and frame as .
Proof
Use conservation of power. Imagine any small joint velocity about the equilibrium. The power the motors put in is . The power the tool delivers to the environment is . In static equilibrium with no losses and no change in kinetic energy, the two must be equal for every : . A linear function that vanishes for every has zero coefficients, so , that is .
∎
This is the principle of virtual work, the same tool that gives Lagrange's equations in classical mechanics. In the code above, the hand at m presses down on a table with N, and N·m. The physics is checkable by hand: a vertical force produces a torque equal to the force times the horizontal distance to the joint. The hand is m to the right of the shoulder and m to the right of the elbow, and , . The minus signs say that the motors push clockwise, downwards.
The theorem has three consequences that engineers use daily.
- Singular directions carry load for free. If , a force along needs no torque at all: the structure takes it. A stretched arm resists a push along its length with its bones, not its muscles; you lock your knees when you stand still for the same reason. The force ellipsoid has the same axes as the velocity ellipsoid but semi-axes : where the arm is fast, it is weak, and where it is slow, it is strong, like a gearbox.
- Torque sensing becomes force sensing. Inverting the relation, estimates the contact force from measured joint torques. Collaborative arms with torque sensors in every joint, and others that estimate torque from motor currents, use this to detect a collision with a person and stop.
- Redundant arms have internal torques. If , torques in the null space of produce no tool force: the arm can stiffen or relax its posture without changing what it pushes on.
Gravity on the arm itself adds its own torques, , which the next lesson computes; a payload of mass held at the tool needs the extra torque , where is the linear-velocity part of , the world frame has up and m/s²: the arm pushes up on the payload with a force equal to its weight.
Resolved-rate control, and what singularities do to it
In 1969 Daniel Whitney proposed controlling an arm directly in task space by solving the velocity equation at every control tick: given the desired tool velocity , command , and add a little feedback on the position error to stop drift,
This resolved-rate control is still how many robots are jogged with a joystick or teach pendant in "Cartesian mode", and how teleoperated and visual-servoing systems turn a desired motion into joint commands. It is also numerical IK from the previous lesson run in real time: each tick is one Newton step towards a moving target.
Near a singularity the inverse explodes. To see it, simulate an operator who pushes the hand outwards along a ray at m/s, from m to m from the shoulder, and back again, although the arm reaches only m. Compare the plain inverse with damped least squares, , for several .
import numpy as np
L1, L2 = 0.5, 0.4
def fk(q):
return np.array([L1 * np.cos(q[0]) + L2 * np.cos(q[0] + q[1]),
L1 * np.sin(q[0]) + L2 * np.sin(q[0] + q[1])])
def jacobian(q):
s1, c1, s12, c12 = np.sin(q[0]), np.cos(q[0]), np.sin(q[0] + q[1]), np.cos(q[0] + q[1])
return np.array([[-L1 * s1 - L2 * s12, -L2 * s12], [L1 * c1 + L2 * c12, L2 * c12]])
# An operator pushes the hand outwards along a ray at 30 degrees at 0.1 m/s for 5 s, then back:
# 0.45 m -> 0.95 m -> 0.45 m from the shoulder. The arm reaches only 0.9 m.
u = np.array([np.cos(np.pi / 6), np.sin(np.pi / 6)])
def desired(t):
if t <= 5.0:
return (0.45 + 0.1 * t) * u, 0.1 * u
return (0.95 - 0.1 * (t - 5.0)) * u, -0.1 * u
def run(lam, dt=0.002, T=10.0, k=5.0):
x0, _ = desired(0.0)
q2 = np.arccos((x0 @ x0 - L1**2 - L2**2) / (2 * L1 * L2)) # elbow-down start
q = np.array([np.arctan2(x0[1], x0[0]) - np.arctan2(L2 * np.sin(q2), L1 + L2 * np.cos(q2)), q2])
peak_speed = worst_error = 0.0
flipped = False
for n in range(int(round(T / dt)) + 1):
xd, vd = desired(n * dt)
command = vd + k * (xd - fk(q)) # feed-forward velocity plus a little feedback
J = jacobian(q)
if lam == 0.0:
qdot = np.linalg.solve(J, command) # plain resolved rate: J^-1
else:
qdot = J.T @ np.linalg.solve(J @ J.T + lam**2 * np.eye(2), command)
reachable = xd * min(1.0, (L1 + L2) / np.linalg.norm(xd)) # closest point the arm can reach
peak_speed = max(peak_speed, np.abs(qdot).max())
worst_error = max(worst_error, np.linalg.norm(reachable - fk(q)))
flipped = flipped or q[1] < 0 # crossed to the elbow-up branch?
q = q + dt * qdot
return peak_speed, worst_error, flipped
print("method peak joint speed worst error elbow flipped")
for lam in (0.0, 0.05, 0.1, 0.2):
name = "plain J^-1" if lam == 0 else f"DLS lambda = {lam}"
peak, err, flip = run(lam)
print(f"{name:18} {peak:12.2f} rad/s {err:11.3f} m {'yes' if flip else 'no'}")The plain inverse commands a peak joint speed of about rad/s, some seventy revolutions per second, as the arm approaches full stretch; it overshoots straight through the singularity and comes out on the other elbow branch. On a real robot the drives would saturate or trip, and if they did not, an arm whipping its elbow over at full speed is exactly the kind of motion that safety systems exist to stop. Damped least squares keeps the peak to , and rad/s for , and , never flips the elbow, and pays with a tracking error of to cm while the operator asks for the impossible: the hand lags inside the reachable region instead of chasing an unreachable point.
The table also shows that is a genuine trade-off. Small damping lets the arm get very close to full stretch, from where it recovers slowly, because exactly at the singularity the radial direction has zero gain; large damping keeps the arm well away from it but tracks less accurately everywhere near the boundary. Practical controllers therefore use variable damping, with zero when the smallest singular value is comfortably large and rising smoothly as it falls below a threshold, and they clip joint speeds to the drives' limits whatever the formula says.
Jacobians in professional software
Every robotics library computes Jacobians, and the first thing to learn about each is its conventions, because a twist means nothing until you say which point's velocity and which frame it is expressed in.
- Pinocchio computes all joint Jacobians in one pass and offers each frame's Jacobian in three conventions:
LOCAL(velocity of the frame's origin, expressed in the frame itself, the body Jacobian),WORLD(the spatial Jacobian, whose linear part is the velocity of the point of the body that is passing through the world origin), andLOCAL_WORLD_ALIGNED(velocity of the frame's origin, expressed along world axes), which matches the geometric Jacobian of this lesson. - Drake's
MultibodyPlant.CalcJacobianSpatialVelocitytakes the frame of the moving body, the point on it, the frame to measure relative to, and the frame to express the result in, all as explicit arguments. - MuJoCo provides
mj_jac,mj_jacBodyandmj_jacSite, returning separate translational and rotational blocks in world coordinates. - KDL has
ChainJntToJacSolverfor serial chains.
With Pinocchio, the manipulability of a tool frame takes a few lines. It is shown, not run here, since it needs Pinocchio and a robot model:
import numpy as np
import pinocchio as pin
model = pin.buildModelFromUrdf("my_arm.urdf")
data = model.createData()
tool = model.getFrameId("tool0")
q = pin.neutral(model)
pin.computeJointJacobians(model, data, q) # every joint Jacobian, in one pass
pin.updateFramePlacements(model, data)
J = pin.getFrameJacobian(model, data, tool, pin.LOCAL_WORLD_ALIGNED) # 6 x nv
sigma = np.linalg.svd(J[:3], compute_uv=False) # translational part only: one unit
print("manipulability", np.prod(sigma), "condition", sigma[0] / sigma[-1])Beyond hand-written formulas, libraries also differentiate kinematics automatically: Pinocchio can be used with CasADi, Drake has its own automatic-differentiation scalar type, and MuJoCo's JAX version (MJX) differentiates through the whole simulator. This matters for optimisation-based planning and for learning, which need derivatives of many quantities, not just of the tool position.
In industry, Jacobians run inside every robot controller: for Cartesian jogging, for linear and circular moves, for force control, and for safety. Controllers monitor tool and elbow speeds as well as joint speeds, because near singularities modest tool speeds hide large joint speeds; safety standards for industrial robots, such as ISO 10218, specify safety-rated speed monitoring for robots that work alongside people. In research, manipulability and its relatives guide the placement of robots in work cells, the design of new arms, the choice of postures for redundant arms and humanoids, and the "dexterity" terms in grasp and motion optimisation.
Common misconceptions
Misconception
"At a singularity the robot cannot move." It loses one or more directions of tool motion, not all of them. The stretched planar arm can still move its hand sideways; the wrist-singular six-axis arm can still move its tool in five independent ways. The danger is in trying to move in, or near, the lost direction.
Misconception
"A small determinant means the arm is nearly singular." The determinant depends on units and on the arm's size: the same arm measured in millimetres has a determinant a million times larger. Use the smallest singular value relative to the largest (the inverse condition number), with consistent units, to judge closeness to a singularity.
Misconception
"The Jacobian is a property of the robot." It is a property of the robot in a configuration, for a chosen reference point, expressed in a chosen frame. Two libraries can return different matrices for the same arm and both be right. Mixing conventions, such as a body-frame Jacobian with a world-frame target velocity, is one of the commonest bugs in robot code.
Misconception
"The Jacobian transpose is roughly its inverse." The update is gradient descent on , and it converges (slowly) without inverting anything, which is why it is popular in animation. But is not : it scales directions by instead of . The real relation between them is duality: maps velocities forwards, and maps forces backwards.
Exercises
1. Jacobians, velocity and singularities
Warm-upHumanA planar two-link arm has cm and cm. At the configuration , , what is , in cm² (with lengths in centimetres and angles in radians)?
2. Jacobians, velocity and singularities
Warm-upHumanFor a planar two-link arm with m and m, which configurations are singular? Select all that apply.
3. Jacobians, velocity and singularities
CoreHumanThe arm ( m, m) is stretched out horizontally, , and its hand presses straight down on a scale with a force of N, so N. Ignoring the arm's own weight, what is the magnitude of the shoulder torque, in N·m?
4. Jacobians, velocity and singularities
CoreComputationalWrite planar_jacobian(lengths, q) returning the Jacobian of the tip position of a planar arm with revolute joints. lengths[i] is the length of link i, and q[i] is the angle of joint i relative to the previous link, so link i points at the absolute angle .
The tests compare your matrix with finite differences for arms of 1 to 5 links.
5. Jacobians, velocity and singularities
CoreComputationalThe starter computes joint velocities by the plain inverse, which fails at singular configurations and does not work at all for non-square Jacobians. Rewrite dls_velocity(J, xdot, lam) to return the damped least-squares joint velocity
which minimises . It must reduce to the inverse when lam = 0 and is invertible, stay finite at singularities, and work for a redundant Jacobian.
6. Jacobians, velocity and singularities
CoreHumanA six-axis arm with a spherical wrist has , so the axes of joints 4 and 6 are collinear. Which statement is true?
7. Jacobians, velocity and singularities
Warm-upHumanFor the planar two-link arm, at which elbow angle between and is the manipulability largest? Give the angle in degrees.
Further reading and resources
- Modern Robotics: Mechanics, Planning, and Control · Kevin M. Lynch and Frank C. Park · 2017Chapter 5 covers velocity kinematics, space and body Jacobians, statics and manipulability with twists and wrenches.
- Resolved Motion Rate Control of Manipulators and Human Prostheses · Daniel E. Whitney · 1969The paper that introduced controlling an arm by inverting its Jacobian at every instant.
- Manipulability of Robotic Mechanisms · Tsuneo Yoshikawa · 1985Defines the manipulability measure and ellipsoid.
- Inverse Kinematic Solutions With Singularity Robustness for Robot Manipulator Control · Yoshihiko Nakamura and Hideo Hanafusa · 1986
- Introduction to Inverse Kinematics with Jacobian Transpose, Pseudoinverse and Damped Least Squares methods · Samuel R. Buss
- Pinocchio documentationJoint and frame Jacobians, and the LOCAL, WORLD and LOCAL_WORLD_ALIGNED conventions for expressing them.
- DrakeMultibodyPlant computes spatial-velocity Jacobians with every frame stated explicitly in the function arguments.
- MuJoCo documentation: computation
- Orocos Kinematics and Dynamics Library (KDL)