Lesson 03 · 60 minutes

Did It Actually Turn?

Open loop vs closed loop

Today's goal

Run the same move with the IMU off and on, measure the difference, and explain what the robot 'knows' in each case.

Ideas in this lesson

Sense → Think → Do

With heading hold off, the robot drives the square on timing alone: it never checks. With it on, it senses its heading the whole way, thinks about the error, and corrects as it goes, then squares up at the end if anything is left.

How the session runs

  1. Mark a start spot and a start direction with tape (an arrow on the floor).
  2. Check the IMU: in the app console type i. You should see 'on MPU-6050 0x68' (or BNO055 0x28).
  3. Watch the Sensors tab: the big IMU number is the heading, 0 to 360 degrees clockwise. Turn the robot by hand and watch it follow.
  4. Program tab: open 'Example: IMU showdown (square without, then with)' and read the steps. Heading hold off, a square, wait 3 seconds, heading hold on, the same square.
  5. Press RUN. During the first square, mark where each corner really is and which way the robot ends up facing. The block it is doing lights up.
  6. During the second square, mark the corners again. Compare the two sets of marks and measure how many degrees off the robot faced at the end of each.
  7. Run it twice more. Is the open-loop error the same every time? Is the closed-loop one?
  8. Drive by hand with the pad: strafe sideways with heading hold on (in), then off (if). With it on, the nose stays pointing the same way.
  9. Discuss: what did the robot know in the second square that it did not know in the first?

Try this

When it goes wrong

What you seeWhat it means
i says 'none found'SDA and SCL swapped, or a loose wire. A4 is SDA, A5 is SCL.
Heading drifts slowly when sitting stillThe MPU-6050 measures its offset during the first second after power-on. Restart with the robot sitting still.
IMU on, but the turn is still wrongCheck the IMU is flat and firmly mounted. A loose board measures its own wobble.
'move: slowing to N%' in the consoleThe robot slowed the whole move so no wheel goes over its top speed. The path stays the same, it just takes longer.
Notes for the grown-up

This is the strongest demo in the course. Do the open-loop square first and let them see the scatter before revealing the IMU. On an uncalibrated robot each closed-loop move ends with a little wiggle: the settle step correcting what is left. After auto-calibration (lesson 4) the moves stop early enough for their momentum to land them on target, and the wiggle mostly disappears: point that out too.

Ages: K-5: 'eyes closed vs eyes open' walking a turn across the room, then the robot. 6-12: talk about error, proportional correction (the sketch corrects 3 rad/s per rad of error), and gyro drift.

Materials: Robot with MPU-6050 or BNO055, tape for start marks, protractor or a printed angle mat, app for the console.

← Same Job, Different PhysicsEvery Robot Is Different →