Implementation Plan and Debugging
Implementation Plan and Debugging
Debugging:
Construction of the robot was very simple and conventional. Only a single light sensor
and a touch sensor were mounted on the same base frame and connected to input 2
and 1 respectively.
At first, EYE sensor, LEFT, RIGHT and TOO BRGHT/DARK values were defined. (#
define). Following Jims instructions given in class, I knew I had to use four tasks. A
main task, which would allow other three tasks to work. The other three tasks were:
1: Line Following task: This task made the robot follow the black line. All principles for
this task were learnt by me as they were used in the previous assignments. I used a
single light sensor to judge the grey part of the line by using threshold values for too
dark or too bright areas. Coding for this part was easy and gave no problem in
implementation. The commands written were all correct from the beginning, but I spent
few minutes writing the correct values of TOO DARK and TOO BRIGHT.
2: Turn around task: This task made the robot turn around after hitting the red brick and
again follow the line. I used bumpbot 1 bumper for this task. This type of bumper is not
as good as fall-off bumper, but was reliable in reading the value of the sensor and
easier to construct. I gave the robot enough turn time to come back to the line I wanted
it to. This task also required me to stop line following task for the robot to back up and
then restart line following task. I also placed sound so I could be confident that the task
was followed.
3: Stop on green task: This task made the robot stop on the green patch. My language
included a currentTick (also learnt from previous assignments). While in green patch,
the CurrentTick was put equal to t3. Until was used so that if the robot is not in the
green area for the required time of .2 seconds, it would let go the CurrentTick value. If
the robot stayed in the green area for .2 seconds (using CurrentTick()-t3), the motors
would turn off. I also put in a tone for assurance. This task also stopped other two tasks
to stop further line following by the robot.
This task took hours before it could be debugged. First off, long t3 had to be defined
after several compilation tests. It took several minutes to write correct reflective light
values in the frame.
Compiling all tasks together:
Compiling these tasks together gave me several errors. At first, I had to match up the
correct numbers of parenthesis and brackets. Task main was used to set up sensors
and give command to all three other tasks to work at the same time. Later, I realized
that line following and turn around tasks were working fine, but the Stop on green task
was not working at all. I used a PlayTone code which further indicated that it was not
working. After several minutes of troubleshooting I found a silly mistake in my coding. I
missed the statement while (true) for this task which meant that the task was followed
only at the start and then never followed again.