Skip to content
You Start with one site
Amounts in Start with one site
Mechanical Engineering & Design · Course

Velocity Kinematics and the Jacobian

Lesson 4 of 6 24 min read
Found this useful?

Ask a robot arm to move its hand in a slow, straight line while the arm is almost fully stretched, and a joint may have to spin faster than its motor can turn. The hand leaves the line, or the robot stops with a fault. Next to a person, the same poses can turn a small motor torque into a hard push. One matrix, the Jacobian, explains both. It converts joint speeds into the velocity of the hand and hand forces into joint torques, and it shows the poses where the arm loses a direction of motion. #robotics #jacobian #velocity-kinematics

Learning Objectives

By the end of this lesson, you will be able to:

  1. Derive the Jacobian matrix for serial robot manipulators
  2. Compute forward and inverse velocity mappings between joint space and task space
  3. Detect singularities and interpret their physical meaning
  4. Visualize manipulability ellipsoids using singular value decomposition
  5. Apply the pseudoinverse method for redundant manipulators
  6. Map end-effector forces to joint torques using the Jacobian transpose

Real-World Engineering Challenge: Collaborative Robot with Force-Limited Operation



A collaborative robot works beside people with no safety cage. On a production line, one must hand parts to a human worker. The technical specification ISO/TS 15066 gives the largest force a robot may put on each part of the human body. In this lesson we take one limit for the whole task: 150 N at the end-effector, the tool at the end of the arm.

The motors act at the joints, but the limit is at the hand. The controller must know, at every moment, how joint speeds and joint torques appear at the hand, and in which poses a small torque gives a large force.

System Challenge: Safe Velocity and Force Control

Critical Engineering Questions:

Why the Jacobian Is Essential for Collaborative Robots

A robot inside a cage can make a sudden move and hurt nobody. Beside a person, a sudden move or an unexpected force is a danger at once.

Collaborative Robot Design Challenge

Design Goal: Control the velocity and the force of a collaborative robot with the Jacobian. The robot is a planar 2R arm: two links in one plane, joined by two revolute (turning) joints.

Key Requirements:

  • Velocity Mapping: Find the velocity of the end-effector from the joint speeds
  • Trajectory Tracking: Find the joint speeds for a straight path of the end-effector
  • Singularity Monitoring: Detect the poses where the arm loses a direction of motion
  • Force Safety: Keep the force at the end-effector below 150 N

Fundamental Theory



What is the Jacobian?

Turn one joint of an arm a little, and the hand moves a little. How far, and in which direction, depends on the pose of the arm. The Jacobian is the table that holds these answers: one column for each joint, and in it the motion of the hand for one unit of motion of that joint.

Bicycle Gear Ratio

On a bicycle, the gear ratio tells you how fast the wheel turns for a given speed of the pedals. The Jacobian does the same work for a robot: it tells you how fast the hand moves for given speeds of the joints.

Where the Comparison Stops

A gear ratio is one fixed number. The Jacobian is a table of numbers, because there are several joints and the hand moves in several directions. And it is not fixed: every entry changes as the arm changes its pose. In some poses a whole direction of motion disappears.

Mathematical Definition

Write the joint angles (radians) as a list , and the position of the end-effector as a list of coordinates (metres). Forward kinematics is the rule . The symbol means “the change of the first coordinate for a small change of joint 2, with the other joints held still”. The Jacobian collects all such rates:

A dot over a symbol means its rate of change with time. So is the list of joint speeds, in rad/s, and is the velocity of the end-effector, in m/s. Each joint adds its own share to the motion of the hand, and the shares add:

In words: the velocity of the hand is the Jacobian times the joint speeds. The writing is a reminder that the entries of depend on the pose.

Body vs Spatial Jacobian: Two Ways to Express Velocity

For later work in 3D: the velocity of the tool can be written in the frame of the robot base (the spatial Jacobian) or of the tool (the body Jacobian). Mixing them causes sign errors. In the planar examples here the choice makes no difference.

Now build the Jacobian for a planar 2R arm with link lengths and (metres) and joint angles and .

Step 1: Forward Kinematics Equations

The position of the end-effector, from Forward and Inverse Kinematics, is:

Here is measured counterclockwise from the axis, and is the turn of link 2 away from the direction of link 1.

Step 2: Compute Partial Derivatives

The Jacobian needs four rates of change: each of and , for a small change of each of and . Use the rules that the derivative of is and the derivative of is .

Partial derivatives of :

Partial derivatives of :

Detailed differentiation walkthrough

Take . For a change of : the first term gives , and the second gives , because is inside . For a change of : the first term has no in it and gives zero, and the second gives . The equation follows the same way.

Step 3: Assemble the Jacobian Matrix

Combining all four partial derivatives into matrix form:

To write less, let , , and :

The velocity of the end-effector is then:

Column 1 is the velocity of the hand when joint 1 alone turns at 1 rad/s: the whole arm swings about the base. Column 2 is the velocity of the hand when joint 2 alone turns at 1 rad/s: only link 2 swings, about the elbow. The real velocity is column 1 times plus column 2 times .

Forward and Inverse Velocity Mapping

Problem: The joint speeds and are known. Find the velocity of the end-effector.

Method: Multiply.

This always has an answer, in every pose.

When to use: To find the real velocity of the end-effector from the joint speeds that the encoders (the angle sensors on the joints) measure. A collaborative robot uses it to check that the hand is not moving too fast near a person.

Numerical Example

Take a 2R arm with m and m, in the pose , . The joints turn at rad/s and rad/s.

  1. Compute trigonometric values:

    , so ,

    , so ,

  2. Build the Jacobian:

  3. Forward velocity mapping:

    The end-effector speed is m/s.

  4. Compute the determinant:

    The exact value follows from the closed form . The four-digit entries above give ; the difference is rounding only.

    Since , the robot is not at a singularity and the inverse velocity mapping is well-defined.

  5. Inverse velocity example: Suppose we want m/s, m/s (pure horizontal motion). Then:

Singularity Analysis

Stretch your own arm out fully and try to move your fingertip further away: you cannot, however hard your shoulder and elbow work. A singularity of a robot is the same thing: a pose in which the two columns of point along one line, so the joints can move the hand along that line only. The other direction is lost, at any joint speed.

Determinant of the Jacobian

The determinant measures how far the two columns are from lying on one line, and it is zero when they do. For the 2R arm:

Multiplying out, the terms with cancel and a sine identity leaves one short result (the steps follow below):

Only the elbow angle appears. Turning joint 1 turns the whole arm and does not change how close it is to a singularity.

Step-by-step determinant simplification

Starting from the expanded determinant:

The terms cancel:

Now apply the subtraction formula:

With and :

Therefore:

Singular Configurations

The singularity condition occurs when , which means or .

Configuration: The two links lie on one straight line and point the same way.

Physical meaning: The end-effector is at the largest reach, . Each joint can only swing it sideways, across the arm. It cannot move along the arm, toward the base or away from it.

Consequence for collaborative robots: Near this pose, even a slow motion of the hand along the arm needs very high joint speeds. The controller must slow the motion or change the path before the arm is straight.

Practical Singularity Thresholds

The value of depends on the link lengths, so a threshold for one robot does not fit a larger one. A measure with no units is the condition number : the speed of the hand in its easiest direction divided by its speed in the hardest direction (defined in the next part). A rule of thumb, to be tuned for each robot:

  • : the hand moves well in every direction
  • : one direction is clearly slower. Begin to add damping.
  • : near a singularity. Use damped least squares.
  • : singular in practice. Reduce speed or plan another path.

Manipulability Ellipsoids

One picture shows what the hand can do in a pose. Give the joints a fixed budget of speed: every pair of joint speeds with . Mark every hand velocity this budget can give. The marks fill an ellipse (in 3D, an ellipsoid), long in the directions where the hand moves easily and thin where it does not. It is called the manipulability ellipsoid.

The axes of the ellipse come from the singular value decomposition (SVD) of the Jacobian, which splits any matrix into a turn, a stretch along fixed axes, and another turn:

The matrix holds the stretch factors , called the singular values, largest first.

Key properties:

  • The half-lengths of the axes are the singular values, and their directions are the columns of
  • The manipulability index is for a square Jacobian. It is proportional to the area of the ellipse.
  • The condition number compares the long axis to the short one. is a circle: every direction is equally easy (isotropic).

In the numerical example, and . Their product is ✅, and . The hand moves nine times more easily in its best direction than in its worst.

Interpreting the Manipulability Ellipsoid

Large and round: the hand moves equally well in all directions. This is the best pose for work beside a person.

Long and thin: arrange the task so that its motion lies along the long axis.

Flat: the arm is near a singularity. Avoid this pose.

Pseudoinverse for Redundant Robots

Put a fingertip on the table and keep it there. You can still move your elbow. Your arm has more joints than the task needs, and a robot of that kind is called redundant. The simplest example is a planar arm with three joints (3R) that controls only the position . It has many possible sets of joint speeds for one hand velocity, and is not square, so it has no ordinary inverse.

The Moore-Penrose pseudoinverse chooses the set with the smallest joint speeds overall. With the transpose of (rows and columns exchanged):

The other sets of joint speeds differ from this one by motions that leave the hand still, like the elbow in the fingertip example. These motions are called the null space of . All solutions of are:

Here is the identity matrix and is any list of joint speeds you would like to have. The factor keeps only the part of that does not move the hand.

3-Link Planar Robot Example:

For a 3R robot with link lengths and joint angles :

The Jacobian is :

where and .

The arm has joints and the task has coordinates, so free motion is left: the arm can change its shape in one way while the end-effector stays still. Through its choice of , the controller uses this freedom for a second aim: to stay away from singularities, from joint limits or from an obstacle.

An example for joint limits: give each joint a cost that grows with its distance from the middle of its range, . The slope (gradient) of points toward higher cost, so the program uses the opposite direction as :

def joint_limit_gradient(q, q_min, q_max):
"""Gradient of the quadratic centering cost."""
center = (q_min + q_max) / 2
span = (q_max - q_min) / 2
return 2 * (q - center) / span**2
def redundant_ik_velocity(J, dx_desired, q, q_min, q_max, k_sec=1.0):
"""Primary: track dx_desired. Secondary: center joints in their limits."""
J_pinv = np.linalg.pinv(J)
z = -k_sec * joint_limit_gradient(q, q_min, q_max)
null = (np.eye(len(q)) - J_pinv @ J) @ z
return J_pinv @ dx_desired + null

The end-effector velocity does not change, because the second term contains only motions that leave the hand still. Keep the gain small, so that this second aim does not use most of the joint speed.

Force and Torque Mapping

The same matrix connects forces. Suppose the arm is still and the end-effector pushes on something with a force , in newtons. Each motor must hold a torque, and is the list of these joint torques, in N·m. The rule comes from power: torque times joint speed at the joints equals force times velocity at the hand, if friction is ignored. With this gives:

Velocity goes from the joints to the hand through . Force goes from the hand back to the joints through the transpose .

Force Mapping for Collaborative Safety

Keeping below the force limit:

To find the force at the hand from measured joint torques, invert the rule. With the largest allowed force N, the controller must keep:

Here is the inverse of , and the double bars mean the size of the force. Near a singularity, a small joint torque can give a large force in the direction the arm cannot move. A straight leg works the same way: with the knee locked it holds your weight with almost no effort from the muscles.

Python Code: Jacobian Computation and Velocity Mapping

The first program repeats the numerical example. It prints the same Jacobian, a hand velocity of (-2.187, 1.621) m/s with a speed of 2.722 m/s, , and joint speeds of 0.259 and -1.143 rad/s for the horizontal motion.

import numpy as np
def jacobian_2r(theta1, theta2, L1, L2):
"""
Compute the Jacobian matrix for a 2R planar robot.
Parameters:
theta1, theta2 : joint angles in radians
L1, L2 : link lengths in meters
Returns:
J : 2x2 Jacobian matrix
"""
s1 = np.sin(theta1)
c1 = np.cos(theta1)
s12 = np.sin(theta1 + theta2)
c12 = np.cos(theta1 + theta2)
J = np.array([
[-L1*s1 - L2*s12, -L2*s12],
[ L1*c1 + L2*c12, L2*c12]
])
return J
def forward_velocity(J, dq):
"""
Forward velocity mapping: joint velocities -> end-effector velocity.
Parameters:
J : Jacobian matrix (m x n)
dq : joint velocity vector (n,)
Returns:
dx : end-effector velocity vector (m,)
"""
return J @ dq
def inverse_velocity(J, dx):
"""
Inverse velocity mapping: end-effector velocity -> joint velocities.
Uses direct inverse for square Jacobian, pseudoinverse otherwise.
Parameters:
J : Jacobian matrix (m x n)
dx : desired end-effector velocity (m,)
Returns:
dq : required joint velocities (n,)
"""
if J.shape[0] == J.shape[1]:
# Square Jacobian: use direct inverse
det_J = np.linalg.det(J)
if abs(det_J) < 1e-6:
print(f"WARNING: Near singularity! det(J) = {det_J:.6f}")
# Use damped least squares instead
lam = 0.01 # damping factor
dq = J.T @ np.linalg.solve(J @ J.T + lam**2 * np.eye(J.shape[0]), dx)
return dq
return np.linalg.solve(J, dx)
else:
# Redundant robot: use pseudoinverse (minimum-norm solution)
return np.linalg.pinv(J) @ dx
# ---- Numerical example from the lesson ----
L1, L2 = 1.0, 0.8 # link lengths (m)
theta1 = np.radians(45)
theta2 = np.radians(30)
dq = np.array([2.0, -1.0]) # joint velocities (rad/s)
# Compute Jacobian
J = jacobian_2r(theta1, theta2, L1, L2)
print("Jacobian matrix:")
print(np.round(J, 4))
# Forward velocity mapping
dx = forward_velocity(J, dq)
print(f"\nEnd-effector velocity: dx = {dx[0]:.3f} m/s, dy = {dx[1]:.3f} m/s")
print(f"End-effector speed: {np.linalg.norm(dx):.3f} m/s")
# Determinant (singularity measure)
det_J = np.linalg.det(J)
print(f"\ndet(J) = {det_J:.4f}")
print(f"Analytical check: L1*L2*sin(theta2) = {L1*L2*np.sin(theta2):.4f}")
# Inverse velocity: desired horizontal motion
dx_desired = np.array([0.5, 0.0])
dq_required = inverse_velocity(J, dx_desired)
print(f"\nFor dx = {dx_desired}:")
print(f"Required joint velocities: dq1 = {dq_required[0]:.3f} rad/s, "
f"dq2 = {dq_required[1]:.3f} rad/s")
# Verify by forward mapping
dx_check = forward_velocity(J, dq_required)
print(f"Verification: dx = {dx_check[0]:.3f}, dy = {dx_check[1]:.3f}")

Python Code: Singularity Detection Across Configurations

The second program colours every pair of joint angles by . The picture is made of horizontal bands, because depends only on . The largest value, , is at .

import numpy as np
import matplotlib.pyplot as plt
def singularity_map(L1, L2, resolution=200):
"""
Compute and visualize the singularity measure (determinant of J)
across the entire joint space for a 2R robot.
Parameters:
L1, L2 : link lengths
resolution : grid resolution for joint angles
"""
theta1_range = np.linspace(-np.pi, np.pi, resolution)
theta2_range = np.linspace(-np.pi, np.pi, resolution)
T1, T2 = np.meshgrid(theta1_range, theta2_range)
# Vectorized determinant computation: det(J) = L1 * L2 * sin(theta2)
# Note: det(J) depends only on theta2 for the 2R robot
det_J = L1 * L2 * np.sin(T2)
fig, axes = plt.subplots(1, 2, figsize=(14, 5))
# Heatmap of determinant magnitude
ax1 = axes[0]
c1 = ax1.contourf(np.degrees(T1), np.degrees(T2), np.abs(det_J),
levels=50, cmap='viridis')
ax1.contour(np.degrees(T1), np.degrees(T2), np.abs(det_J),
levels=[0.01], colors='red', linewidths=2)
plt.colorbar(c1, ax=ax1, label='|det(J)|')
ax1.set_xlabel('theta1 (degrees)')
ax1.set_ylabel('theta2 (degrees)')
ax1.set_title('Jacobian Determinant Magnitude')
ax1.axhline(y=0, color='r', linestyle='--', alpha=0.7, label='Singularity: theta2=0')
ax1.axhline(y=180, color='r', linestyle='--', alpha=0.7, label='Singularity: theta2=180')
ax1.axhline(y=-180, color='r', linestyle='--', alpha=0.7)
ax1.legend(fontsize=8)
# Cross-section at theta1 = 45 degrees
ax2 = axes[1]
det_cross = L1 * L2 * np.sin(theta2_range)
ax2.plot(np.degrees(theta2_range), det_cross, 'b-', linewidth=2)
ax2.axhline(y=0, color='r', linestyle='--', alpha=0.7)
ax2.fill_between(np.degrees(theta2_range), det_cross, 0,
where=(np.abs(det_cross) < 0.05),
color='red', alpha=0.3, label='Near-singular zone')
ax2.set_xlabel('theta2 (degrees)')
ax2.set_ylabel('det(J)')
ax2.set_title(f'det(J) vs theta2 (L1={L1}, L2={L2})')
ax2.legend()
ax2.grid(True, alpha=0.3)
plt.tight_layout()
plt.savefig('singularity_map_2r.png', dpi=150, bbox_inches='tight')
plt.show()
print(f"Singularity lines: theta2 = 0 deg (fully extended, reach = {L1+L2})")
print(f" theta2 = 180 deg (fully folded, reach = {abs(L1-L2)})")
print(f"Maximum |det(J)| = {L1*L2:.3f} (at theta2 = +/-90 deg)")
# Generate singularity map
singularity_map(L1=1.0, L2=0.8)

Python Code: Manipulability Ellipsoid Visualization

The third program draws the arm and its ellipse in four poses. Expect a broad ellipse at and an almost flat one at and at .

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import Ellipse
def jacobian_2r(theta1, theta2, L1, L2):
"""Compute Jacobian for 2R robot."""
s1, c1 = np.sin(theta1), np.cos(theta1)
s12, c12 = np.sin(theta1 + theta2), np.cos(theta1 + theta2)
return np.array([
[-L1*s1 - L2*s12, -L2*s12],
[ L1*c1 + L2*c12, L2*c12]
])
def fk_2r(theta1, theta2, L1, L2):
"""Forward kinematics: returns end-effector position."""
x = L1*np.cos(theta1) + L2*np.cos(theta1 + theta2)
y = L1*np.sin(theta1) + L2*np.sin(theta1 + theta2)
return x, y
def plot_manipulability(L1, L2, configurations, scale=0.3):
"""
Visualize the robot arm and its manipulability ellipsoid
for several configurations.
Parameters:
L1, L2 : link lengths
configurations : list of (theta1, theta2) tuples in degrees
scale : scaling factor for ellipsoid display
"""
n_configs = len(configurations)
fig, axes = plt.subplots(1, n_configs, figsize=(5*n_configs, 5))
if n_configs == 1:
axes = [axes]
for ax, (t1_deg, t2_deg) in zip(axes, configurations):
t1 = np.radians(t1_deg)
t2 = np.radians(t2_deg)
# Joint positions for drawing the arm
x0, y0 = 0, 0
x1 = L1 * np.cos(t1)
y1 = L1 * np.sin(t1)
x2, y2 = fk_2r(t1, t2, L1, L2)
# Draw the robot arm
ax.plot([x0, x1, x2], [y0, y1, y2], 'ko-', linewidth=3,
markersize=8, markerfacecolor='steelblue')
ax.plot(x0, y0, 'ks', markersize=12) # base
# Compute Jacobian and SVD
J = jacobian_2r(t1, t2, L1, L2)
U, sigma, Vt = np.linalg.svd(J)
# Compute ellipsoid parameters
angle = np.degrees(np.arctan2(U[1, 0], U[0, 0]))
width = 2 * scale * sigma[0]
height = 2 * scale * sigma[1]
# Draw the manipulability ellipsoid at end-effector
ellipse = Ellipse(xy=(x2, y2), width=width, height=height,
angle=angle, alpha=0.3, facecolor='coral',
linewidth=2, edgecolor='red')
ax.add_patch(ellipse)
# Draw principal directions
for i in range(2):
direction = U[:, i] * sigma[i] * scale
ax.arrow(x2, y2, direction[0], direction[1],
head_width=0.03, head_length=0.02,
fc='red' if i == 0 else 'blue',
ec='red' if i == 0 else 'blue', linewidth=1.5)
# Draw workspace boundary
theta_circle = np.linspace(0, 2*np.pi, 100)
ax.plot((L1+L2)*np.cos(theta_circle), (L1+L2)*np.sin(theta_circle),
'g--', alpha=0.3, linewidth=1)
if L1 != L2:
ax.plot(abs(L1-L2)*np.cos(theta_circle),
abs(L1-L2)*np.sin(theta_circle),
'g--', alpha=0.3, linewidth=1)
# Annotations
det_J = np.linalg.det(J)
w = sigma[0] * sigma[1] # manipulability index
kappa = sigma[0] / max(sigma[1], 1e-10) # condition number
ax.set_title(f'theta1={t1_deg}, theta2={t2_deg}\n'
f'w={w:.3f}, kappa={kappa:.2f}, det={det_J:.3f}',
fontsize=10)
ax.set_xlim(-2.2, 2.2)
ax.set_ylim(-2.2, 2.2)
ax.set_aspect('equal')
ax.grid(True, alpha=0.3)
plt.suptitle('Manipulability Ellipsoids for 2R Robot (L1=1.0, L2=0.8)',
fontsize=13, fontweight='bold')
plt.tight_layout()
plt.savefig('manipulability_ellipsoids.png', dpi=150, bbox_inches='tight')
plt.show()
# Compare several configurations
L1, L2 = 1.0, 0.8
configs = [
(30, 90), # good dexterity
(45, 30), # moderate dexterity
(60, 10), # near singularity (theta2 close to 0)
(0, 170), # near singularity (theta2 close to 180)
]
plot_manipulability(L1, L2, configs, scale=0.3)

Python Code: Straight-Line Motion Using the Jacobian

The fourth program moves the hand along a straight line from (1.2, 0.5) m to (0.4, 1.0) m in 2 seconds. At each time step it finds the joint speeds with the inverse Jacobian, then moves the joints by speed times time step (resolved-rate control). The hand speeds up at the start and slows down at the end.

Two points help when you read it:

  • It prints a “tracking error” of about 77 mm at most. That number compares the hand with a point that moves along the line at constant speed, so nearly all of it is a difference in timing. The hand stays within about 1.3 mm of the line.
  • The option elbow_down=True in ik_2r selects . For the start point this puts the elbow below the line from base to hand, which is the elbow-down pose.
import numpy as np
import matplotlib.pyplot as plt
def jacobian_2r(theta1, theta2, L1, L2):
"""Compute Jacobian for 2R robot."""
s1, c1 = np.sin(theta1), np.cos(theta1)
s12, c12 = np.sin(theta1 + theta2), np.cos(theta1 + theta2)
return np.array([
[-L1*s1 - L2*s12, -L2*s12],
[ L1*c1 + L2*c12, L2*c12]
])
def fk_2r(theta1, theta2, L1, L2):
"""Forward kinematics for 2R robot."""
x = L1*np.cos(theta1) + L2*np.cos(theta1 + theta2)
y = L1*np.sin(theta1) + L2*np.sin(theta1 + theta2)
return np.array([x, y])
def straight_line_trajectory(L1, L2, q_start, p_start, p_end,
duration=2.0, dt=0.01):
"""
Generate joint trajectories for straight-line end-effector motion
using resolved-rate (Jacobian inverse) control.
Parameters:
L1, L2 : link lengths
q_start : initial joint angles [theta1, theta2] in radians
p_start : start position [x, y]
p_end : end position [x, y]
duration : motion time in seconds
dt : time step in seconds
Returns:
t_hist, q_hist, p_hist, det_hist : time-series data
"""
n_steps = int(duration / dt)
t_hist = np.zeros(n_steps)
q_hist = np.zeros((n_steps, 2))
p_hist = np.zeros((n_steps, 2))
det_hist = np.zeros(n_steps)
q = q_start.copy()
for i in range(n_steps):
t = i * dt
t_hist[i] = t
q_hist[i] = q
# Current end-effector position
p_current = fk_2r(q[0], q[1], L1, L2)
p_hist[i] = p_current
# Desired end-effector velocity (linear interpolation)
# Use trapezoidal velocity profile for smooth motion
s = t / duration # normalized time [0, 1]
if s < 0.2:
# Acceleration phase
v_scale = s / 0.2
elif s > 0.8:
# Deceleration phase
v_scale = (1.0 - s) / 0.2
else:
# Constant velocity phase
v_scale = 1.0
# Desired velocity direction and magnitude
direction = p_end - p_start
dist = np.linalg.norm(direction)
# Average speed adjusted for trapezoidal profile
v_avg = dist / duration
v_peak = v_avg / 0.8 # compensate for accel/decel phases
dx_desired = (direction / dist) * v_peak * v_scale
# Compute Jacobian
J = jacobian_2r(q[0], q[1], L1, L2)
det_J = np.linalg.det(J)
det_hist[i] = det_J
# Inverse velocity mapping with damped least-squares near singularity
if abs(det_J) < 0.05:
# Damped least-squares (Levenberg-Marquardt)
lam = 0.01
dq = J.T @ np.linalg.solve(J @ J.T + lam**2 * np.eye(2), dx_desired)
else:
dq = np.linalg.solve(J, dx_desired)
# Clamp joint velocities for safety
max_dq = 5.0 # rad/s limit
if np.max(np.abs(dq)) > max_dq:
dq = dq * max_dq / np.max(np.abs(dq))
# Integrate joint angles (Euler method)
q = q + dq * dt
return t_hist, q_hist, p_hist, det_hist
# ---- Simulate straight-line motion ----
L1, L2 = 1.0, 0.8
# Start and end points
p_start = np.array([1.2, 0.5])
p_end = np.array([0.4, 1.0])
# Compute initial joint angles using inverse kinematics (geometric)
def ik_2r(x, y, L1, L2, elbow_down=True):
"""Inverse kinematics for 2R planar robot."""
r2 = x**2 + y**2
cos_t2 = (r2 - L1**2 - L2**2) / (2 * L1 * L2)
cos_t2 = np.clip(cos_t2, -1, 1)
# elbow_down=True gives theta2 > 0: the elbow sits below the line from base to hand.
if elbow_down:
t2 = np.arctan2(np.sqrt(1 - cos_t2**2), cos_t2)
else:
t2 = np.arctan2(-np.sqrt(1 - cos_t2**2), cos_t2)
t1 = np.arctan2(y, x) - np.arctan2(L2*np.sin(t2), L1 + L2*np.cos(t2))
return np.array([t1, t2])
q_start = ik_2r(p_start[0], p_start[1], L1, L2, elbow_down=True)
# Run simulation
t_hist, q_hist, p_hist, det_hist = straight_line_trajectory(
L1, L2, q_start, p_start, p_end, duration=2.0, dt=0.005
)
# ---- Plot results ----
fig, axes = plt.subplots(2, 2, figsize=(12, 10))
# End-effector path
ax = axes[0, 0]
ax.plot(p_hist[:, 0], p_hist[:, 1], 'b-', linewidth=2, label='Actual path')
ax.plot([p_start[0], p_end[0]], [p_start[1], p_end[1]], 'r--',
linewidth=1.5, label='Desired straight line')
ax.plot(p_start[0], p_start[1], 'go', markersize=10, label='Start')
ax.plot(p_end[0], p_end[1], 'rs', markersize=10, label='End')
ax.set_xlabel('x (m)')
ax.set_ylabel('y (m)')
ax.set_title('End-Effector Path')
ax.legend()
ax.set_aspect('equal')
ax.grid(True, alpha=0.3)
# Joint angles over time
ax = axes[0, 1]
ax.plot(t_hist, np.degrees(q_hist[:, 0]), 'b-', label='theta1')
ax.plot(t_hist, np.degrees(q_hist[:, 1]), 'r-', label='theta2')
ax.set_xlabel('Time (s)')
ax.set_ylabel('Joint angle (degrees)')
ax.set_title('Joint Angle Trajectories')
ax.legend()
ax.grid(True, alpha=0.3)
# Joint velocities (numerical differentiation)
ax = axes[1, 0]
dq1 = np.gradient(q_hist[:, 0], t_hist)
dq2 = np.gradient(q_hist[:, 1], t_hist)
ax.plot(t_hist, dq1, 'b-', label='d(theta1)/dt')
ax.plot(t_hist, dq2, 'r-', label='d(theta2)/dt')
ax.set_xlabel('Time (s)')
ax.set_ylabel('Joint velocity (rad/s)')
ax.set_title('Joint Velocities')
ax.legend()
ax.grid(True, alpha=0.3)
# Jacobian determinant over time
ax = axes[1, 1]
ax.plot(t_hist, det_hist, 'g-', linewidth=2)
ax.axhline(y=0.05, color='r', linestyle='--', alpha=0.7,
label='Singularity threshold')
ax.axhline(y=-0.05, color='r', linestyle='--', alpha=0.7)
ax.set_xlabel('Time (s)')
ax.set_ylabel('det(J)')
ax.set_title('Singularity Measure During Motion')
ax.legend()
ax.grid(True, alpha=0.3)
plt.suptitle('Straight-Line Motion via Jacobian Inverse Kinematics',
fontsize=14, fontweight='bold')
plt.tight_layout()
plt.savefig('straight_line_jacobian.png', dpi=150, bbox_inches='tight')
plt.show()
# Report tracking error
desired_path = p_start + np.outer(t_hist / t_hist[-1], p_end - p_start)
tracking_error = np.linalg.norm(p_hist - desired_path, axis=1)
print(f"Maximum tracking error: {np.max(tracking_error)*1000:.2f} mm")
print(f"Average tracking error: {np.mean(tracking_error)*1000:.2f} mm")
print(f"Minimum |det(J)| during motion: {np.min(np.abs(det_hist)):.4f}")

System Application: Collaborative Robot Force Limiting



The collaborative robot must follow the path of the handover and keep the force at the end-effector below 150 N. This loop runs in the robot’s own controller, many times each second.

Force-Limited Trajectory Execution

At each time step the controller does this:

  1. Measure the joint angles with the encoders and the joint torques with the torque sensors.

  2. Compute the Jacobian for the present pose.

  3. Estimate the force at the end-effector with . If its size is above , reduce all joint torques by the same factor.

  4. Check for a singularity with . If it is below the threshold, change to damped least squares and reduce speed.

  5. Compute the joint speeds for the wanted hand velocity: (the pseudoinverse for a redundant robot).

  6. Limit the joint speeds to what the motors and the safety rules allow.

  7. Send the limited joint speeds to the motor drives.

Force Monitoring Example

Take the 2R arm in the pose of the numerical example (, ), with measured joint torques N·m and N·m. The force at the end-effector is:

Take the inverse Jacobian from the numerical example and exchange its rows and columns:

Row by row:

The size of the force is N, far below the 150 N limit in this pose ✅

Design Guidelines



Jacobian Computation

Derive the Jacobian as a formula, then program it. Check the program against small test moves of each joint. Compute it again in every control cycle (typically 1 kHz for collaborative robots).

Singularity Management

Watch or the smallest singular value. Near a singularity, use damped least squares ( to ) and reduce speed.

Redundancy Exploitation

Use the null space for a second aim: joint limits, singularities or obstacles. The motion of the end-effector always comes first.

Force Safety

Use to turn the force limit into joint torque limits, and update them in every control cycle, because changes with the pose.

Practical Checklist

  1. Derive the Jacobian for your robot and check it with small test moves.

  2. Find the singular poses in your workspace and keep planned paths away from them.

  3. Set singularity thresholds from the speed and force your task needs.

  4. Add damped least squares for poses near a singularity.

  5. Test the force mapping in several poses, most of all near the edge of the workspace.

Summary



Key Concepts Covered

  1. The Jacobian matrix turns joint speeds into the velocity of the end-effector: . Each column is the motion of the hand for one joint alone.
  2. Forward velocity mapping is a multiplication and works in every pose
  3. Inverse velocity mapping needs or and fails at singularities
  4. Singularities are the poses with . For the 2R arm, : the arm is singular when straight or fully folded.
  5. Manipulability ellipsoids show in which directions the hand moves easily
  6. The pseudoinverse gives a redundant robot the smallest joint speeds, and the null space leaves freedom for a second aim
  7. Force mapping uses the transpose: . Where the hand is fast it is weak.
  8. Safety beside people needs the force at the hand checked in every control cycle

What Comes Next

Trajectory Planning and Motion Control uses the Jacobian to plan smooth paths for pick-and-place work.



Comments

Loading comments...
© 2021-2026 SiliconWit®. All rights reserved.
Predict first

A two-link arm is stretched fully straight. In which direction can the tip not move at that instant, whatever the two joints do?

See it: what the joints can do to the tip
θ₁θ₂ 1 m/s
  • Tip velocity for the joint speeds you set
  • Joint 1 alone, at 1 rad/s (column 1 of J)
  • Joint 2 alone, at 1 rad/s (column 2 of J)
  • Every tip velocity the joints can give at unit joint speed
J =
det J = L₁·L₂·sin θ₂
Tip velocity (vx, vy), m/s
Tip speed
Ellipse half-axes

The arm is the lesson's example: 1.0 m and 0.8 m links at 45° and 30°. The two thin arrows are the two columns of J. Each one is the tip velocity when one joint turns at 1 rad/s and the other is still. The tip velocity is the first arrow times the first joint speed plus the second arrow times the second joint speed. The ellipse holds every tip velocity the joints can give together at unit speed. Move θ₂ toward 0° or 180°. The two thin arrows turn to lie on one line, the ellipse becomes flat, and det J goes to zero. The tip can then move only across the arm.

Check yourself

Three questions. Each wrong choice is a mistake people really make, so read the note after you answer.

1. The arm (1.0 m and 0.8 m links) is fully straight, so it is singular. Joint 1 turns at 1 rad/s and joint 2 is held still. How fast does the tip move?

2. At θ₁ = 45° and θ₂ = 30° the lesson's arm has det J = 0.40. You turn joint 1 to θ₁ = 90° and leave joint 2 where it is. What is det J now?

3. With θ₁ = 0° and the elbow at θ₂ = 90°, moving the tip straight away from the base at 0.1 m/s needs joint 1 at 0.06 rad/s and joint 2 at 0.16 rad/s, turning the other way. What does the same slow tip motion need when the arm is almost straight, at θ₂ = 5°?

0.1 m/s0.1 m/s90°5° Joint 1: 0.06 rad/sJoint 2: 0.16 rad/sJoint 1: 1.15 rad/sJoint 2: 2.58 rad/s
6.3 N9.1 N15.4 N71.8 N 30°10°5°1°elbow angle θ₂ Same torques:10 and 5 N·m Straighter arm,larger force.
Watch it build: the Jacobian of one pose
1.0 0.8 θ₁ = 45°, θ₂ = 30° (0.91, 1.48) θ₁ θ₂ x y ?? ?? −1.480−0.773 0.9140.207 1 2 col 1: 1.74 m/s col 2: 0.80 m/s
  1. The arm of the numerical example: links 1.0 m and 0.8 m, at θ₁ = 45° and θ₂ = 30°.
  2. Forward kinematics puts the hand at (0.914, 1.480) m.
  3. The Jacobian is a 2 × 2 table: a row for x and y, a column for each joint.
  4. Row x, the derivatives of x: −1.480 for joint 1, −0.773 for joint 2.
  5. Row y, the derivatives of y: 0.914 and 0.207. The table is full.
  6. Each column is a hand velocity for 1 rad/s at one joint: 1.74 m/s across the line to the base, 0.80 m/s across link 2.
Found this useful?

Discussion

    Comments show your name. Be kind, stay on the topic.