← All Base Form Math projects
BM-16NOT STARTEDBASE FORM · CALCULUSMATHPYTHON

Robot arm reacher

Make a 2-link robot arm reach any point you click, using its Jacobian to steer the joints.

EST.7 h
REWARD+100 XP
AFTERoriginal

ML-ARENA BENCHMARKS

YOUR NUMBER VS THE INDUSTRY'S
METRICINDUSTRYMINE
reach error on 1,000 random targets
GOAL · all within 1 mm
closed-form inverse kinematics—
no results yet
YOUR RESULTS

Your recorded results appear here.

Brief

A robot arm has motors at its joints, but what you care about is where its tip goes. Turning joint angles into a tip position is forward kinematics. The reverse, finding angles that put the tip on a target, is inverse kinematics, and robot arms solve it many times per second.

For a 2-link arm with lengths L1L_1 and L2L_2, the tip is at

x=L1cos⁡θ1+L2cos⁡(θ1+θ2),y=L1sin⁡θ1+L2sin⁡(θ1+θ2)x = L_1\cos\theta_1 + L_2\cos(\theta_1+\theta_2), \qquad y = L_1\sin\theta_1 + L_2\sin(\theta_1+\theta_2)

The Jacobian JJ is the 2 × 2 matrix of partial derivatives Jij=∂pi/∂θjJ_{ij} = \partial p_i / \partial \theta_j, where p=(x,y)p = (x, y). It says how the tip moves for a tiny change in each angle: Δp≈J Δθ\Delta p \approx J\,\Delta\theta. You build it with the chain rule. For example, the derivative of cos⁡(θ1+θ2)\cos(\theta_1+\theta_2) with respect to θ1\theta_1 is −sin⁡(θ1+θ2)-\sin(\theta_1+\theta_2) times the derivative of the inside, which is 1.

Steering is then a loop. Measure the error ee from tip to target, find a small Δθ\Delta\theta with JΔθ≈eJ\Delta\theta \approx e, take it, repeat. Solve that linear system exactly and you have Newton's method. Step along J⊤eJ^\top e instead and you have gradient descent on 12∥e∥2\tfrac12\|e\|^2. Both struggle where det⁡J=L1L2sin⁡θ2\det J = L_1 L_2 \sin\theta_2 is close to zero.

VISUALFig. 1
θ₁ θ₂ L₁L₂ TIP (x, y) e TARGET x = L₁cos θ₁ + L₂cos(θ₁+θ₂) y = L₁sin θ₁ + L₂sin(θ₁+θ₂) e = target − tip. Each step, the Jacobian J turns e into a small change of θ₁ and θ₂. det J = L₁L₂ sin θ₂ zero when the arm is straight or folded flat
The two-link arm, its angles, and the error vector e from tip to target. Why it's here: Every formula in the project refers to these symbols. Keep the picture next to your derivation.
HINT · OBJECTIVE 4
Stuck? Hints stay hidden until you ask.
HINT · OBJECTIVE 6
Stuck? Hints stay hidden until you ask.

DATA · simulated arm

Objectives

0 / 6 CLEARED

Read-only. Log in to update progress.

VICTORY CONDITIONS

  1. All 1,000 random reachable targets are reached within 1 mm by your Jacobian-based solver, checked by running its angles through forward kinematics and against the closed-form solution. Record the worst error with `python tools/mlarena.py record BM-16 "<max error> mm"`.
  2. The solver never returns NaN or infinite angles, including for targets near the inner and outer edges of the reachable ring.
  3. The README has a recording of the click-to-reach demo.

Side quests

Add a third link. J becomes 2 × 3 and there are infinitely many solutions. Use the pseudo-inverse and pick the one that moves the joints least.
Add joint limits and see how each solver handles a target that needs a forbidden angle.

Terms in plain words

Forward kinematics
Joint angles in, tip position out. A bit of trigonometry.
Inverse kinematics
Target position in, joint angles out. The hard direction, and what this project solves.
Jacobian
The matrix of partial derivatives of every output with respect to every input. For this arm it is 2 × 2 and says how the tip moves for a small turn of each joint.
Chain rule
The derivative of a function of a function is the product of their derivatives. With several variables, the Jacobians multiply.
Singularity
A pose where det J = 0, so small joint moves can't push the tip in some direction. For this arm, that's fully straight or fully folded.