-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdemo_test_single_point.m
More file actions
54 lines (45 loc) · 2.13 KB
/
demo_test_single_point.m
File metadata and controls
54 lines (45 loc) · 2.13 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
%% demo_test_single_point.m
% ------------------------------------------
% Demonstrates the use of `BatCallLocaliser.test()`
% on a single simulated source position
% You may also access the outputs 'result' and 'out' for all parameters.
% ------------------------------------------
clear; clc;
% --- Define Simulation Parameters ---
params = struct();
params.fs = 384e3; % Sampling rate
params.d = 10e-3; % Duration of call (eg. 10 ms)
params.f0 = 25000; % Start frequency
params.f1 = 80000; % End frequency
params.tail = 50; % Tapering in percent
params.micSpacing = 0.5; % Edge length of array in metres
params.snr_db = 60; % Signal-to-noise ratio
params.callType = 'FM'; % or 'FM'
params.velocity = [0 0 0]; % m/s (negative = approaching), x y z components
% --- Microphone Configuration ---
cfg = mic_array_configurator(4, 'Tetrahedron', params.micSpacing);
params.mic_positions = cfg.mic_positions;
% --- Create Localiser ---
localiser = BatCallLocaliser(params);
% --- Define Source Location ---
source_position = [1.2, -0.8, 2.5]; % (in metres)
% --- Generate Call Signal and Propagate to Mics ---
result = localiser.simulate(source_position);
% --- Run Localisation Test ---
out = localiser.test(result, 0, 1);
% --- Compute True Azimuth & Elevation ---
ref_mic = params.mic_positions(1,:);
rel_vector = source_position - ref_mic;
az_true = atan2d(rel_vector(2), rel_vector(1));
el_true = asind(rel_vector(3) / norm(rel_vector));
% --- Angular Error ---
az_est = out.tdoa.azimuth;
el_est = out.tdoa.elevation;
ang_error = sqrt((az_true - az_est)^2 + (el_true - el_est)^2);
% --- Print Results ---
fprintf('\nGround Truth Source: [%.2f, %.2f, %.2f] m\n', out.true_source);
fprintf('TDOA Estimate: [%.2f, %.2f, %.2f] m\n', out.tdoa.position);
fprintf('Position Error: %.2f cm\n', out.tdoa.error * 100);
fprintf('True Azimuth: %.2f°, True Elevation: %.2f°\n', az_true, el_true);
fprintf('Estimated Azimuth: %.2f°, Estimated Elevation: %.2f°\n', az_est, el_est);
fprintf('Angular Error: %.2f°\n\n', ang_error);