... | ... | @@ -35,28 +35,29 @@ For the first part of the exercise we wrote a program, **SoundLover.java** [TODO |
|
|
|
|
|
A range of 0 to 100 could make sense as it incorporates noise levels up to shouting and loud music [3], excluding aeroplane noise and noise above the pain threshold, which seems reasonable for a robot intended for educational purposes. On the other hand, we may simply not have observed higher values as there were no sound sources present to produce noise of that loudness level. This, however, is not important as we will most likely not encounter sound of that level during this session either. And if we do, our past experiences has shown that when values higher than 100 are passed to the robot's motors, they are simply interpreted as a value of 100.
|
|
|
|
|
|
Ideally we would run some more thorough experiments to figure out the exact range that the sound sensor can measure, but we opted not to do this. The result of running this program can be seen in [TODO: ref til video].
|
|
|
Ideally we would run some more thorough experiments to figure out the exact range that the sound sensor can measure, but we opted not to do this. The result of running this program can be seen in Video 1.
|
|
|
|
|
|
[TODO: Video]
|
|
|
*Video 1: The robot running SoundLover.java*
|
|
|
|
|
|
As can be seen in the video, the robot starts driving forward fine when measuring some noise, however it keeps driving forward with full speed despite receiving (almost) no sound. We judged this as being a result of one of two things: The sound sensor could be vibrating too violently when the robot is driving full force, which the sensor interprets as a loud sound thereby causing a constant feedback loop making the robot continue to drive forward. Alternatively, it could simplu be that the sound made by the motors is loud enough to cause the robot to keep driving. A combination of the two being the cause is also likely.
|
|
|
|
|
|
To solve this issue, we rebuilt the robot to extend the sound sensor further away from the robot by placing it on a pole. This could help in both cases: If motor noise was the cause, distancing the sensor from the motors would obviously help. And if vibrations were the cause, placing the sensor on a pole might help as the vibrations on the end of the pole should be of a lower frequency than those produced directly by the robot's motors and movement. The rebuild can be seen in Figure 2 and the result of running the program with this build can be seen in [TODO: ref]
|
|
|
To solve this issue, we rebuilt the robot to extend the sound sensor further away from the robot by placing it on a pole. This could help in both cases: If motor noise was the cause, distancing the sensor from the motors would obviously help. And if vibrations were the cause, placing the sensor on a pole might help as the vibrations on the end of the pole should be of a lower frequency than those produced directly by the robot's motors and movement. The rebuild can be seen in Figure 2 and the result of running the program with this build can be seen in Video 2.
|
|
|
|
|
|
![re-rebuilt robot](https://gitlab.au.dk/LEGO/lego-kode/raw/master/week8/img/polebot.PNG)
|
|
|
*Figure 2: The robot after second rebuild - notice that the flower is still there*
|
|
|
|
|
|
[TODO: Rebuild video]
|
|
|
*Video 1: The robot running SoundLover.java after rebuild*
|
|
|
*Video 2: The robot running SoundLover.java after rebuild*
|
|
|
|
|
|
We see that the build solves our problem extremely well, as the robot accurately slows down once we stop making sounds, instead of constantly driving forward as a result of its own
|
|
|
We see that the build solves our problem extremely well, as the robot accurately slows down once we stop making sounds instead of constantly driving at high speed.
|
|
|
|
|
|
Next, we modified our program to receive raw values directly from the sensor port instead of using *readValue()* from the sound sensor. We did this because we want an accurately known interval of measured values in order to map to any range that we desire. The sensor measures a raw value between 0 and 1023, where a high raw value means a low sound level. We simply convert the measured value to a percentage of possible maximum value, then invert this percentage, and pass it along as a motor power parameter. As can be seen in video [Insert next video, one from corner to middle in 3 bursts (Nicolai knows wtf this means)], this modifications still works perfectly fine, and allows for more precise and easier mapping to any ranges we want.
|
|
|
Next, we modified our program to receive raw values directly from the sensor port instead of using *readValue()* on the *SoundSensor* class. We did this because we would like an accurately known interval of measured values in order to map to any range that we desire. The sensor measures a raw value between 0 and 1023, where a high raw value means a low sound level. We simply convert the measured value to a percentage of the maximum value 1023, then invert this percentage by subtracting it from 100, and then pass it along as the value of the motor power parameter. As can be seen in Video 3, this modifications still works perfectly fine, and as it allows for more precise and easier mapping to any ranges we want, we decided to continue using raw values.
|
|
|
|
|
|
[Perhaps insert code example?]
|
|
|
[TODO: Perhaps insert code example?]
|
|
|
|
|
|
[Video]
|
|
|
[TODO: Video, one from corner to middle in 3 bursts (Nicolai knows wtf this means)]
|
|
|
*Video 3: Running SoundLover.java using raw values read directly from the sensor port instead of dB values read from the sound sensor*
|
|
|
|
|
|
We now want to map our raw value to the range -100 to 100, in order for the robot motor power range to go from full power backwards to full power forwards, rather than from full stop to full power forwards. We do this by simply multiplying the percentage of measured raw value (inverted) with our full range value, in this case 200, and then adding this number to our minimum range value, in this case -100. We implemented this in the program **SoundReactor.java**, and the result can be seen in [INSERT NEXT VIDEO].
|
|
|
|
... | ... | |