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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.