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.
Use the color camera to recognize and respond to objects of certain colors.
Work through the lab 2 Jupyter notebook (
labs/lab2/lab2.ipynb). This Jupyter notebook will help you experiment with image processing and build up functions that you will need for the main challenges.
See Using Jupyter for instructions on how to use the Jupyter Notebook with RacecarSim or a physical RACECAR-MN.
Lab 2A - Line Following¶
Open the racecar directory on your computer in Visual Studio Code. The starter code for lab 2A (
labs/lab2/lab2a.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.
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.
Lab 2B - Cone Parking¶
The starter code for lab 2B (
labs/lab2/lab2b.py) has similar helper functions to lab 2A, but it currently has no instructions for moving the car. Replace the
TODO: comment with code that allows the car to drive up to an orange cone and stop 30 cm 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.