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

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

Linear Algebra · Mathematical Foundations · M1-L1 · Beginner

2D Robot Vector Navigator

Robot scenario

Scout is a small delivery robot in a hospital corridor. It does not know much: where it is, which way it faces, and where the next beacon is. Everything it does comes from arrows between those places.

First you will steer it with arrows you can drag. Then you will find out why a one-line bearing formula sends it the wrong way, and fix it. You will finish by writing the planner that turns a list of beacons into turns and legs, and prove it on maps you have never seen.

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: robot, beacon and two legs are all draggable, and you see vector addition as a picture and as numbers. Stage 2 is the diagnosis: the formula atan(dy / dx), which many first programs use, fails in half the plane. Stages 3 and 4 are the fixes you write: distance and bearing from a displacement, and the forward, left and turn numbers of a robot-frame view. Stage 5 puts them together into a route planner and grades it on hidden maps. Stage 6 is a sandbox that makes the signs of forward and left, and the turn angle, something you can predict.

    Grading is result-based. Your functions run on the example and on freshly generated hidden maps, and are compared with exact results to six decimal places. Every quadrant, positions straight above, below and behind the robot, a beacon at the robot's own position, and turns close to half a turn appear in the hidden maps, because those are the cases that break first.

    You can use plain Python, math, and the small linear algebra library lakit (import lakit as la): la.vsub, la.vadd, la.norm, la.dot, la.cross, la.unit and more. It runs in your browser; NumPy is not available there.

    Theory for this lab

    Mathematical Foundations labs

    1. M1-L1: 2D Robot Vector Navigator: this lab.

    Educational simplification: a flat plane, the robot turns on the spot, and a leg is a straight displacement with no speed limits or dynamics. Angles are in radians, counter-clockwise from the +x axis. Real planners add a footprint, obstacles and a controller; the vector arithmetic here is the part that stays the same.

    Get the next lab

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