FixTheRobot Explore Robotics / Linear Algebra / M8 / M8-L1

This lab works on phones, but writing code is much easier on a laptop.

Linear Algebra · Jacobians and Robot Kinematics · M8-L1 · Intermediate

Interactive Robotic Arm and Inverse Kinematics

Robot scenario

Scout has grown an arm: two links, two joints, a hand. Telling the hand where to go is easy; telling the joints how to get it there is the whole subject of inverse kinematics.

You will reach a target by dragging the hand, find out why the textbook inverse sends the joints spinning when the arm is almost straight, and then write the two pieces of a robust solver: a damped velocity step and a full iterative solver that survives a singular start and targets out of reach.

Your task

    Simulation
    solution.pyLoading Python…
    Ctrl+Enter runs
    What Python can I use?

    Plain Python with math and lakit (import lakit as la: vectors, matmul, solve, qr, svd, eigh, lstsq, pinv and more; NumPy is not available in the browser). Your code runs in a background worker: an endless loop is stopped after a few seconds and the page stays usable. It runs in your browser and is never sent anywhere.

    Hints

    What this lab teaches

    Stage 1 is hands-on: the hand is draggable, the two arm shapes for one target are visible, and the reach limits are drawn. Stage 2 is the diagnosis: the exact Jacobian inverse demands enormous joint speeds when the arm is almost straight. Stage 3 is the fix you write: damped_step computes Jᵀ(J Jᵀ + λ²I)⁻¹ v. Stage 4 uses it: solve_ik iterates damped steps from a singular start and stays stable for unreachable targets.

    Grading is result-based. Your functions run on the example and on freshly generated hidden Jacobians and targets, including an exactly singular Jacobian, a wide 2 × 3 Jacobian, a singular starting pose and targets beyond the reach, and are compared with exact results.

    You can use plain Python, math, and the small linear algebra library lakit (import lakit as la): la.solve, la.matmul, la.transpose, la.matvec, la.norm and more. It runs in your browser; NumPy is not available there.

    Theory for this lab

    Jacobians and Robot Kinematics labs

    1. M8-L1: Interactive Robotic Arm and Inverse Kinematics: this lab.

    Educational simplification: a planar two-link arm with links of 2.2 m and 1.6 m, no joint limits, no dynamics and no obstacles. The linear algebra of the 2 × 2 Jacobian and of damped least squares is the same as for a six-joint industrial arm.

    Get the next lab

    Get notified when new robotics labs are released. One email per new lab, nothing else.