The line follower used a Raspberry Pi camera to detect the line
The car uses a Pi Camera to detect certain colors and follows the tape.
PID controls were used to correct the pathing of the car when it faced turns or deviated from the tape.
A 6V battery pack powered the motors and the Raspberry Pi was powered by a portable charger, allowing for the robot not to require outside sources of power to drive
This project aimed to build a line-following robot that uses a Pi camera to track different colored tapes. Initially, a grey-scale program was used for testing to ensure the car could decide based on reading color values. After the car successfully was able to change directions based on when it read the tape, the Raspberry Pi was switched to read HSV colors from the tape and only look for HSV values in a specific range. Once the Pi could detect specific colors, PID controls were implemented to change the motor speed as the camera read the error from the mean value of the tape. By fine-tuning the K values, the car completed a complicated track. However, the Pi faced calibration issues with the lighting and was inconsistent with the difficult track. Therefore, the final track attempted was the simplest for consistency with reading the HSV values and PID controls.
When initially designing the car, one concern was the motor wire placement, as the motors needed to be below the car for the camera to be at the correct height. Therefore, a gap was created in the car to allow the wires to go through the car and be connected to the motor drive
When initially testing the PID controls, there were instances where the PID value was negative when correcting to one side. To resolve this issue, the absolute value of the error was taken, and manual turning values were put in the code so the motors would turn in the correct direction.
Another issue with the PID controls was when the PID value would be less than the minimum motor PWM values when the camera was on the tape. To resolve this, the PWM was set to a constant value if the car was going straight, and the PID value was less than 35, the minimum PWM value.
Top view of car
Back view of car
Car driving the red track before PID controls and HSV reading were implemented
Car driving the purple track with initial PID controls and HSV values
Car driving the orange track after PID controls were fine tuned to not overcorrect
Car driving the pink track after correct HSV colors were found
To improve, the car could have been fabricated more efficiently. Although the car was able to complete the task, it was bulky and used up significant excess space. To improve, the car could have been more compact with the batteries having designated places inside the car to minimize space. Although this would not significantly impact the car's performance, a more compact frame would allow it to travel faster by reducing the load on the motors.
Another improvement would be to improve the HSV color range detection. In the current code, the user would have to manually check the HSV values and correct the range within the code. If the car had an auto color detection system, it could first collect the color range before driving the specific color. This would save time for the user by not having them manually change the HSV range. Additionally, this would allow the car to travel on different color tracks without needing to change the internal code.
Wires from motors were connected to Pi through an opening in the back
Motors were attached with 3D printed motor holders
The Raspberry Pi had a laser cut holder to prevent the Pi from moving while the car turned