Upload
dinhminh
View
214
Download
0
Embed Size (px)
Citation preview
SIS project: David FitzGeraldSound detection with a real e-puck Daniel Kroiss
Goal:● Program an e-puck in order to find a sound source.
Equipment:● Two e-pucks
● Three batteries
● Bluetooth USB key
Programming language:● C
04.06.2013 2
Procedure:1. Record the sound
2. Apply the Fast Fourier Transform
3. Calculate the phase and phase differences
4. Determine the sinus of the angle between the e-puck orientation and the sound direction
5. Clean the values and do a normalisation
6. Calculate the angle between the e-puck orientation and the sound direction
7. Set the wheel speeds
SIS project: David FitzGeraldSound detection with a real e-puck Daniel Kroiss
04.06.2013 3
1. Sound recording:● The sound is sampled with three microphones and stored in an array:
2. Fast Fourier Transform● The fast fourier transform is calculated by the following function:
// 1. Get Sounde_ad_scan_on();while( !e_ad_is_array_filled());
e_ad_scan_off();
// i. Substract mean of vectore_subtract_mean(e_mic_scan[k], FFT_BLOCK_LENGTH, LOG2_BLOCK_LENGTH);
// ii. Copy vector into sigCmpxe_fast_copy(e_mic_scan[k], (int*)sigCmpx, FFT_BLOCK_LENGTH);
// iii. Do FFT. The result is stored in sigCmpx.e_doFFT_asm(sigCmpx);
SIS project: David FitzGeraldSound detection with a real e-puck Daniel Kroiss
04.06.2013 4
3. Phase:● The phase is determined using the following line of code:
// iv. Phase calculationtheta[k] = atan2(sigCmpx[IND_FFT].imag, sigCmpx[IND_FFT].real);
● It requires the index (IND_FFT) thats corresponds to the sound frequency (880 Hz). We can find it by plotting the magnitude of the signal.
● We chose the index 22, for which the frequency is:
f ≈ 22256/2
⋅33'0002
Hz
SIS project: David FitzGeraldSound detection with a real e-puck Daniel Kroiss
04.06.2013 5
(33'000 Hz ≈ microphone sampling frequency)
3. Phase difference:● The phase difference is related to the time it takes the sound to go
from one microphone to another:
For example:
● At this point it is possible to useΔφ to make the e-puck turntowards the sound source.
Δ t = Δϕ2⋅π⋅f
Δ ϕ10 = ϕ0 − ϕ1
SIS project: David FitzGeraldSound detection with a real e-puck Daniel Kroiss
04.06.2013 6
Forward direction
Δφ10
> 0 Δφ10
< 0
● If Δφ10
> 0: turn left
● If Δφ10
< 0: turn right
● Else: go forward or turn around (depending on the sign of Δφ
20 and
Δφ21
)
Works well
Mic 1 Mic 0
Mic 2
Δϕ10 = ϕ0 − ϕ1
SIS project: David FitzGeraldSound detection with a real e-puck Daniel Kroiss
04.06.2013 7
3. Phase difference:
4. Sinus determination:
θ = arcsin ( v⋅Δ tx )The angle is given by:
where v is the speed of sound.
SIS project: David FitzGeraldSound detection with a real e-puck Daniel Kroiss
04.06.2013 8
5. Sinus filtering:
● must have a value between -1 and 1
Normalization required
● Plot of a values and cleaned a values
a= v⋅Δ tx
⇒
SIS project: David FitzGeraldSound detection with a real e-puck Daniel Kroiss
04.06.2013 9
5. Sinus filtering implementation:
// iv. Normalisationfor (k=0;k<3;k++){
// Clean amplified valuesif (a[k] > 1){
a[k] = -0.5;}else if (a[k] < -1){
a[k] = 0.5;}
// Normalisationif (a[k] > 0){
a[k] = a[k]/max_value[k];}else{
a[k] = -a[k]/min_value[k];}// Clean max and min valuesif (a[k] > 1){
a[k] = 1;}else if (a[k] < -1){
a[k] = -1;}
}
SIS project: David FitzGeraldSound detection with a real e-puck Daniel Kroiss
04.06.2013 10
6. Angle θ:● One angle is not sufficient to determine the direction of the sound.
Mic 2
Mic 0Mic 1
θ20
= θ20
?● We computed the angle θ21
for mic2 & mic1, and θ20 for
mic2 & mic0
SIS project: David FitzGeraldSound detection with a real e-puck Daniel Kroiss
04.06.2013 11
⇒ θ20 & θ21 → real θ
6. Angle β:● We defined the angle β (comprised between -π and π) based on θ21
and θ20.
Forward direction
β > 0 β < 0
Result when making the sound source turn around the e-puck:
SIS project: David FitzGeraldSound detection with a real e-puck Daniel Kroiss
04.06.2013 12
7. Wheel speed:
e_set_speed_right
e_set_speed_left
I 1000 1000
II 1000 200
III a 1000 -1000
III b -1000 1000
IV 200 1000 II
III
I
IV
a bStopping condition:
if (e_get_prox(k) > sensitivity level ){
e_set_speed_left(0);e_set_speed_right(0);
}
SIS project: David FitzGeraldSound detection with a real e-puck Daniel Kroiss
04.06.2013 13
Forward direction
Performance:● The method using β works as well as the method that uses the sign of
Δφ.
● The fluidity was improved by removing the NaN values of φ.
● The time needed to reach the sound source is directly dependent on the wheel speeds.
Problems encountered:● The IR sensors could cause the e-puck to stop randomly due to the
lighting conditions.
● The maximum distance between the e-puck and the sound source up to which sound is detected is pretty small (~70 cm).
● Unreliable Bluetooth connection.
SIS project: David FitzGeraldSound detection with a real e-puck Daniel Kroiss
04.06.2013 14
Possible improvements:● The performance could be improved by better filtering the signal.
● The accuracy of β could be better with more correct values for the normalization (max_value and min_value).
● Use several consecutive samples before calculating the angle in order to reduce the influence of the noise.
SIS project: David FitzGeraldSound detection with a real e-puck Daniel Kroiss
04.06.2013 15
Conclusion:● What was important for us was the precision of the angle β.
● The time needed to reach the sound source was secondary.
● Through this project, we were able to see that the method using the FFT works pretty well. However, it would be interesting to compare it with other methods.
//Thank you for your attention !
SIS project: David FitzGeraldSound detection with a real e-puck Daniel Kroiss
04.06.2013 16
References:● http://ras.papercept.net/conferences/support/word.php
● http://www.labbookpages.co.uk/audio/beamforming/delayCalc.html
● http://moodle.epfl.ch/course/view.php?id=7321
● http://www.e-puck.org/index.php?option=com_content&view=article&id=2&Itemid=8
● http://www.siteduzero.com/informatique/tutoriels/apprenez-a-programmer-en-c
● https://github.com/davidmarek/E-Puck-Algorithms-Library/blob/master/firmware/BTcomDM.c
SIS project: David FitzGeraldSound detection with a real e-puck Daniel Kroiss
04.06.2013 17