0

Line Robot - Basic lessons - Exercises - Avoid exit

One of the many exercises which will help You to program RCJ Rescue Line.

Task: avoid exiting evacuation zone.

Follow right wall in RCJ Rescue Line evacuation zone, but do not exit it. Base Your code on a combined wall-following example (compiled from 2 lessons):

void RobotLine::loop() {
	if (frontLeft() < 90)
		go(-50, 50);
	else{
		int error = (rightFront() - 100) * 0.5;
		error = constrain(error, -50, 50);
		go(50 + error, 50 - error);
	}
}