Goals & Results

Statement of Goals

At the start of the project, we identified four goals.

1. Learn to connect to the PiCar robot

Our first goal was simple: we needed to connect to our PiCar robot, Prince. Initially, progress was slow, since we had to plug Prince into a monitor, keyboard and mouse every time we wanted to use him. We eventually settled on two complementary remote-access methods that worked side by side. SSH was the bigger workflow win, because multiple group members could open shells into Prince at the same time. One person could be editing or running scripts while another tailed sensor logs and a third pushed file changes, without anyone having to take over a single shared GUI. When we did need to see the desktop (mostly for the calibration utility) we used RealVNC Viewer to screen-mirror the Pi. We did most of our coding on our personal laptops and pushed files over to Prince with Cyberduck (SFTP), then SSH'd in to run them. Claude Code helped along the way with debugging and writing parts of this site.

2. Test and understand the hardware

Once we were familiar with the Pi operating system, we wanted to test our hardware. We wrote dedicated test scripts for the camera, the wheels and steering, and the grayscale sensor channels we would later use for line-following.

3. Begin the robot's calibration

Our next step was getting Prince ready for the line-following program. We wrote an early calibration script focused on giving the robot a consistent, repeatable starting state: zeroing the steering servo, centering the camera pan and tilt, and setting up offsets we could load back in later.

4. Develop and test a successful line-following program

Our last goal was the biggest. We took everything we had learned and built a line-following program based on a PID controller (KP=20, KD=5, with the integral term left at zero) running at roughly 50 Hz, with dynamic speed reduction on sharp turns. This was by far the longest part of our work. The hardest case was 90° corners that bent sharper than Prince's turning radius. He would usually overshoot and lose the line entirely. The breakthrough was recognising that on this track, when the line is lost it is almost always behind the car, not in front of it. So our recovery logic reverses first, then sweeps to re-acquire. Recovery is split into two modes: a gentle “drift” mode for small errors (mostly straight sections), and an aggressive “corner” mode for large errors (sharp bends). With the reverse-first recovery in place, even the runs where Prince originally lost the line at a corner usually ended with him backing up, finding the line again, and continuing.

Intersections were a separate problem. The code can detect when all three sensors go dark, but our earlier attempts to actively drive straight through that condition produced too many false positives at corner elbows, which look identical to a real intersection from the sensor's point of view. In the final code the intersection handler is disabled (ENABLE_INTERSECTION_HANDLER = False), so an “all dark” reading is allowed to fall through to the corner-recovery path instead. That was the right call for this track, which had no real intersections, only sharp bends.

As a finishing touch we added a small audio loop that plays a regal, royal-themed track while Prince is on the line, fading down whenever he loses it. It made testing genuinely fun rather than tedious, and it's audible on the music-and-crown clip in the media page.

Results

Goal Status Notes
1. Learn to connect Achieved SSH for parallel shell access plus VNC for desktop work, with Cyberduck (SFTP) for pushing files.
2. Test hardware Achieved Wrote dedicated test scripts for the camera, wheels/steering, and grayscale sensor.
3. Calibrate robot Achieved Per-sensor thresholds and a measured steering trim (-6) saved to disk and loaded at startup.
4. Implement line following Partially achieved PID line-following with reverse-first recovery handles straights, curves, and most 90° corners. Intersection handling is detected in code but disabled, since corner-elbow false-positives were better routed to recovery.