Learn 4: Experiment With Color Sensing
5. Demo: First, Line Follower
Now that we’ve calibrated both sensors, let’s make our robot follow a line until it either loses that line or identifies a given color, then turn around and come back.
In the Main Code cell we have provided you with a copy of the basic proportional line following algorithm from the Robot Operations Manager mission, with the following minor changes made:
- The code has been placed inside a main() function.
- The init() function has been removed (it's now called in the Interactive Control Code cell).
- A global declaration for our variable container instance (var) has been added and the courier’s state has been reset using the reset() function that we wrote.
- References to picker have been replaced with courier.
- We’ve also added a stopping condition that is linked to the Emergency Stop button.