SPIKE Prime Robotics Camp — Day 3
Give your robot an inner compass
Each day upgrades our robot.
Upgrade your robot's inner compass:
Honest truth: the gyro isn't magic. We'll tune it.
Bugs are sensor data.
The robot did exactly what the code said.
What did the code actually say?
Here's a drawn sequence of robot moves.
One step is wrong. Find it.
A small early error throws off everything after it — that's sensor data!
The robot can already:
straight() distanceturn() an angleConnect, drive, and turn — then we add the gyro.
Same robot, same ideas. Pybricks shows the Python next to your blocks.
A gyroscope senses how the robot is turning.
It lets the robot feel which way it's facing instead of just counting wheel-spins.
The gyro corrects as it goes.
robot.use_gyro(True) # now turns/straights use the gyro
One line. Same straight() and turn() after that.
Run the same moves twice — gyro off, then gyro on.
Measure how far off each one ends up.
use_gyro(True) and run againThe robot can tell you the direction it's facing.
print(hub.imu.heading()) # degrees
The gyro is better — but not perfect.
robot.turn(360)hub.imu.heading() — back to 0?turn(357).turn(362).
robot.turn(357) # one hub's true full turn
Could be 355-363 on yours. It's calibration, not a bug.
Get up, move, refuel.
Keep food away from the kits and laptops!
Prove the gyro helps, then tune a true 360°.
The chart is the proof.
use_gyro(True) makes turns more accuratehub.imu.heading() reads the heading (starts at 0)Obstacle Avoidance
We'll give your robot eyes with the distance sensor —
so it can react to the world and change
what it does instead of running a fixed script.