Autonomous PiCar
An autonomous Raspberry Pi-based vehicle featuring real-time PID motor control, computer vision, ultrasonic sensing, and accelerometer-assisted steering.
Overview
The Autonomous PiCar is a Raspberry Pi-controlled vehicle that drives, tracks objects, recognizes traffic-light colors, and holds a stable speed under closed-loop control — combining motor characterization, PID tuning, computer vision, ultrasonic sensing, and accelerometer-based steering correction into one autonomous system.
Highlights
- PID motor control: characterized the PiCar’s open-loop motor behavior (PWM duty cycle to rotational speed), built a feedforward baseline, then tuned proportional and integral gains separately for suspended-wheel testing and ground driving — ground driving required more aggressive gains to overcome rolling resistance and static friction.
- Vision-guided target seeking: RGB frames from the Pi Camera are converted to HSV and filtered into binary masks to isolate a blue target, calculate its center of mass, and steer toward it in real time.
- Traffic-light-responsive driving: separate HSV masks detect red, yellow, and green, driving distinct behaviors (continue / slow down / stop), backed by an emergency-stop distance threshold regardless of detected color.
- Sensor fusion for stability: ultrasonic distance sensing handles collision-avoidance braking, while accelerometer/gyroscope data corrects heading drift to keep the vehicle driving straight.
Future Improvements
Although the current prototype is fully functional, there are several improvements I would like to explore.
- More robust frame-handling to fully eliminate dropped-frame stalls under real-time load
- Adaptive HSV thresholding that self-corrects for changing lighting instead of fixed bounds
- Closed-loop speed control that reacts to terrain changes mid-drive, not just at calibration
- Combining ultrasonic and vision data for earlier obstacle detection instead of treating them as separate systems
What I Learned: This project showed me how tightly control systems and computer vision have to work together in a real autonomous system — tuning PID gains, filtering noisy sensor data, and building reliable OpenCV masks all had to hold up simultaneously, not just individually, for the car to behave predictably.
Demonstrations
Target Seeking


Autonomous target-seeking demonstration.
Traffic Light Recognition




Traffic-light response demonstration.