Exercises
This code is fun, but there are many ways you could improve the behaviors. Here are some suggested ways to extend this code and deepen your learning:
- Use the control pipeline to allow a user to tune the color filters, correct radius, and PID values from the web page. Perhaps the initial PID values should be close to the other tunable values?
- There is quite a lot of setup code. Could you put this into a function/method?
- Could the queues to the web page be used to send the debug data to the page, instead of printing them in the console? Could the data be plotted in a graph?
- The field of view for tracking with the Pi Camera is pretty narrow. A wide-angle lens would improve the field of view a lot, letting the robot see more.
- The camera doesn't perform too well when it's dark. The robot has an LED strip, but it's not illuminating much. Could you add a bright LED as a headlamp for the camera?
- You could track other objects by trying the...