Lesson 04 · 60 minutes

Every Robot Is Different

Measuring your own robot's numbers

Today's goal

Let the IMU measure your robot's own motors, check one distance with a tape measure, and explain why one trial is not enough.

Ideas in this lesson

Sense → Think → Do

The robot can SENSE its own turning with the IMU, so it can calibrate most of itself: that is the closed loop from lesson 3, pointed at its own motors. Distance it cannot sense, so for that you are the sensor, with a tape measure.

How the session runs

  1. Flash calibration.ino (the calibration program: no sensors or demos, just measuring). Open the Calibrate tab. Type the robot's name, then press the surface it is standing on (carpet, rug, hardwood, tile, concrete). The top panel always says which numbers the robot is driving with: the fleet defaults until it is calibrated.
  2. Step 1, speed curve: clear a space, press the button and stand back. For about 20 seconds the robot spins: first it hunts for the lowest power that gets it moving at all (ours: nothing at PWM 64, then suddenly 46 degrees a second at 72), then half, three-quarter and full power. Is half power half the speed? Usually it is much more: motors are not straight lines.
  3. Step 2, drive straight: it drives forward and back, then strafes left and right, slow and fast, with heading hold off. A stronger side makes it turn when it should go straight; the gyro measures how much, and each wheel gets its own trim. Watch the turn numbers shrink from round to round.
  4. Step 3, distance: press Drive it, measure from the start mark to the tail, and how far it ended up to the side. Enter both and Apply. Drive it again: closer?
  5. Every step changes the robot straight away and saves the numbers in its EEPROM. Flash mecanum_holonomic.ino again: it reads them at power-on (the top panel says 'saved in the robot's EEPROM'). Uploading a new version later keeps them.
  6. Now pick a different surface and do it again. Compare the two sets: which numbers change, and why?
  7. No IMU, or to see the science by hand: open 'Without an IMU' for the tape-measure runs (cf full power, ch half, cs strafe, cr spin), three trials each; the app averages them. Our robot strafed about 615 mm sideways for 1380 mm forward: 0.45. Why? The rollers slip sideways.
  8. Compare with another group's robot. Same kit, different numbers.

Try this

When it goes wrong

What you seeWhat it means
Steps say 'Pick the surface first'Press the surface the robot is on, at the top of the Calibrate tab.
Speed curve says the robot hardly turnedWheels off the floor, battery flat, or no IMU found (Sensors tab, top panel).
Drive straight never gets thereA wheel rubbing or a loose motor: check by hand. Then run it again; it carries on from where it got.
Trials disagree by a lotBattery is dropping, or the floor changes. Charge up and use the same patch of floor.
A wheel goes backwards in t0-t3Tick 'backwards' for that corner in the wiring table and paste the new table into the sketch.
Notes for the grown-up

Measuring is the scientific method in miniature: predict, measure, repeat, average, check. The speed curve and drive-straight steps do most of it for you, which is the point to make: a robot that can sense itself can measure itself. Make the prove-it runs a small celebration; it is satisfying when the robot lands on the mark.

Ages: K-5: watch the speed curve and drive-straight steps, then the class guesses where the 1 m run will stop before measuring it. 6-12: compute STRAFE_EFFICIENCY by hand from the tape-measure steps, and discuss why the IMU's accelerometer cannot measure distance (a 0.01 g error, summed twice, is about 0.8 m off after 4 seconds).

Materials: Robot with MPU-6050 or BNO055, app, tape measure (mm), masking tape for marks, charged battery, a consistent floor patch about 2 m by 2 m.

← Did It Actually Turn?Sideways Is a Direction →