From oscillation to super smooth: how to tune Kp, Ki and Kd while your robot actually runs — on the track, not just in theory.
Every line-follower starts the same way: maybe 20-30 cm/s, a nervous wobble at every corner, and a motor that screams when it thinks it lost the line. Then you add your first PID and the robot develops a new hobby: vibrating in place.
The key is to tune on the robot, not in theory. Set Ki and Kd to zero, raise Kp until the robot oscillates, then back off to about half. That single step kills most of the wobble and gives you a loop you can actually steer.
From there, Kd does the heavy lifting on sharp corners — it dampens the overshoot so the robot can carry more speed into a turn. Add it incrementally and watch the corner where the oscillation used to start.
Finally, a tiny bit of Ki fixes the steady-state wander on long straights. Keep it small; too much integral and the robot hunts after every bump on the track.