... | @@ -14,17 +14,18 @@ The goal for the day is to test whether it is possible to follow the Alishan tra |
... | @@ -14,17 +14,18 @@ The goal for the day is to test whether it is possible to follow the Alishan tra |
|
|
|
|
|
## Plan
|
|
## Plan
|
|
|
|
|
|
The plan is to conduct various tests to see how the gyroscope behaves when driving on the Alishan track. This data will then be used to make a control the car.
|
|
The plan is to conduct various tests to see how the gyroscope behaves when driving on the Alishan track. This data will then be used to control the car.
|
|
The control strategy for the car is to make the car drive forward until it reaches the first plateau, which is sensed by the gyroscope. On the plateau the car should turn 180 degrees to the right and drive forward until the next plateau is reach and so on.
|
|
The control strategy idea for the car is to make the car drive forward until it reaches the first plateau, which is sensed by the gyroscope. On the plateau the car should turn 180 degrees to the right and drive forward until the next plateau is reach and so on.
|
|
|
|
|
|
## Gyro Offset Test
|
|
## Gyro Offset Test
|
|
|
|
|
|
### Setup
|
|
### Setup
|
|
The gyro sensor is placed on the Lego car as shown in the picture below, and both motors are set to full power, while the car is turned upside down. This is down, to test what effect the motor have on the gyro offset.
|
|
The gyro sensor is placed on the Lego car as shown in the picture below, and both motors are set to full power, while the car is turned upside down. This is down, to test what effect the motor have on the gyro offset.
|
|
The gyro measurements are saved using a datalogger. The source code is found in [TODO!!!].
|
|
The gyro measurements are saved using a datalogger. The source code is found in [TODO!!!].
|
|
INSERT PICTURE
|
|
|
|
|
|
|
|
|
|
|
|
|
|
![Lego car with gyro sensor attached.](https://gitlab.au.dk/rene2014/lego/raw/master/Lesson8/Images/LegoCarWithGyro.jpg)
|
|
|
|
|
|
### Results
|
|
### Results
|
|
In the figure below the raw gyro values are shown. Note that the big offset in the first second is due to pressing the enter button. The measured gyro values are quite varying even though the car is lying still. Therefore an exponential filter is applied to the gyro values.
|
|
In the figure below the raw gyro values are shown. Note that the big offset in the first second is due to pressing the enter button. The measured gyro values are quite varying even though the car is lying still. Therefore an exponential filter is applied to the gyro values.
|
|
The filter have the form:
|
|
The filter have the form:
|
... | @@ -33,7 +34,7 @@ The filter have the form: |
... | @@ -33,7 +34,7 @@ The filter have the form: |
|
The filtered gyro data is shown in the lower part of the figure below.
|
|
The filtered gyro data is shown in the lower part of the figure below.
|
|
![Upper part: Gyro measurements with both motors turned on at full power. The car was places on the back and did not move. Lower part: Filtered gyro measurements with an exponential filter.](https://gitlab.au.dk/rene2014/lego/raw/master/Lesson8/Images/GyroDataNoMove.png)
|
|
![Upper part: Gyro measurements with both motors turned on at full power. The car was places on the back and did not move. Lower part: Filtered gyro measurements with an exponential filter.](https://gitlab.au.dk/rene2014/lego/raw/master/Lesson8/Images/GyroDataNoMove.png)
|
|
|
|
|
|
The filtered data does not have the same spikes as the raw data, but it have a smaller amplitude. The `alpha` value used here is 0.85.
|
|
The filtered clearly removes a lot of the spikes in the data. This might make it easier to see when a plateau is entered. The `alpha` value used here is 0.7.
|
|
|
|
|
|
## Gyro measurements on a plateau
|
|
## Gyro measurements on a plateau
|
|
|
|
|
... | @@ -41,23 +42,26 @@ The filtered data does not have the same spikes as the raw data, but it have a s |
... | @@ -41,23 +42,26 @@ The filtered data does not have the same spikes as the raw data, but it have a s |
|
In order to use the gyro sensor to detect when the car is entering a plateau, a test is conducted. The car is placed on the ramp and both motors are set to full power. During the run raw gyro sensor data is logged using a datalogger.
|
|
In order to use the gyro sensor to detect when the car is entering a plateau, a test is conducted. The car is placed on the ramp and both motors are set to full power. During the run raw gyro sensor data is logged using a datalogger.
|
|
|
|
|
|
### Results
|
|
### Results
|
|
In the figure below the raw and filtered gyro data are shown. In the beginning of the run the wheels slipped, which caused oscillations in the gyro data. This is seen from 0-1 seconds. After one second the car gained grip on caused a increase in the gyro data. At 1.7 seconds the car entered the plateau, which caused a dip followed by a rise in gyro measurements. This is characteristic and can be detected using an algorithm.
|
|
In the two figures below the raw and filtered gyro data for a run up on and down on a plateau are shown.
|
|
In the filtered data, the measurements is below 550 in 100 ms and above 640 in 130 ms. We have chosen to let the algorithm work the following way:
|
|
The car entered the plateau, at the points with large increase and decrease in the gyro data for the upward and downward driving respectively.
|
|
A plateau is entered if:
|
|
We have chosen to describe entering a plateau based on the gyroscope in the following way:
|
|
- the data is below 550 in 50-150 ms
|
|
*A plateau is entered from below if the gyro data is above 650 in more than 100 ms.*
|
|
- followed by a rise above 640 in 60- 170 ms.
|
|
*A plateau is entered from above if the gyro data is below 560 in more than 100 ms.*
|
|
[INSERT code snippet of algorithm]
|
|
|
|
|
|
|
|
|
|
![Upper part: Gyro measurements with both motors turned on at full power. The car was placed on a ramp on the Alishan track, and stopped on the first plateau. Note that the car was driving up the ramp. Lower part: Filtered gyro measurements with an exponential filter.](https://gitlab.au.dk/rene2014/lego/raw/master/Lesson8/Images/GyroPlateauUpMiddle.png)
|
|
|
|
|
|
![Upper part: Gyro measurements with both motors turned on at full power. The car was on the first ramp on the Alishan track, and stopped on the first plateau. Lower part: Filtered gyro measurements with an exponential filter.](https://gitlab.au.dk/rene2014/lego/raw/master/Lesson8/Images/GyroBadVejgrebFirstPlat.png)
|
|
|
|
|
|
|
|
Note that this test might only be valid for entering a plateau from below.
|
|
![Upper part: Gyro measurements with both motors turned on at full power. The car was placed on a ramp on the Alishan track, and stopped on the first plateau. Note that the car was driving up the ramp. Lower part: Filtered gyro measurements with an exponential filter.](https://gitlab.au.dk/rene2014/lego/raw/master/Lesson8/Images/GyroPlateauDownMiddle.png)
|
|
TODO add data for entering a plateau from above.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Conclusion
|
|
## Conclusion
|
|
|
|
From the tests performed with the gyro sensor, it seems possible to detect when the car enters a plateau, be it from below or above. This could be exploited in further work.
|
|
|
|
It was clear from the tests performed that the car was not able to drive forward in a straight line without the use of a line follower. In further work, a line follower should therefore be added to the car, so that this can be used on the straight lines.
|
|
|
|
It is still to be investigated how to turn the car in a precise way, after the plateaus are entered. The current idea is to use the DifferentialPilot class to turn the car.
|
|
|
|
The control strategy needs to be changed, since we plan on including a line follower. A possible solution might be to implement two behaviors:
|
|
|
|
**Lowest priority:** Use the light sensor to follow a line.
|
|
|
|
**Highest priority:** Use the gyro to detect plateau, and turn 180 degrees right, left or on the spot, based on a simple state machine.
|
|
|
|
|
|
## References
|
|
## References
|
|
|
|
|
... | | ... | |