-
Notifications
You must be signed in to change notification settings - Fork 25
/
InverseSensorModels.py
624 lines (425 loc) · 17 KB
/
InverseSensorModels.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
# -*- coding: utf-8 -*-
# <nbformat>3.0</nbformat>
# <codecell>
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.cm as cm
import matplotlib.mlab as mlab
from IPython.html.widgets import interact
from IPython.html import widgets
%matplotlib inline
# <headingcell level=1>
# Inverse Sensor Models
# <markdowncell>
# Gives the probability $P$ of how a sensor reading $z$ might be, with a given sensor pose $x$ and an environment $m$.
#
# $P(z\mid x,m)$
# <codecell>
def normalize(P):
return P/np.max(np.sum(P))
# <headingcell level=2>
# 2D Mixture Density
# <markdowncell>
# Good tutorial video:
# <codecell>
from IPython.display import HTML
HTML("""
<video width="500" height="260" controls>
<source src="http://ais.informatik.uni-freiburg.de/teaching/ss13/robotics/recordings/rob1-07-sensor-models.mp4" type="video/mp4">
</video>
""")
# <markdowncell>
# $P(z\mid x,m) = \left(\begin{matrix}P_{hit}(z\mid x,m) \\ P_{unexp}(z \mid x,m) \\ P_{max}(z \mid x,m) \\ P_{rand}(z \mid x,m) \end{matrix}\right)$
# <codecell>
zs = np.arange(0, 10.01, 0.01) # Entfernungen
# <headingcell level=4>
# Measurement Noise
# <markdowncell>
# Sensor readings are normal distributed around the true value with standard deviation $\sigma_z$ and mean $z_{exp}$.
#
# $P_{hit}(z\mid x,m) = \frac{1}{\sqrt{2 \pi \sigma_z^2}} \cdot \exp{\left(-\frac{1}{2} \cdot \frac{(z-z_{exp})^2}{\sigma_z^2}\right)}$
# <codecell>
varz = 0.05 # Variance
zexp = 5.0 # here is the obstacle
Pzx_hit = 1.0/np.sqrt(2*np.pi*varz) * np.exp(-1/2.0*(zs-zexp)**2/varz)
Pzx_hit = normalize(Pzx_hit)
# <headingcell level=4>
# Unexpected Obstacles
# <markdowncell>
# There might be measurements before the beam hits the real obstacle.
#
# $P_{unexp}(z \mid x,m) = \lambda \cdot \exp{\left(-\lambda \cdot z\right)}$
# <codecell>
lamb = 0.5
Pzx_unexp = lamb * np.exp(-lamb * zs)
Pzx_unexp[zs>zexp] = 0.0
Pzx_unexp = normalize(Pzx_unexp)
# <headingcell level=4>
# Random Measurements
# <markdowncell>
# There is a random distribution, that the measurement is somewhere.
#
# $P_{rand}(z \mid x,m) = \frac{1}{z_{max}}$
# <codecell>
Pzx_rand = np.ones(len(zs)) * 0.01
Pzx_rand = normalize(Pzx_rand)
# <headingcell level=4>
# Max Range Model
# <markdowncell>
# The beam can get lost and is responding with the maximum value.
#
# $P_{max}(z \mid x,m) = \delta(z_{max})$
# <codecell>
Pzx_maxrange = np.zeros(len(zs))
Pzx_maxrange[-2:] = 0.03
#Pzx_maxrange = normalize(Pzx_maxrange)
# <headingcell level=3>
# Resulting Mixture Density
# <codecell>
Pzx = Pzx_hit + Pzx_unexp + Pzx_rand + Pzx_maxrange
Pzx = normalize(Pzx)
# <codecell>
plt.figure(figsize=(12,6))
ax1 = plt.subplot2grid((4,4), (0,0), rowspan = 2)
plt.plot(zs, Pzx_hit)
plt.axvline(zexp, c='k', alpha=0.5)
plt.title('Measurement Noise')
plt.ylabel(r'$P(z \mid x,m)$')
ax2 = plt.subplot2grid((4,4), (0,1), rowspan = 2, sharey=ax1)
plt.plot(zs, Pzx_unexp)
plt.axvline(zexp, c='k', alpha=0.5)
plt.title('Unexcpected Obstacles')
ax3 = plt.subplot2grid((4,4), (0,2), rowspan = 2, sharey=ax1)
plt.plot(zs, Pzx_rand)
plt.axvline(zexp, c='k', alpha=0.5)
plt.title('Random Measurement')
ax4 = plt.subplot2grid((4,4), (0,3), rowspan = 2, sharey=ax1)
plt.plot(zs, Pzx_maxrange)
plt.axvline(zexp, c='k', alpha=0.5)
plt.title('Max Range Measurement')
ax5 = plt.subplot2grid((4,4), (2,0), colspan=4, rowspan = 3)
plt.plot(zs, Pzx)
plt.axvline(zexp, c='k', alpha=0.5)
plt.title('= Mixture Density')
plt.ylabel(r'$P(z|x,m)$')
plt.xlabel('z [$m$]')
for ax in [ax2, ax3, ax4]:
plt.setp(ax.get_yticklabels(), visible=False)
# The y-ticks will overlap with "hspace=0", so we'll hide the bottom tick
#ax.set_yticks(ax.get_yticks()[1:])
ax.text(-1.5,np.max(Pzx_maxrange)/2,'+', fontsize=20)
plt.tight_layout()
plt.savefig('InverseSensorModel-MixtureDensity.png', dpi=150)
# <headingcell level=2>
# Fit the model with real data
# <markdowncell>
# ![ibeo Lux](http://www.mechlab.de/wp-content/uploads/2012/02/ibeoLUX.jpg)
#
# Maximize likelihood of the data:
# $P(z \mid z_{exp})$
# <codecell>
import pandas as pd
# <codecell>
def ibeo2XYZ(theta, dist, layer):
'''
Berechnet die kartesischen X,Y,Z-Koordinaten aus polaren Koordinaten des IBEO Lux Laserscanners unter der Annahme er ist perfekt horizontal ausgerichtet.
Input:
- theta: Horizontaler Winkel
- dist : polarer Abstand
- layer: Ebene
'''
# Ibeo Lux hat 3.2° bei 4 Ebenen vertikal
oeffnungswinkel = 3.2
ebenen = 4.0
# aus Ebene den Vertikalwinkel berechnen
phi = (layer * oeffnungswinkel/(ebenen-1) - oeffnungswinkel/2.0) * np.pi/180.0
X = dist * np.cos(theta)
Y = dist * np.sin(theta)
Z = dist * np.sin(phi)
return np.array([X, Y, Z])
# <codecell>
data = pd.read_csv('kalibrierungtisch2.txt', delimiter='|')
# <codecell>
data.head(5)
# <headingcell level=4>
# Let's see how they are collected, line by line
# <codecell>
@interact
def integratemeasurement(t = widgets.IntSliderWidget(min=1, max=5000, step=1, value=40, description="")):
#print t
f = (data['<Ebene>']==3) & (data['<Winkel>']>-0.015) & (data['<Winkel>']<0.015)
angle = data['<Winkel>'][f].iloc[:t]
distance = data['<Radius>'][f].iloc[:t] /100.0
layer = data['<Ebene>'][f].iloc[:t]
plt.scatter(distance,angle, s=50, alpha=0.1)
plt.axis('equal')
plt.xlabel('z [$m$]')
plt.ylabel('$\phi$ [$rad$]')
# <codecell>
timestamps = data['# <Zeitstempel>'].unique()
# <codecell>
x=[]
y=[]
for i, timestamp in enumerate(timestamps):
#f = (data['# <Zeitstempel>']==timestamp) & (data['<Ebene>']==3)
#f = (data['# <Zeitstempel>']==timestamp) & ((data.index%467.0)==0)
f = (data['# <Zeitstempel>']==timestamp) & (data['<Ebene>']==3) & (data['<Winkel>']>-0.015) & (data['<Winkel>']<0.01)
angle = data['<Winkel>'][f]
distance = data['<Radius>'][f] /100.0
layer = data['<Ebene>'][f]
# 350. Punkt jedes Zeitstempels nehmen
[xe, ye, ze] = ibeo2XYZ(angle, distance, layer)
x.extend(xe)
y.extend(ye)
# <codecell>
plt.scatter(x,y)
plt.axis('equal')
# <codecell>
# <codecell>
plt.figure(figsize=(6,3))
plt.hist(x, bins=5, align='mid');
#plt.axvline(np.mean(x), alpha=0.6, c='k')
plt.xlim(0, 5)
#plt.title('Histogram of real ibeo Lux Sensor measurement')
plt.xlabel('z [$m$]')
plt.tight_layout()
plt.savefig('Histogram-ibeoLux-InverseSensorModel.png', dpi=150)
# <markdowncell>
# Actually, the sensor is so good, that all assumptions are not necessary. It basically just detects the obstacle with a very narrow normal distribution. In case of a deterministic grid, you even do not have to assume a normal distribution, because the discrete cells can't determine the difference.
#
# Like so, it is implemented in Hornung, A., Wurm, K. M., Bennewitz, M., Stachniss, C., & Burgard, W. (2013). OctoMap: an efficient probabilistic 3D mapping framework based on octrees. Autonomous Robots, 34(3), 189–206. doi:10.1007/s10514-012-9321-0
# <headingcell level=2>
# Multivariante Gaussian for Sensor
# <markdowncell>
# Sensors scan a 3D environment, so we have to take a look at a multivariant gaussian sensor.
# <headingcell level=4>
# Range for Sensor Readings
# <codecell>
zs = np.arange(0, 10.1, 0.01) # Entfernungen
ts = np.arange(-1, 1.1, 0.01) # Winkel
# <headingcell level=4>
# Standard Deviations for Angle and Distance
# <codecell>
def calcmultivargauss(sigmaz, sigmat, dxy, txy):
P = np.zeros((len(zs), len(ts)))
x = np.zeros((len(zs), len(ts)))
y = np.zeros((len(zs), len(ts)))
for i,z in enumerate(zs):
for j,t in enumerate(ts):
x[i,j] = z * np.cos(t)
y[i,j] = z * np.sin(t)
P[i,j] = 1.0/(2.0*np.pi*sigmat*sigmaz) * np.exp(-0.5*((z-dxy)**2/sigmaz**2 + (t-txy)**2/sigmat**2))
return x,y,P
# <codecell>
@interact
def plotmultivargauss(sigmaz = widgets.FloatSliderWidget(min=0.01, max=5.0, step=0.01, value=0.3, description=""), \
sigmat = widgets.FloatSliderWidget(min=0.01, max=1.0, step=0.01, value=0.2, description=""), \
dxy = widgets.FloatSliderWidget(min=0.0, max=9.0, step=0.1, value=4.0, description=""), \
txy = widgets.FloatSliderWidget(min=-1.0, max=1.0, step=0.1, value=0.0, description="")):
x,y,P = calcmultivargauss(sigmaz, sigmat, dxy, txy)
plt.contourf(x, y, P, cmap=cm.gray_r)
plt.scatter(0, 0, s=250, c='k')
plt.plot([0, 10*np.cos(np.max(ts))],[0, 10*np.sin(np.max(ts))], '--k')
plt.plot([0, 10*np.cos(np.min(ts))],[0, 10*np.sin(np.min(ts))], '--k')
plt.xlabel('X');
plt.ylabel('Y');
plt.xlim([0, 8]);
plt.ylim([-4, 4]);
return plt
# <codecell>
# <codecell>
sigmaz = 0.3 # Entfernung
sigmat = 0.2 # Winkel
dxy = 8.0 # Sensor Reading Entfernung
txy = 0.0 # Sensor Reading Winkel
x, y, P = calcmultivargauss(sigmaz, sigmat, dxy, txy)
# <headingcell level=4>
# 3D Plot
# <codecell>
fig = plt.figure(figsize=(12,6))
ax = fig.gca(projection='3d', axisbg='w')
ax.scatter(0,0, s=100, c='k')
ax.plot_wireframe(x, y, P, rstride=50, cstride=5)
ax.set_xlabel(r'x [$m$]')
#ax.set_xlim(0, 8)
ax.set_ylabel('y [$m$]')
#ax.set_ylim(-4, 4)
ax.set_zlabel('P')
#ax.set_zlim(-100, 100)
ax.view_init(elev=45., azim=180.)
plt.savefig('InverseSensorModel-3D.png', dpi=150)
# <headingcell level=2>
# KONOLIGE Ansatz
# <markdowncell>
# Is ja alles ganz nett, aber lässt sich schlecht implementieren. Deshalb Ansatz von Konolige, K. (1997). Improved occupancy grids for map building. Autonomous Robots, 367, 351–367. Retrieved from http://cs.krisbeevers.com/research/research_qual/05-konolige97.pdf
#
# 1. The range error becomes proportionally larger at increasing range.
# 2. The probability of detection becomes smaller at larger ranges.
#
# A mathematical model for target reflection in the 1D case is:
#
# $$p(z=D|C) = \frac{\alpha(z_i)}{\sqrt{2\pi} \delta(z_i)} \cdot \exp{\frac{-(D-z_i)^2}{2\delta(z_i)^2}}$$
#
# where the target is at distance $z_i$ from the transducer. In this model, $\alpha(z_i)$ is the attenuation of detection with distance, $\delta(z_i)$ is the range variance (increasing with distance).
#
# Example: For a Polaroid Ultrasonic $d(z) = 0.01 + 0.015\cdot z$ and $\alpha = 0.6(1-\min(1; 0.25r))$
# <codecell>
zs = np.arange(0, 10.01, 0.01) # Entfernungen
ts = np.arange(-1, 1.01, 0.01) # Winkel
# <codecell>
D = 5.0 # Sensor Measurement
# <codecell>
d = 0.01+0.15*zs
a = 0.1*(1-np.min((np.ones(len(zs)), 1/10.0*zs), axis=0))
# <codecell>
plt.figure(figsize=(9,3))
plt.subplot(121)
plt.plot(zs, d)
plt.xlabel('Distance in m')
plt.ylabel(r'$\delta(z)$')
plt.title('Range Error')
plt.subplot(122)
plt.plot(zs, a)
plt.xlabel('Distance in m')
plt.ylabel(r'$\alpha(z)$')
plt.title('Detection Attenuation')
plt.tight_layout()
# <codecell>
# The effect of F is to make the no change for cells everywhere but in the vicinity of the range reading r = D
F = 0.0001
# <codecell>
# probability Density
p = a*np.exp(-(zs-D)**2/(2.0*d**2)) + F
p = p/np.max(p)
plt.plot(zs, p)
plt.axvline(D, c='k')
plt.ylabel(r'$P(z|x,m)$')
plt.xlabel('z [$m$]')
# <codecell>
# <markdowncell>
# Probability that no range reading was received at a distance less than D:
#
# $P = 1- \int_0^D p(r=x|C)\mathrm{d}x$
# <codecell>
# probability that no range reading was received at a distance less than D
P = 1.0-np.cumsum(p)/np.sum(p)
P[zs>D] = 0.0
plt.plot(zs, P)
plt.axvline(D, c='k', alpha=0.2)
plt.ylabel(r'$P(\neg z|x,m)$')
plt.xlabel('z [$m$]')
# <codecell>
# sensor probability density
spd = P*p
spd = spd/np.max(spd)
plt.plot(zs, spd)
plt.axvline(D, c='k', alpha=0.5)
#plt.ylim(0, 0.01)
plt.ylabel(r'$P(z|x,m)$')
plt.xlabel('z [$m$]')
# <codecell>
plt.figure(figsize=(8,5))
ax1 = plt.subplot2grid((4,4), (0,0), rowspan = 2, colspan = 2)
plt.plot(zs, p)
plt.axvline(zexp, c='k', alpha=0.5)
plt.title('Measurement Noise')
plt.ylabel(r'$P(z \mid x,m)$')
ax2 = plt.subplot2grid((4,4), (0,2), rowspan = 2, colspan = 2, sharey=ax1)
plt.plot(zs, P)
plt.ylabel(r'$P(\neg z|x,m)$')
plt.axvline(zexp, c='k', alpha=0.5)
plt.title('No Range Reading')
ax3 = plt.subplot2grid((4,4), (2,0), colspan=4, rowspan = 3)
plt.plot(zs, spd)
plt.axvline(zexp, c='k', alpha=0.5)
plt.title('= KONOLIGE Inverse Sensor Model')
plt.ylabel(r'$P(z|x,m)$')
plt.xlabel('z [$m$]')
for ax in [ax2]:
plt.setp(ax.get_yticklabels(), visible=False)
# The y-ticks will overlap with "hspace=0", so we'll hide the bottom tick
#ax.set_yticks(ax.get_yticks()[1:])
ax.text(-1.5,np.max(P)/2,'+', fontsize=20)
plt.tight_layout()
plt.savefig('InverseSensorModel-KONOLIGE.png', dpi=150)
# <headingcell level=2>
# LANGERWISCH Error Bounding Box
# <markdowncell>
# Langerwisch, M., & Wagner, B. (2013). Building variable resolution occupancy maps assuming unknown but bounded sensor errors. Intelligent Robots and Systems ( …, 4687–4693. Retrieved from http://www.rts.uni-hannover.de/images/2/24/Langerwisch13-IROS.pdf
# <headingcell level=4>
# Simple Model
# <markdowncell>
# The error afflicted dis- tance will be the interval [d], having w([d]) as the maximum assumed error bound. The laser beam is assumed to spread in width with an angle of ϕb. Together with the angular position of the scanning mirror ϕm, the beam angle results in [ϕ] = [ϕm − ϕb/2 ,ϕm + ϕb/2 ]. Now, an outer boundary of
# the possible locations of the real object reflection can be calculated in the sensor coordinate frame:
# <markdowncell>
# $[p'] = \left[\begin{matrix}d \cdot \cos(\phi) \\ d \cdot \sin(\phi)\end{matrix}\right] $
# <codecell>
wd = 0.04 # maximum assumed error bound for distance measurement
phib = 0.01 # rad
d = 1.0 # m
phi = 0.8 # rad
# <codecell>
@interact
def plotmultivargauss(wd = widgets.FloatSliderWidget(min=0.005, max=1.0, step=0.005, value=0.05, description=""), \
phib = widgets.FloatSliderWidget(min=0.01, max=1.0, step=0.01, value=0.01, description=""), \
d = widgets.FloatSliderWidget(min=0.0, max=10.0, step=0.1, value=1.0, description=""), \
phi = widgets.FloatSliderWidget(min=-1.0, max=1.0, step=0.1, value=0.6, description="")):
p = {}
p['p1'] = ((d-wd) * np.cos(phi-phib), (d-wd) * np.sin(phi-phib))
p['p2'] = ((d+wd) * np.cos(phi-phib), (d+wd) * np.sin(phi-phib))
p['p3'] = ((d+wd) * np.cos(phi+phib), (d+wd) * np.sin(phi+phib))
p['p4'] = ((d-wd) * np.cos(phi+phib), (d-wd) * np.sin(phi+phib))
plt.figure(figsize=(10,5))
plt.subplot(121)
[plt.scatter(v[0], v[1], s=10) for k,v in p.iteritems()]
plt.plot((0, d*np.cos(phi)), (0, d*np.sin(phi)), c='r', alpha=0.5)
plt.axis('equal')
plt.xlabel('x [$m$]')
plt.ylabel('y [$m$]')
plt.title('Error Bounding Box')
plt.scatter(0,0, s=50, c='k', label='Sensor')
plt.subplot(122)
[plt.scatter(v[0], v[1], s=100) for k,v in p.iteritems()]
plt.axis('equal')
axlims = plt.axis()
plt.plot((0, d*np.cos(phi)), (0, d*np.sin(phi)), c='r', alpha=0.5)
plt.axis(axlims)
plt.title('Error Bounding Box (Zoom In)')
plt.tight_layout()
#plt.savefig('InverseSensorModel-Langerwisch-BoundingBox.png', dpi=150)
return plt
# <headingcell level=4>
# Including Beam Width
# <markdowncell>
# Moreover, the width of the laser beam has to be considered, because it actually never starts with beam width 0.
# Therefore, we displace the origin of the beam virtually to behind. The distance [d] is extended by
# <codecell>
@interact
def plotmultivargauss(wd = widgets.FloatSliderWidget(min=0.005, max=1.0, step=0.005, value=0.05, description=""), \
phib = widgets.FloatSliderWidget(min=0.01, max=1.0, step=0.01, value=0.01, description=""), \
d = widgets.FloatSliderWidget(min=0.0, max=10.0, step=0.1, value=1.0, description=""), \
phi = widgets.FloatSliderWidget(min=-1.0, max=1.0, step=0.1, value=0.6, description=""), \
wb = widgets.FloatSliderWidget(min=0.01, max=1.0, step=0.01, value=0.01, description="")):
dd = 1.0/np.tan(phib/2.0) * wb/2
p = {}
p['p1'] = (((d+dd-wd) * np.cos(phi-phib)) - dd*np.cos(phi), ((d+dd-wd) * np.sin(phi-phib)) - dd*np.sin(phi))
p['p2'] = (((d+dd+wd) * np.cos(phi-phib)) - dd*np.cos(phi), ((d+dd+wd) * np.sin(phi-phib)) - dd*np.sin(phi))
p['p3'] = (((d+dd-wd) * np.cos(phi+phib)) - dd*np.cos(phi), ((d+dd-wd) * np.sin(phi+phib)) - dd*np.sin(phi))
p['p4'] = (((d+dd+wd) * np.cos(phi+phib)) - dd*np.cos(phi), ((d+dd+wd) * np.sin(phi+phib)) - dd*np.sin(phi))
plt.figure(figsize=(10,5))
plt.subplot(121)
[plt.scatter(v[0], v[1], s=10) for k,v in p.iteritems()]
plt.plot((0, d*np.cos(phi)), (0, d*np.sin(phi)), c='r', alpha=0.5)
plt.axis('equal')
plt.title('Error Bounding Box')
plt.scatter(0,0, s=50, c='k', label='Sensor')
plt.subplot(122)
[plt.scatter(v[0], v[1], s=100) for k,v in p.iteritems()]
plt.axis('equal')
axlims = plt.axis()
plt.plot((0, d*np.cos(phi)), (0, d*np.sin(phi)), c='r', alpha=0.5)
plt.axis(axlims)
plt.title('Error Bounding Box (Zoom In)')
plt.tight_layout()
return plt