Software apps and online services
This team project for ELEC 424 at Rice University was to design an autonomous lane keeping RC/toy car. The objective for this project is to build a car that follows blue lanes, stops at the stop signs and responds to the traffic light. This project is built based on wonderful previous works as below
User raja_961, “Autonomous Lane-Keeping Car Using Raspberry
Pi and OpenCV”. Instructables. URL:
PWM control for beaglebone black: https://learn.adafruit.com/setting-up-io-python-library-on-beaglebone-black/pwm
So, our car follows the blue lane. While it is moving, it stops at the red traffic light and remains stopped until the green light is turned on. As well as, it stops at the stop sign on the ground for 2.5 seconds.
In each iteration of the loop, we capture a frame and compress it to a lower resolution by 80x40 (width and height) to speedup image processing. This enhanced the car's performance a lot by reducing latency. Then we convert it to HSV format for color detection. We recognized the blue regions and used the Canny algorithm to detect edges of the lane.
Our program also detected red colors. Once it finds that the red pixels in the frame exceed a certain threshold (10 pixels), it will take the red region as the red traffic light or stop region. Then it will stop by resetting the speed PWM to the baseline. The green color detector will only be enabled if the car stops before the traffic light. Once the traffic light switches from red to green, the car keeps going by giving a larger PWM input. So, for the “traffic light” the car stops until it detects a green light while for the “stop signs” it stops for 2.5 seconds.Steering control
For the steering control, we used variables called “deviation” and “error” from the original code. In our case, the best threshold for going straight was 15. So, if the “deviation” is under 15 and over -15, the car goes straight. If the “deviation” is over 15 or under -15, it changes steering linearly based on the “deviation”. To do this we mapped deviation to the steering PWM input using “out = 7.3 - deviation * 5 / 80”. 7.3 was due to the calibration with the RC car. Constant 5 and 80 is the steering range and steering angle of the servo motor, respectively. The performance based on linear mapping was enough to control steering so we did not implement PID control for steering.Speed control
In our speed control method we design it to be tunable from one number based upon the variability of the batteries, this number is fed into the other numbers that are tuned for controlling the speed. We created three parts to control speed. These parts are controlling the car while it’s going straight, soft turns and hard turns. We found that this method works best for our cars sensitive to how fast openCV detects the lane.