Goal
Our goal this week was to build and program a robot which would "win the race", ie a robot that follows a line as fast as possible. We took this challenge to mean that the robot should be able to follow any given line (black on white background) from one end to the other as closely as possible and in as little time as possible.
Plan
Our hypothesis was that we could accomplish this with a robot design based on a modified version of the standard robot as described in the NXT set manual. That is, a robot with two powered front wheels controlled by independent motors which manoeuvres the track by applying varied torque to each of the powered wheels. We would add a set of front-mounted light sensors to sense the lay of the track.
Experiments, results, revision
In early experiments with the standard robot chassis, we felt that for a cheap increase in speed we might simply exchange the standard wheels with much larger ones. Results of this modification were largely as expected, save that the reconstruction forced us to lower the unpowered rear wheel to match the height of the new wheels. Speed increase was not overwhelming, but we decided to stick with the larger wheels in future experiments.
The standard line following car as described in the NXT manual has only one light sensor, which meant that a "bang-bang" mode of control had to be employed. We hoped that adding a second light sensor would enable us to control the car in smoother movements.
Results of the modification were positive: The car now had two light sensors, mounted to take readings on either side of the track. The idea was that the car would be able to detect when it was directly over the track (both sensors reading white) and thereby gain a speed increase on long straight segments.
Further testing, however, showed that this speed increase would send it too far out in relation to the track. The car would end up oscillating back and forth across the track, increasing angle of entry each time, leading to more oscillation. Much like the original bang-bang controller.
In essence, we had simply added a third "bang" for straight segments, still a quite unsophisticated method of control.
Experiment: Adding a third sensor
To approach a more analogue steering method we had the idea of introducing a third light sensor, set some distance forward of the first two. This light sensor would detect the lay of track ahead of the robot. Through this additional knowledge of upcoming curves and straight segments we would be able to construct a control program that would be more sensitive to changes in the track, the idea being that we would thereby avoid sending the robot careening out across the edges.
In addition to this change, we would attempt a more state-based control program. We would "remember" the last state and act according to this. With the 3 sensors we now knew on which side of the line we were, even when they all read white. This was accomplished by saving which of the left and right sensor last saw black.
Final program
In our final code we had made a class "ColorSensors" which had 3 booleans, each one saying if a colorsensor was black. It also had a boolean for checking if all sensors saw blue. These were updated in every with a call to update(). It also came with its own calibration program, so we could store what was black, white and blue in the light we were in at the moment.
Now, the only thing the main program had to handle was to call update, and else act acording the the following cases:
- Middle sensor black and the two other white

This means we are on track, and give it full speed
- Two sensors black
We are on a slight curve, and choose to speed down left motor, to turn left. As we only turn slightly means our car doesn't go too far off the line on the other side
- One side sensor black

The curve is shaper thus we have to turn even more
- All sensors white
Here we act acording to the last sensor which was black.
If the left one was black, we make a sharp turn to the left. Opposite for right.
If the last reading wasn't one of these 2, we slow down. The option could happen at a sharp curve, as our front sensor was further ahead than the two others. In this case we slowed down, as we soon had to do a turn, and thus would be faster reacting when we knew what to do.
While not entirely analogue, this method has enough different cases that we feel that the robots motions will be adequately smooth, avoiding unnecessary oscillation.
Results
Results of this final modification were very positive. When properly calibrated the robot would adjust its speed in accordance with the cases above to take turns with great precision and speed. The calibration was a sticking point, however, as the performance hinged greatly on the threshold values for black and white that had been set for each light sensor. Taking readings, altering code and recompiling soon proved tedious, and we implemented a simple function that would allow us to take readings of black and white values before each execution of the race program.
public void calibrateBlue() {
NXTBlueThreshold = (int)((left.readValue() + right.readValue()) / 2);
RCXBlueThreshold = middle.readValue();
Sound.playTone(500, 20);
}
With this system in place we were able to shave out time to about 20 seconds for the entire track.
As far as our original goal was concerned, we had two practical measures of success: The time the robot took to complete the track and the degree to which the robot followed the line. It is difficult to set a hard target for both of these measures, especially since one is usually inversely proportionate to the other. In both aspects, we found our robot adequate to our original goal.
Conclusion
The results of our robot were satisfactory only in the sense that they met our expectations to the original design strategy. Shaving further seconds off our final time, we feel, can at this point only be accomplished be changing the fundamental workings of our design.
Having observed the results of the other groups participating in the course, such changes might be a speed increase through gearing or the inclusion of differential steering, which would allow for much smoother turns.
Given more time, our immediate strategy would be to redesign the robot to use improved gearing and differential steering, and we did in fact make such an attempt at the eleventh hour of the race. Unexpectedly, we failed to make the deadline and abandoned the project before the robot became fit for competition.
Conclusion
The results of our robot were satisfactory only in the sense that they met our expectations to the original design strategy. Shaving further seconds off our final time, we feel, can at this point only be accomplished be changing the fundamental workings of our design.
Having observed the results of the other groups participating in the course, such changes might be a speed increase through gearing or the inclusion of differential steering, which would allow for much smoother turns.
Given more time, our immediate strategy would be to redesign the robot to use improved gearing and differential steering, and we did in fact make such an attempt at the eleventh hour of the race. Unexpectedly, we failed to make the deadline and abandoned the project before the robot became fit for competition.
0 comments:
Post a Comment