-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtdoa_blue.py
73 lines (49 loc) · 1.74 KB
/
tdoa_blue.py
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
'''
TIME DIFFERENCE OF ARRIVAL (TDOA) LOCALISATION
USING BEST LINEAR UNBIASED ESTIMATOR
AUTHOR: ABIJITH J KAMATH
abijithj@iisc.ac.in
'''
# %% IMPORT PACKAGES
import os
import numpy as np
from skimage.io import imread
from scipy.io import loadmat
from matplotlib import pyplot as plt
from matplotlib import style
from matplotlib import rcParams
import utils
# %% PLOT SETTINGS
plt.style.use(['science','ieee'])
plt.rcParams.update({
"font.family": "serif",
"font.serif": ["cm"],
"mathtext.fontset": "cm",
"font.size": 11})
# %% LOAD DATA
img = imread('data/mapimage.jpeg')
data = loadmat('./data/TDOA_data.mat')
anchor_location = data['anchor_location'].astype(np.float)
target_location = data['target_location'].astype(np.float)
true_distances = data['true_distances']
noisy_distances = data['noisy_distances']
var_vec = data['sigma2']
# %% ESTIMATE USING BLUE
blue_pos = utils.blue_tdoa(noisy_distances[:,0,0], anchor_location, var=0.001)
# %% ESTIMATE USING MLE
init_pos = np.array([0.0,0.0])[:,np.newaxis]
mle_pos = utils.mle_tdoa(noisy_distances[:,0,0], anchor_location, init_pos,
var=0.001, step_size=.0005, max_iter=100)
# %% PLOT LOCATIONS
os.makedirs('./results', exist_ok=True)
path = './results/'
plt.figure(figsize=(12,6))
ax = plt.gca()
utils.plot_sensors(target=blue_pos, anchors=anchor_location*0, image=img, ax=ax,
xaxis_label=r'$x$', yaxis_label=r'$y$', marker='o', markersize=11,
target_colour='blue', legend_label=r'BLUE', show=False)
utils.plot_sensors(target=mle_pos, anchors=anchor_location, image=None, ax=ax,
xaxis_label=r'$x$', yaxis_label=r'$y$', title_text=r'TDOA Localisation using BLUE',
marker='+', markersize=11, target_colour='red', legend_label=r'MLE',
show=True, save=path+'blue')
# %%