Teaching a robot to stay in its lane
HSV thresholds, lane offsets and an ultrasonic conscience on ROS 2.
Placeholder draft; replace with the real post.
The robot is a Freenove 4WD car on a Raspberry Pi running Ubuntu 24.04 and ROS 2 Jazzy. The pipeline is almost embarrassingly classical: segment the lane in HSV, compute the offset from centre, steer proportionally, and stop when the ultrasonic sensor says something is closer than it should be.
Classical first
Before reaching for a learned policy, the HSV threshold got me 90% of the way, and when it fails, I can see why in one OpenCV window instead of a loss curve.
What broke
Sunlight. Every lighting change moved the lane out of my carefully tuned thresholds, which is the day I finally understood why people train models.