Robot Programmer
State machines, odometry, feedback control up to PID, noisy sensors, maze solving and path planning, all in Python. 8 lessons to work through.
- States and Modes: Give Spark modes with a state machine: draw states and arrows, find out why a robot needs memory, hunt bugs only state machines have, then program a night patrol that waits for the caretaker, waits for people and turns only at walls.
- Timing and Doing Two Things at Once: Find out why sleep() makes a robot blind, read Spark’s clock with ticks_ms(), juggle several jobs in one fast loop, then give the night patrol a flashing beacon that never stops it watching.
- Wheel Encoders: Find out why driving by time goes wrong, count wheel turns with an encoder, drive exact distances, keep straight with unequal motors and turn exact corners, then deliver the register on Spark’s worst days.
- Knowing Where You Are: Turn wheel ticks into x, y and heading with odometry, see how its errors creep in, then drive to checkpoints and find the way home to the charger in the dark.
- Steering by Error: Swap bang-bang wiggling for proportional control: steer by how far off the line Spark is, cap it and tune the gain, follow Jo at a steady gap, then glide to the library door.
- PID in Plain Words: Three helpers share the steering: P looks at the error now, I remembers it and D sees where it is heading. Calm a heavy book trolley, make up for a weak motor and stop the total winding up.
- Noisy Sensors and Smoothing: Readings wobble, and some are simply wrong. Smooth a scuffed line so D steers calmly, ignore ghost echoes from a polished floor, and choose how much to trust each reading so Spark still keeps up.
- Wall Following and Maze Solving: Two new side sonars and one 50 cm square at a time. Drive straight by wheel ticks and walls, keep a hand on the wall with a simple rule, and count squares to notice when Spark is going round in circles.