Tuesday 31 May 2011

Line tracking: software part

After successful fixing encoder problem we had two sessions: on Saturday May, 28 and on Monday May, 30. As a result we made a good progress in line-tracking assignment. Hereby I will give short explanation of software part.

We decided to use Master-Slave architecture. It means that two bricks will use different code. Master brick will make main computational work. Slave brick will receive information from sensors and transfer it to the Master one.

It is useful because for Lake finding assignment we will use communication between bricks as well as with Earth computer. Therefore we decided to use com.c library and studied threading and semaphores in BrickOS environment.

Slave brick has a very simple programme. It reads values from three light sensors and rotation encoder. Then it activates thread for reading information from IR port, initializes it and sends values to Master brick which has certain ID

Master brick consists of four motion control functions such as move(), stopDriving(), stopSteering() and steer(int angle). Next service function is init() which initializes all sensors. The function isObstacle(int sensor, int trigger) determines whether rover is on the line or outside it. Finally, main(int argc, char **argv) function realizes main logic of assignment.

Main idea is as follows. Initially light sensors determine contrast values of tape and table. These values are stored and continuously compared with new values obtained from sensors. If there will be detected that sensors are outside tape then immediately direction of movement is calculated and motors steer to the necessary direction according to necessary angle. In order to keep on track forward movement is stopped then rotation is performed. As soon as necessary angle is achieved forward movement is continued in order to return to track. When it happens steering angle adjusted to zero in order to perform straight movement. Otherwise, rotation and steering continued.

Meanwhile, encoder sends information about rotations and this information is transformed to the distance covered by rover. This distance is supposed to be the line length and indicated on LCD of the brick.

As a result, we get "slalom-style" movement which allows rover to keep on the line no matter how curvy it is.

No comments:

Post a Comment