binaulocExample.m 2.07 KB
Newer Older
Fredrik Bagge Carlson's avatar
Fredrik Bagge Carlson committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
% Assuming that you already have a 'client' handle, and that the 'binauloc'
% component is running on the turtlebot, load this component.
binauloc = client.load('binauloc')

% Connect the input port of binauloc to the output port of bass, so that
% binauloc receives the raw audio data from bass. Note that the data flow
% goes from bass on the Raspberry Pi to binauloc on the turtlebot. The
% audio data does not pass by Matlab here.
binauloc.connect_port('Audio', 'bass/Audio')

% Setup the parameters of the algorithm. To have a bit more information
% about the role of each parameter, you can call binauloc.Setup('-h'). To
% have further information, c.f. Portello et al. IROS 2013 & IROS 2014
binauloc.Setup( ...
    '/home/turtlebot/genom3/activeloc/data/setup', ... % just a file to write parameters in (please do not change)
    24414, ... % the sample rate
    5000, ... % the maximum frequency
    1024, ... % the number of samples per frame (here a frame is a block of audio)
    512, ... % the overlap between two frames
    '::localization::HANNING', ... % the window function
    10, ... % contributes to the smoothing of the pseudo-likelihood
    '/home/turtlebot/genom3/activeloc/data/projector', ... % another file to write data in  (please do not change)
    '/home/turtlebot/genom3/activeloc/data/noise') % yet another file to write data in  (please do not change)

% Learn the noise characteristics. Make sure the environment is silent
% before calling this service!
binauloc.LearnNoise(2) % 2 seconds

% Use the inter-aural transfer function to compute a projector on the space
% spanned by the steering vector [1; inter-aural transfer function]
binauloc.PretabProj('/home/turtlebot/genom3/activeloc/steerVecs/steerVecS72')

% Start the localization (runs indefinitely, don't forget the '-a' option)
rLocalizeSources = binauloc.LocalizeSources('-a', 1, 1, 4)

% The azimuth detection is now running, you can retrieve the current
% estimated azimuth in p = binauloc.Azimuths(). The value is in radians,
% increasing towards right.

% The localization can be stopped with binauloc.StopLocalization()