Line following algorithm¶
-
void
followUntil
(Robot &r, float distance, linefollowTerminator *terminator = & until_junction)¶ Follow a line until an event.
For example:
followUntil(robot, 0.6, until_junction) // follow the line to a junction 60cm away followUntil(robot, 0.2, until_xjunction) // follow the line to a cross-junction 20cm away followUntil(robot, 0.2, until_bumper) // follow the line until the bumper is pressed 20cm away followUntil(robot, 0.2, NULL) // follow the line for exactly 20cm
- Parameters
r
: A reference to a Robotdistance
: The expected distance to drive, in meters, before the event occursterminator
: A function taking(Robot&, const LineSensors::Reading&)
that returns true when the robot should stop. If NULL, stop afterdistance
has been travelled
- Exceptions
LineLost
: The target line couldn’t be found, recovery failed.Timeout::Expired
: It’s taking more than 25% longer than expected to reach the target
-
void
turnAtJunction
(Robot &r, int turns, bool goForward = true)¶ Turns the robot at a junction.
- Parameters
r
: A reference to a Robotturns
: The number of 90 degree turns to go through, counter-clockwise being positive.goForward
:false
if the robot already has its wheelbase over the junction
- Exceptions
LineLost
: The target line couldn’t be found, recovery failed.