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

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

Linear Algebra · Eigenvalues, Eigenvectors and SVD · M6-L1 · Intermediate

Point Cloud PCA

Robot scenario

Scout's LiDAR returns thousands of points a second. Almost every mapping routine begins by asking a tiny neighbourhood of them a single question: are you a wall, a pole, or a bush? The answer is hidden in three numbers, the eigenvalues of the neighbourhood covariance.

You will find the direction of greatest spread by hand, learn to read three spreads as plane, line or volume, then write the two functions that do this for real: the principal axes of a cloud, and a patch classifier that survives a patch 1000 m away.

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: turning an axis shows that the variance along it is uᵀ C u, largest at the top eigenvector. Stage 2 is the diagnosis: three spreads become linearity, planarity and sphericity. Stage 3 asks for principal_axes: centre, covariance, eigen-decomposition, sort. Stage 4 asks for classify_patch on hidden patches that include a distant wall which breaks an uncentred covariance.

    Grading is result-based. Your functions run on the example and on freshly generated hidden clouds in random orientations and positions, compared with exact eigenvalues to a relative 10⁻⁶ and axes to 10⁻⁴ rad (sign free).

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

    Theory for this lab

    Eigenvalues, Eigenvectors and SVD labs

    1. M6-L1: Point Cloud PCA: this lab.

    Educational simplification: synthetic Gaussian patches without outliers, 60 to 80 points each. Real pipelines add neighbour search and outlier rejection around exactly this eigen-analysis.

    Get the next lab

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