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
- Open loop: do the plan and hope (timed motors, no checking)
- Closed loop: measure what actually happened and correct
- The IMU (MPU-6050 or BNO055) measures how far the robot has turned
- Feedback is the THINK that turns a toy into a robot
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
- Mark a start spot and a start direction with tape (an arrow on the floor).
- Check the IMU: in the app console type i. You should see 'on MPU-6050 0x68' (or BNO055 0x28).
- 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.
- 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.
- 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.
- 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.
- Run it twice more. Is the open-loop error the same every time? Is the closed-loop one?
- 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.
- Discuss: what did the robot know in the second square that it did not know in the first?
Try this
- Lift one side of the robot slightly while it turns (carefully). Which mode notices?
- Run on carpet and on a smooth floor, heading hold off. Does the error change?
- Build your own test in the Program tab: turn right 90 four times, with heading hold off and then on.
- Could a robot be closed loop without an IMU? What else could it measure?
When it goes wrong
| What you see | What 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 still | The 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 wrong | Check the IMU is flat and firmly mounted. A loose board measures its own wobble. |
| 'move: slowing to N%' in the console | The 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.