0

Soccer Robot C - Basic lessons - Exercises - Playfield center

An exercise useful for goalkeeper in Robocup Junior Soccer.

Task: go to center of the playfield.

Move the robot just left - right and position it in the center between 2 walls 182 cm apart. However, do so only if at least one side has a free space of 81 cm (half of 182 minus robot's diameter of 10 cm) and assume that it is a wall in that case. Otherwise assume there are other obstacles and do not move. Use code for maintaining a steady direction:

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

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