3 Using the line to control the robot

The only sensor information available to the robot is the image from its camera. Remember that the camera is mounted exactly midway between the wheels of the robot so the center of the image corresponds to the location of robot.

3.1 Vertical line down the center of the image

If the image contains a vertical line located exactly down the center of the image then the robot is on the line and moving in the correct direction. We should control the robot to continue moving forward in a straight line.

3.2 Vertical line on the right side of the image

If the image contains a vertical line located on the right side of the image then the robot is to the left of the line and moving parallel to the line direction. We should control the robot to turn to the right to move towards the line. How sharply we turn to the right depends on how far that the line is from the center line (the center line is shown as the red dotted line).

3.3 Vertical line on the left side of the image

If the image contains a vertical line located on the left side of the image then the robot is to the right of the line and moving parallel to the line direction. We should control the robot to turn to the left to move towards the line. How sharply we turn to the left depends on how far that the line is from the center line.

3.4 Line sloping down to the right in the center of the image

If the image contains a line sloping down to the right and in the center of the image then the robot is on the line but moving away from the line. We should control the robot to turn to the left so that its direction matches the line direction. How sharply we turn to the left depends on the angle between the line and the vertical direction of the image.

3.5 Line sloping up to the right in the center of the image

If the image contains a line sloping up to the right and in the center of the image then the robot is on the line but moving away from the line. We should control the robot to turn to the right so that its direction matches the line direction. How sharply we turn to the right depends on the angle between the line and the vertical direction of the image.

3.6 Line sloping down to the right in right side of the image

If the image contains a line sloping down to the right and in the right side of the image then the robot is off of the line but moving towards the line. In this situation we have two competing factors driving the control of the robot: (1) The robot is located to the left of the line so we want to turn to the right to move the robot back towards the line, and (2) the direction of the line is such that we want to turn the robot to the left so that it is travelling in the same direction as the line. Whether we turn left, right, or go straight depends on the angle of the line and how far the line is from the center of the image.

3.7 Line sloping up to the right in right side of the image

If the image contains a line sloping up to the right and in the right side of the image then the robot is off of the line and moving away from the line. In this situation we want to turn the robot to the right. Furthermore, we should turn more sharply to the right than if the line was vertical but in the same location (and if the line had the same angle but was in the center of the image).

3.8 Line sloping down to the right in left side of the image

If the image contains a line sloping down to the right and in the left side of the image then the robot is off of the line and moving away from the line. In this situation we want to turn the robot to the left. Furthermore, we should turn more sharply to the left than if the line was vertical but in the same location (and if the line had the same angle but was in the center of the image).

3.9 Line sloping up to the right in left side of the image

If the image contains a line sloping up to the right and in the left side of the image then the robot is off of the line but moving towards the line. In this situation we have two competing factors driving the control of the robot: (1) The robot is located to the right of the line so we want to turn to the left to move the robot back towards the line, and (2) the direction of the line is such that we want to turn the robot to the right so that it is travelling in the same direction as the line. Whether we turn left, right, or go straight depends on the angle of the line and how far the line is from the center of the image.