... | ... | @@ -107,7 +107,7 @@ |
|
|
>
|
|
|
>To run the program and observe how the robot responds to different sound input.
|
|
|
>
|
|
|
>**Result**
|
|
|
>#### 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.
|
|
|
>
|
... | ... | @@ -115,15 +115,15 @@ |
|
|
>
|
|
|
># Exercise 4 - button listener
|
|
|
>
|
|
|
>**Task**
|
|
|
>#### 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**
|
|
|
>#### Plan
|
|
|
>
|
|
|
>To implement the ButtonListener from [4] of the Lab Lesson 3 guide.
|
|
|
>
|
|
|
>**Result**
|
|
|
>#### Result
|
|
|
>
|
|
|
>We implemented the ButtonListener example in the SoundCtrCar program as seen in the code below.
|
|
|
>
|
... | ... | @@ -151,4 +151,14 @@ |
|
|
>
|
|
|
>
|
|
|
># Conclusion
|
|
|
>Through this lab lesson we’ve gained experience with the sound sensor and how it can be used as an alternate >navigation method. We found out that the sensor is able to detect sound in distances between 0-4 metres and that the >obtained value will vary dependently on the distance. We used the sound input to navigate the car in various ways. >First we made it drive, turn and stop after it detects a clap. Furthermore we installed to sound sensors on the car, >and made it drive towards the direction where most sound was detected.
|
|
|
>
|
|
|
>By logging data from the sound sensor we found out that different sounds result in different sound profiles. This >means that we are able to detect and distinguish different sounds based on the sound profile. For example it is >possible to program the robot to listen for claps as it emits a certain sound pattern.
|
|
|
>
|
|
|
>Lastly we implemented a ButtonListener on the robot and found out how we can terminate the program under different >circumstances. This was necessary as the one of the exercises involved four inner loops which prevented the program >from terminating once the escape button was pressed. By implementing the ButtonListener we made the program >terminate properly.
|
|
|
>
|
|
|
># References
|
|
|
>
|
|
|
>
|
|
|
>
|
|
|
> |
|
|
\ No newline at end of file |