# Practical Exercises

You may do these practical sessions in groups of two or work through them on your own.

The practicals will be held in 233R.

You should also read through the description of the practical exercise and print out and read any additional material supplied before the class.

### Exercise 1

I will give you code (a cut-down version of the code we use for our RoboCup team). Exercise 1 is to the compile the code, run it, and then write your own version of MyBehavior.cc, which makes use of at keast five of the pieces of behavior in BehaviorFunctions.cc.

You should hand in a copy of your version of MyBehavior.cc

### Exercise 2

Exercise 2 is an exercise in dead-reckoning navigation, and the use of odometry. The exercise replicates the work of Borenstein. There are two parts:
1. Write code that has the robot walk in a square, 3 feet on each side. Thus the robot should start by walking in a straight line for 3 feet, turn through 90 degrees clockwise, walk another 3 feet in a straight line, turn another 90 degrees clockwise, and so on, until it has turned through 360 degrees and walked back to its starting point.

The aim of the exercise is to minimise the distance that the robot ends up from its starting point.

Run 10 trials of your code, measuring the distance between where the robot ends up and its starting point, and recording the components of this distance in the direction the robot started walking (the x direction) and orthogonal to this (the y direction). It is important to distinguish positive and negative x and y measurements.

2. Repeat but have the robot walk in a square 6 feet on each side.
You should hand in copies of MyBehavior.cc for both parts of the exercise, plus a plot of the error in the position of your robot at the end of its two walks.

### Exercise 3

Exercise 3 is an exercise in using vision along with dead-reckoning. There are two parts:
1. Write code that has the robot look for the ball, which should be about 6 feet from the robot, and then walk to the ball. When the robot is at the ball, it should turn and walk back to where it came from.

The aim of the exercise is to minimise the distance that the robot ends up from its starting point. As in the previous exercise, record the components of this distance in the direction the robot started walking (the x direction) and orthogonal to this (the y direction). It is important to distinguish positive and negative x and y measurements.

Run 10 trials of your code, measuring the distance between where the robot ends up and its starting point.

2. Repeat but mark the final position of the robot with a second ball (so that the robot can see where to walk to).
You should hand in copies of MyBehavior.cc for both parts of the exercise, plus a plot of the error in the position of your robot at the end of its two walks.