... | ... | @@ -79,67 +79,78 @@ |
|
|
># Exercise 2
|
|
|
>
|
|
|
>**Task**
|
|
|
>
|
|
|
>To use the datalogger to record data from the sound sensor.
|
|
|
>
|
|
|
>**Plan**
|
|
|
>
|
|
|
>We use the program DataLogger.java from lesson 1 to record data from the program SoundSampler.java. Then we will >process the data and make a graph using excel.
|
|
|
>
|
|
|
**Result**
|
|
|
The DataLogger was used to log data from the sound sensor. The experiment consisted of a period of 10 seconds in which consecutive snaps were made with the fingers. The graph below shows the results:
|
|
|
|
|
|
![Skærmbillede 2015-03-02 kl. 10.34.35](http://gitlab.au.dk/uploads/group-22/lego/c97aea11de/Sk%C3%A6rmbillede_2015-03-02_kl._10.34.35.png)
|
|
|
Fig. Recording of a sequence of four finger snaps. The graph shows data logged from the NXT while running the SoundSampler program.
|
|
|
|
|
|
The graph shows four distinct spikes in the sound level caused by the finger snapping. The spikes peak at 30-50 (db?) before the sound level goes back to its normal. The background noise measured is about 2-10 (db?).It is interesting to note that the spikes increase faster than they fade away. This observation can be due to resonance or echo from the sound waves which take some milliseconds to fade away.
|
|
|
|
|
|
>**Result**
|
|
|
>
|
|
|
>The DataLogger was used to log data from the sound sensor. The experiment consisted of a period of 10 seconds in >which consecutive snaps were made with the fingers. The graph below shows the results:
|
|
|
>
|
|
|
>![Skærmbillede 2015-03-02 kl. 10.34.35](http://gitlab.au.dk/uploads/group-22/lego/c97aea11de/Sk%C3%A6rmbillede_2015->03-02_kl._10.34.35.png)
|
|
|
>Fig. Recording of a sequence of four finger snaps. The graph shows data logged from the NXT while running the >SoundSampler program.
|
|
|
>
|
|
|
>The graph shows four distinct spikes in the sound level caused by the finger snapping. The spikes peak at 30-50
|
|
|
>(db?) before the sound level goes back to its normal. The background noise measured is about 2-10 (db?).It is
|
|
|
>interesting to note that the spikes increase faster than they fade away. This observation can be due to resonance or >echo from the sound waves which take some milliseconds to fade away.
|
|
|
>
|
|
|
|
|
|
|
|
|
# Exercise 3 - sound controlled car
|
|
|
|
|
|
**Task**
|
|
|
Use the program SoundCtrCar.java to control the car using sound commands.
|
|
|
|
|
|
**Plan**
|
|
|
To run the program and observe how the robot responds to different sound input.
|
|
|
|
|
|
**Result**
|
|
|
The test was conducted on a table where the car was controlled using voice commands. When the car detected the first spike it would drive forward, when it heard the second it would turn left, on the third it would turn right and on the fourth it would stop.
|
|
|
|
|
|
As every word has its own sound profile It could be interesting to investigate if the robot could interpret and act differently on various voice commands. For instance it might be possible for the robot to recognize the difference in length of words. However if different words are of equal length it might be difficult.
|
|
|
|
|
|
# Exercise 4 - button listener
|
|
|
|
|
|
**Task**
|
|
|
In the program SoundCtrCar.java the ESCAPE button is polled in the outermost loop so that the ESCAPE button can be used to stop the program. This does not work when the program loops in one of the four inner loops. You can make the ESCAPE button always work as a program terminator if you also poll the state of the button in the inner loops. But you can also use the ButtonListener mechanism to listen for the ESCAPE button and exit when ESCAPE is pressed. A simple example of a ButtonListener can be seen in the leJos tutorial, [4]. Try this in the program.
|
|
|
|
|
|
**Plan**
|
|
|
To implement the ButtonListener from [4] of the Lab Lesson 3 guide.
|
|
|
|
|
|
**Result**
|
|
|
We implemented the ButtonListener example in the SoundCtrCar program as seen in the code below.
|
|
|
|
|
|
|
|
|
```
|
|
|
Button.ESCAPE.addButtonListener(new ButtonListener() {
|
|
|
public void buttonPressed(Button b) {
|
|
|
|
|
|
System.exit(0);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void buttonReleased(Button b) {
|
|
|
|
|
|
}
|
|
|
});
|
|
|
|
|
|
```
|
|
|
In order to make the program terminate we use the S
|
|
|
|
|
|
# Exercise 5
|
|
|
|
|
|
|
|
|
|
|
|
# Exercise 6
|
|
|
|
|
|
|
|
|
Conclusion |
|
|
\ No newline at end of file |
|
|
># Exercise 3 - sound controlled car
|
|
|
>
|
|
|
>**Task**
|
|
|
>
|
|
|
>Use the program SoundCtrCar.java to control the car using sound commands.
|
|
|
>
|
|
|
>**Plan**
|
|
|
>
|
|
|
>To run the program and observe how the robot responds to different sound input.
|
|
|
>
|
|
|
>**Result**
|
|
|
>
|
|
|
>The test was conducted on a table where the car was controlled using voice commands. When the car detected the first >spike it would drive forward, when it heard the second it would turn left, on the third it would turn right and on >the fourth it would stop.
|
|
|
>
|
|
|
>As every word has its own sound profile It could be interesting to investigate if the robot could interpret and act >differently on various voice commands. For instance it might be possible for the robot to recognize the difference >in length of words. However if different words are of equal length it might be difficult.
|
|
|
>
|
|
|
># Exercise 4 - button listener
|
|
|
>
|
|
|
>**Task**
|
|
|
>
|
|
|
>In the program SoundCtrCar.java the ESCAPE button is polled in the outermost loop so that the ESCAPE button can be >used to stop the program. This does not work when the program loops in one of the four inner loops. You can make the >ESCAPE button always work as a program terminator if you also poll the state of the button in the inner loops. But >you can also use the ButtonListener mechanism to listen for the ESCAPE button and exit when ESCAPE is pressed. A >simple example of a ButtonListener can be seen in the leJos tutorial, [4]. Try this in the program.
|
|
|
>
|
|
|
>**Plan**
|
|
|
>
|
|
|
>To implement the ButtonListener from [4] of the Lab Lesson 3 guide.
|
|
|
>
|
|
|
>**Result**
|
|
|
>
|
|
|
>We implemented the ButtonListener example in the SoundCtrCar program as seen in the code below.
|
|
|
>
|
|
|
>```
|
|
|
>Button.ESCAPE.addButtonListener(new ButtonListener() {
|
|
|
> public void buttonPressed(Button b) {
|
|
|
>
|
|
|
> System.exit(0);
|
|
|
> }
|
|
|
>
|
|
|
> @Override
|
|
|
> public void buttonReleased(Button b) {
|
|
|
>
|
|
|
> }
|
|
|
> });
|
|
|
>
|
|
|
>```
|
|
|
>In order to make the program terminate we use the S
|
|
|
>
|
|
|
># Exercise 5
|
|
|
>
|
|
|
>
|
|
|
>
|
|
|
># Exercise 6
|
|
|
>
|
|
|
>
|
|
|
># Conclusion
|
|
|
> |
|
|
\ No newline at end of file |