0

Soccer Robot C - Basic lessons - Exercises - Stop on any line

Another exercise inspired by RCJ Soccer.

Task: if any transistor detects line, stop the robot.

Start the robot in direction of 137°. Do not allow it rotate about vertical axis. As soon as any transistor detects a white line, stop the robot. The code to maintain rotational position is here.

void RobotSoccer::loop() {
	static int initialDirection;
	if (setup())
		initialDirection = heading();

	int error = heading() - initialDirection;
	go(0, 0, error);
}