The hardest bug: a smarter controller that stalled the motors
Two cheap motors never spin at exactly the same speed, so a robot told to go straight drifts. I added wheel sensors and a feedback controller (a PID controller) that pushes harder on whichever wheel falls behind.
It worked until the robot turned. The controller asked for so much current that the supply voltage sagged and a motor stalled, and the robot stopped dead.
The fix was to let a simple model of each motor supply most of the power (feed-forward) and keep the feedback controller for small corrections only. The robot stayed stable, in exchange for slightly less precise steering. The earlier firmware versions show each step.





