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

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

Linear Algebra · Linear Systems and Vector Spaces · M3-L1 · Beginner

Solve a Robot's Constraints

Robot scenario

Scout has been upgraded with four mecanum wheels: it can slide sideways as well as drive and turn. Four wheels and three body velocities mean more numbers than the robot has freedoms, and that surplus is both a nuisance (noisy wheels disagree) and a gift (a spare equation to average out noise).

You will read the wheel pattern for sideways motion, find the commands that no body motion can produce, write the least-squares estimator for odometry, and finish with a solver that tells unique, missing and infinite solutions apart.

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: three body-velocity sliders and four wheel arrows make the matrix w = J v visible. Stage 2 is the diagnosis: wheel commands outside the column space of J are slip. Stage 3 is the fix you write: estimate_body_velocity uses all four equations by least squares. Stage 4 generalises: solve_any classifies a system as unique, many or none and returns the minimum-norm solution when there are many.

    Grading is result-based. Your functions run on the example and on freshly generated hidden systems with noise, a slipping wheel, singular matrices and wide and tall shapes, and are compared with exact results to six decimal places.

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

    Theory for this lab

    Linear Systems and Vector Spaces labs

    1. M3-L1: Solve a Robot's Constraints: this lab.

    Educational simplification: ideal mecanum rollers, no floor slip dynamics, a fixed wheel radius and base geometry, and Gaussian encoder noise. The linear algebra of the 4 × 3 wheel matrix is exactly what real odometry code solves.

    Get the next lab

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