How the Hand Answers Each Joint

Jacobian · partial derivatives · forward kinematics · planar arm

A camera-holding arm on a film set is a planar two-link arm: the shoulder joint at the origin, a first link of length l1, an elbow, and a second link of length l2 ending at the camera (the hand). The joint angles are in radians and relative: t1 is the first link's angle from the +x axis, and t2 is the second link's angle from the direction of the first link. With x to the right and y up, the hand is at

x = l_1 \cos t_1 + l_2 \cos(t_1 + t_2), \qquad y = l_1 \sin t_1 + l_2 \sin(t_1 + t_2).

The operator wants to know how sensitive the camera is to each motor. The Jacobian J collects the four partial derivatives (the rate of change of one output when one joint angle changes and the other stays fixed):

J = \begin{pmatrix} \partial x / \partial t_1 & \partial x / \partial t_2 \\ \partial y / \partial t_1 & \partial y / \partial t_2 \end{pmatrix}

Row 0 is about x, row 1 about y; column 0 is about t1, column 1 about t2.

Write jacobian(l1, l2, t1, t2) that returns J as a list of two rows, [[dx_dt1, dx_dt2], [dy_dt1, dy_dt2]], using the exact derivatives (not a numerical estimate).

Examples

Input:  l1 = 2, l2 = 1, t1 = 0, t2 = math.pi / 2
Output: [[-1.0, -1.0], [2.0, 0.0]]
Explanation: the hand is at (2, 1). Turning the shoulder swings it to the left
and up: dx/dt1 = -1, dy/dt1 = 2. Turning the elbow moves it only along -x.

Input:  l1 = 0.4, l2 = 0.3, t1 = 0.5, t2 = -1.2
Output: [[0.00149509, 0.19326531], [0.58048568, 0.22945266]]

Constraints

  • answers are compared with a tolerance of 1e-6; do not round

Goals

  • Differentiate the hand position of a two-link arm with respect to each joint angle
  • Arrange the four partial derivatives as a $2 \times 2$ matrix: rows for $x, y$, columns for the joints
  • Read a column of the Jacobian as the hand's motion when one joint turns
Starting Python…