FixTheRobot Explore Robotics / Localization & SLAM / M2 / M2-L2

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

Localization & SLAM · Mathematical Foundations · M2-L2 · Intermediate

Diagnose a Pose-Transformation Error

Pose code fails quietly. The robot still moves, the map still draws, and the numbers look plausible, but headings flip near 180°, a camera sees the floor in the sky, and a composed rotation is the wrong one of two.

You will diagnose the heading bugs from the shape of their errors, implement the quaternion algebra from scratch, and fix the classic camera optical-frame trap using a fact you can check: floor markers have z = 0.

Your task

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

    Plain Python with math and, for matrices, slamkit (matmul, transpose, solve, inverse, identity). The data arrive as the dictionary D. There is no NumPy, random, json or copy in the browser runtime. Your code runs locally and never leaves this page.

    Hints

    What this lab teaches

    Stage 1 is pure diagnosis: three trackers fail in three different ways at the same moment, and the shape of each failure identifies its cause. Stage 2 implements quaternions and is graded by what the result does to test vectors, because q and −q are the same rotation. Stage 3 chains a fixed axis permutation, a quaternion and a translation, and uses a physical fact (the floor is flat) as a self-check. The simulator keeps the true marker positions and camera mounts private.

    Theory for this lab

    Mathematical Foundations labs

    1. M2-L1: Transform Points Between Coordinate Frames
    2. M2-L2: Diagnose a Pose-Transformation Error: this lab.
    3. M2-L3: Understand Pose Uncertainty
    4. M2-L4: Match Observations to Landmarks

    Educational simplification: one rigid camera and a handful of markers, noise-free quaternions, and trackers with deliberately injected bugs. Production code uses libraries such as Eigen, Sophus or tf2, and also has to handle timestamps and calibration error (Module 7).

    Get the next lab

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