... | ... | @@ -132,4 +132,20 @@ while (! Button.ESCAPE.isDown()) |
|
|
}
|
|
|
```
|
|
|
|
|
|
##### Fig. 7: inner loop of the line follower PID-control class. |
|
|
\ No newline at end of file |
|
|
##### Fig. 7: inner loop of the line follower PID-control class.
|
|
|
|
|
|
One main problem we encountered when first implementing the PID-controller was that the power to the motors could turn negative and cause the motor to drive backwards. To overcome this issue we made a simple if statement that only allowed a call to the drive function if the power values are positive. The next step was to tweak the PID values to follow the line precisely.
|
|
|
|
|
|
#### Tweaking values using a GUI
|
|
|
As the sensors on the robot require a lot of tweaking, we implemented a GUI to transfer values to the robot on the fly (see fig. 8). This was particularly helpful when tuning the PID controller values, as we did not have to hardcode the values directly to the nxt program. Additionally we implemented an ‘offset’ (O) and ‘target-power’ (TP) value transfer. The offset indicated the desired light-level to oscillate between, and the target power was used to increase the robot’s base speed. A video of the robot using the PID-controller to follow the black line can be seen in fig. 9.
|
|
|
|
|
|
![GUI](http://gitlab.au.dk/uploads/group-22/lego/9c27179ca8/GUI.jpg)
|
|
|
##### Fig. 8: Showing the GUI used to tweak the PID controller, the ‘offset’ and the ‘target-power’ on the fly.
|
|
|
|
|
|
[![image alt text](http://img.youtube.com/vi/9fMrdV1WR5A/0.jpg)](http://www.youtube.com/watch?v=9fMrdV1WR5A)
|
|
|
##### Fig. 9: A video showing the robot following a black line using the PID-controller.
|
|
|
|
|
|
#### Getting around the bends
|
|
|
To get the race car around the bends, we decided to hardcode a turn which would be triggered if the light sensor read a series of white readings. This caused some issues as the robot guided by the PID controller would reach the bend at different positions and thus the hardcoded turn would not always line up correctly and reach the next part of the ramp at the right angle. If the robot turned too little, it would simply miss the black line and drive of the side of the ramp.
|
|
|
|
|
|
This finding has lead us to the conclusion that we need to add another sensor. We think that a gyro sensor could better detect the change in the angle of the slope on the ramp so the next experiment is going to incorporate this. |
|
|
\ No newline at end of file |