Creating the line-following behavior code

This behavior will track the line we drew, driving around it and following its curves. Our line-following behavior can be described with a few simple sentences and then we can build it. Let's assume this code starts with the sensor either side of the line; when it crosses into the line, the robot needs to pull to the side to get that sensor back off it. The next diagram shows the behavior visually:

Robot line-following behavior

The same behavior can be described as follows:

  • The robot starts driving
  • When a sensor detects it is on the line, the same wheel will slow down or go backwards, turning the ...

Get Learn Robotics Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.