... | ... | @@ -19,11 +19,11 @@ The plan is to follow the instructions for Lesson 3 [1]. |
|
|
### Exercise 1 and 2
|
|
|
|
|
|
Due to the similarity between exercise 1 and 2 the results have been joined together.
|
|
|
In order to test the sound sensor we made a test setup where the LEGO car was placed next to a computer loudspeaker playing a monotone sound (440Hz sine wave). The leJOS data logger was used to collect the sound levels recorded by the sensor. The setup is seen in figure 1.
|
|
|
In order to test the sound sensor we made a test setup were the LEGO car was placed next to a computer loudspeaker playing a monotone sound (440Hz sine wave). The leJOS data logger was used to collect the sound levels recorded by the sensor. The setup is seen in figure 1.
|
|
|
|
|
|
![Test setup](http://gitlab.au.dk/uploads/rene2014/lego/a6a24b2215/Exercise_2_-_Test_setup.jpg)
|
|
|
|
|
|
Initially the sound level of the computer was set to 100% and then manually lowered with a certain interval. By doing this we expected to see a constant decrease in the sound measurements. The results from this exercise is summarized in figure 2.
|
|
|
Initially the sound level of the computer was set to 100% and then manually lowered in discrete intervals. By doing this we expected to see a decrease in the sound level as the exercise progressed. The results from this exercise are summarized in figure 2.
|
|
|
|
|
|
![Sound level measurements](https://gitlab.au.dk/rene2014/lego/raw/ffd008e7c3df32eb42b20f306dc2ff655fd9a17b/Week5/Measurements/SoundLevelMeasurements.png)
|
|
|
|
... | ... | @@ -62,23 +62,23 @@ Button.ESCAPE.addButtonListener(new ButtonListener() { |
|
|
```
|
|
|
|
|
|
### Exercise 5
|
|
|
The figure below shows four consecutive claps, measured with the NXT sound sensor. The pattern starts out at low amplitude and rises quickly (within the 25ms) to an amplitude above 85%. The length of the four claps varies between approximately 85ms and 175ms and then returns back to low (below 50%).
|
|
|
The figure below shows four consecutive claps, measured with the NXT sound sensor. The pattern starts out at low amplitude and rises quickly (within 25ms) to an amplitude above 85%. The length of the four claps varies between approximately 85ms and 175ms and then returns back to low (below 50%).
|
|
|
|
|
|
![Clap characteristics](https://gitlab.au.dk/rene2014/lego/raw/master/Week5/Measurements/ClapMeasurements.png)
|
|
|
|
|
|
In the SoundCtrCar.java a state change occurs whenever a sound level is recorded as 90% or above. The duration of the sound is not taken into account thus a constant sound above this limit will also trigger a state change. A sleep functionality has been implemented in order to keep the program from running quickly through every state at high sounds.
|
|
|
In the SoundCtrCar.java a state change occurs whenever a sound level is recorded as 90% or above. The duration of the sound is not taken into account thus a constant sound above this limit would also trigger a state change. A sleep functionality has been implemented in order to keep the program from running quickly through every state at lasting high sounds.
|
|
|
|
|
|
### Exercise 6 - Party Finder Robot
|
|
|
In this exercise we mount two sound sensors on the Lego car and create a java application that will drive towards loud sound.
|
|
|
In the application we use a PID controller, to control the steering of the vehicle, so that the sound levels on the two sensors are equal.
|
|
|
In this exercise we mounted two sound sensors on the Lego car and created a java application that drives towards loud sound.
|
|
|
In the application we use a PID controller to control the steering of the vehicle, so that the sound levels on the two sensors are equal and thereby that the source of the sound is directly in front of the car.
|
|
|
|
|
|
In the code snippet below, the main function is shown.
|
|
|
The sensor ports are initiated as raw mode, since this will increase the accuracy of the readings.
|
|
|
The DifferentialPilot is used to steer the vehicle, since is gives a easy handle for turning the vehicle in a smooth way.
|
|
|
The DifferentialPilot is used to steer the vehicle, since is gives an easy handle for turning the vehicle in a smooth way.
|
|
|
In the inner control loop, the PID controller is implemented.
|
|
|
Note that the left sensor reading is calibrated, by subtracting 30 from the raw value.
|
|
|
This is done, in order for the sound sensors to have equal calibration.
|
|
|
Otherwise the vehicle will always turn.
|
|
|
This is done, in order for the sound sensors to have equal output with equal input.
|
|
|
Otherwise the vehicle will not be able to navigate towards the loudest sound source.
|
|
|
|
|
|
```java
|
|
|
SensorPort leftSound = SensorPort.S1;
|
... | ... | @@ -120,7 +120,7 @@ static float Kp = 5.0f, |
|
|
Kd = 0.5f;
|
|
|
```
|
|
|
This means that the integral part of the PID controller is not used.
|
|
|
This is chosen, since it seemed to have an unfortunate effect on the control even when a Ki value of 0.001 was used.
|
|
|
This is chosen, since it seemed to have an unfortunate effect on the control even when a Ki value of 0.001 was used.
|
|
|
|
|
|
The performance of our Party Finding Robot is shown in the following video.
|
|
|
|
... | ... | @@ -131,7 +131,7 @@ The performance of our Party Finding Robot is shown in the following video. |
|
|
The NXT sound sensor was used both to determine characteristics of a clap and to control the LEGO car with various sound controlled applications.
|
|
|
|
|
|
We experienced some non-linearities in the use of the sensor, which we did not fully understand.
|
|
|
This could be investigated further later.
|
|
|
This could be investigated further.
|
|
|
|
|
|
We were very successful with implementing a Party Finder Robot using two sound sensors, a PD controller and the DifferentialPilot class in the leJOS API.
|
|
|
The calibration and choice of gain parameters could probably be optimized to give an even better performance.
|
... | ... | |