Software apps and online services
Our project is a self-driving RC toy car that uses a BeagleBone AI to recognize the lane marked in blue tape and control the steering direction, stopping at each of the two red stop markers.
The final resolution of the camera (100 x 75) was already set up in the starting script that we were provided. Previously we were using 480p, but the frame rate was far less than optimal. We found that at 100 x 75, our BeagleBone AI board was much more responsive and decided on this resolution.
The proportional and derivative gains for servo rotation were also already set up in the started code and worked out of the box for one track. For the other track, the car might go out of the track with the same parameters. We then stepped through the gains to determine the best one for this track.
We had a lot of 0's in our data because the track we used was wider than the car. When the car was at the right center of the track, the camera was too close to the ground to capture the two blue lines. In this scenario, the error would default to zero. This decision makes sense because if our car is at the center of the track, then there is no need to correct for the error.
For maintaining speed consistency, we also used a proportional/derivative gain system. We started with the same gains as the steering system, but it (unsurprisingly) didn't work. So we plotted the speed encoder's data in the CSV files generated by our python program, and then with trial and error, we chose the desired parameters.
We can see that the speed was actually fluctuating around our target value, ten million. If we were to implement a full PID with an integral, this fluctuation would go away.Stop Sign Detection
The two stop boxes were handled simply by checking if the number of red pixels was above a certain threshold. Additionally, for the 1st stop box, we set a delay before we re-checked for the stop box (the delay in the original starter code was not enough, so we had to increase it). From there, it was enough to count the number of times a stop box was encountered, and our car could stop at the 2nd one for good.How to Run the Code
First, we need to install the speed encoder's driver. Then, the PWM must be initialized. Finally, run selfdrive_py.py. Note that we used VideoCapture(0) as the camera object in Python; if testing on a different device or configuration, then you may need to change the index.Demo