Notebook 08 part 1

# Lab Notebook

Date: 12/04 2012
Group members participating: Falk, Jeppe and Jakob
Duration of activity: 4 hours

## Goal

Build a robot that follows the Alishan train track and wins the Robot Race.

Rules of the track [1]:

• The car must start from the start area. No part of the car is allowed to exceed the start area.
• A push on ENTER starts the car and the car should then follow the track to the retrace area, the top platform. From the retrace area the car should drive back until the car drives into the start area again. When the car is in the strart area again it should stop and time elapsed since start should be shown in the LCD. The car should be completely inside the start area before it stops.
• When on the top the car should be completely inside the retrace area before going back.

## Plan

Instead of the standard car a customised robot car was built. The plan was to make it fast and robust.
The robot uses two light sensors in the front pointing to the ground.
The program is designed as a state machine where every part of the track corresponds to a state.

### The state machine

The robot uses two light sensors in the front pointing to the ground. It is designed as a state machine

1. Drive straight ahead out of the green zone (the robot has to be aligned properly)
2. Follow the black line until both sensors see black
3. Turn right
4. Follow the line until both sensors see black
5. Turn left
6. Follow the line until both sensors see black
7. Drive straight ahead for some time (to cross the black line)
8. Do a 180° turn
9. Drive straight ahead for some time (to cross the black line)
10. Follow the line until both sensors see black
11. Turn right
12. Follow the line until both sensors see black
13. Turn left
14. Follow the line until both sensors see green
15. Drive straight ahead for some time and stop

## Results

• Before driving, the two light sensors are calibrated. During calibration for each of the to sensors a black-white and a green-white threshold is computed.
• A simple line follower using two sensors was implementedthreshold = (black + white)/2 + (white - black)/4
• To turn the robot by a certain angle (i.e. 180° to turn it around on the top platform) the method Motor.X.rotate was used. It only works if the TachoCount is reset beforehand.
• In the same way, the robot is set to drive a certain distance to come out of the green start zone.
• On the platform the robot failed to turn and follow the line. The reason was that the measurements of the sensors are different at the slope and the platform, so the threshold values computed before do not work. To solve this problem the thresholds have to be adjusted. With $\text{threshold} = \frac{\text{black} + \text{white}}{2} + \frac{\text{white} - \text{black}}{4}$ the robot kept following the line.
• Another problem was, that if the robot was driving to fast towards the curve, it moves past the two black lines and does not turn. To solve this, the robot was set to slow down after the distance of the slope (using Motor.X.getTachoCount to estimate the distance driven)

## Results

Since there were that many problems with this approach and with all the different states and substates the program became very confusing [2]. Especially detecting the curves with the two-sensor approach was a real problem.
The notebook continues with a new approach here.