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

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

Linear Algebra · Least Squares and Numerical Methods · M5-L1 · Intermediate

LiDAR Plane Fitting

Robot scenario

Scout now carries a LiDAR. Before it can avoid a wall or drive up a ramp it must answer a plain question about every patch of points it sees: what plane are these on?

You will place a line by hand and feel what least squares minimises, find out why the same recipe sends a wall to nonsense, and then write the two routines a real perception pipeline contains: a ground-plane fit and a fit that works for any orientation.

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: two handles place a line and the squared error is shown next to the minimum. Stage 2 is the diagnosis: vertical-error least squares breaks down on a wall. Stage 3 is the first fix you write: fit_ground_plane solves the tall system for z = a x + b y + c. Stage 4 generalises: fit_plane returns a unit normal and offset by total least squares, from the covariance eigenvector, for ground, roofs and walls.

    Grading is result-based. Your functions run on the example and on freshly generated hidden point clouds with noise, and are compared with the exact least-squares and total-least-squares answers (planes up to the sign of the normal).

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

    Theory for this lab

    Least Squares and Numerical Methods labs

    1. M5-L1: LiDAR Plane Fitting: this lab.

    Educational simplification: synthetic points with Gaussian noise and no outliers, a single plane per patch, and a side view for the pictures. Real pipelines add outlier rejection (RANSAC) around exactly these two fits.

    Get the next lab

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