Lab 2: Color Images¶
In this lab, you will program the car to respond to images captured by the camera.
You can view the starter code for this lab in the labs directory of your student repository.
Program the car to follow and drive towards objects of a certain color.
Work through the lab 2 Jupyter notebook on the car. This Jupyter notebook will help you experiment with image processing and build up functions that you will need for the main challenges.
Warm Up: Smoother Line Following¶
Open the racecar directory on your computer in Visual Studio Code. The starter code for lab 2 (
labs/lab2/lab2.py) instructs the car to to follow a blue line. However, this implementation is very jerky.
TODO: (warm up) comment with code that allows the car to follow a blue line more smoothly.
Main Challenge 1: Color Priority¶
TODO: (challenge 1) comments with code that allows the car to follow lines of the following colors with the following priorities:
- Red (highest priority)
- Blue (lowest priority)
For example, if the car sees a red, green, and blue line at the same time, it should follow the red line. The car should only follow a blue line if it does not see any red or green lines.
Main Challenge 2: Cone Parking¶
TODO: (challenge 2) comments with code that allows the car to drive up to an orange cone and stop 1 meter in front of it. If the car is not pointing directly towards the cone, it should steer towards it. If the car is too close to the cone, it should back up. If you pick up the cone and move it, the car should follow the cone.