FixTheRobot Explore Robotics / Guidance, Navigation and Control / M2 / M2-L2

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

Guidance, Navigation and Control · Modelling a Vehicle for GNC · M2-L2 · Intermediate

Find the Simulator Bug

Bench log · Hopper on the test range

16:30. The Hopper simulator has a defect nobody can find: with the engine off and nothing pushing, the spinning test body gains rotational energy, and the attitude estimate drifts in a long run. Three people have each touched the code in the last month.

You will find the three defects the way an engineer does: with checks that have a known answer. Energy must be constant, a quaternion must stay a unit one, and angular momentum must be conserved.

Your task

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

    Plain Python 3 with the standard library and the course library gnckit (import gnckit as g: transfer functions and margins, state space and LQR, the Hopper model, quaternions, a convex solver). 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: an undamped spring conserves energy; a first-order integrator does not, whatever the step. Stage 2: a quaternion update that adds to q leaves the unit sphere, and the exact update is a product with a unit quaternion. Stage 3: Euler's equations have a cyclic sign pattern, and a single swapped pair breaks the conservation of energy and momentum.

    Grading runs your code on hidden frequencies, step sizes, inertias and rates, and compares the energy, the quaternion and the derivative with exact results.

    Theory for this lab

    Modelling a Vehicle for GNC labs

    1. M2-L1: Trim and Linearize Hopper
    2. M2-L2: Find the Simulator Bug: this lab.

    Educational simplification: three isolated defects in three isolated pieces. A real simulator mixes them with sensor models, actuators and a variable step; the checks are the same.

    Get the next lab

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