Skip to content

Commit 7e5dcd9

Browse files
committed
BFB window ready
1 parent 3f1af3a commit 7e5dcd9

File tree

2 files changed

+60
-2
lines changed

2 files changed

+60
-2
lines changed

MyCode/Bayes Filter/bayes_filter_viz.py

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,53 @@
66
from matplotlib.offsetbox import TextArea, DrawingArea, OffsetImage, AnnotationBbox
77

88

9+
910
class BayesFilterBoat(object):
1011

1112
def __init__(self):
12-
pass
13+
self.boat_img = mpimg.imread('/home/sameera/Downloads/sailboat.png')
14+
self.click_counter = 0
15+
self.simulation_scope = 10
1316

17+
def main(self):
18+
self._draw_main_window()
1419

15-
if __name__ == "__main__":
20+
def _draw_main_window(self):
21+
# self.fig, self.axs = plt.subplots(1, 3, figsize=(12, 4))
22+
23+
self.fig = plt.figure(figsize=(10, 8))
24+
gs = self.fig.add_gridspec(2, 2)
25+
26+
# sim axis
27+
self.ax_sim = self.fig.add_subplot(gs[0, :])
28+
self.ax_sim.set_title('Simulation')
29+
30+
# Mesurement model
31+
self.ax_me = self.fig.add_subplot(gs[1, 0])
32+
self.ax_me.set_title('Mesurement Model')
1633

34+
# Motion model
35+
self.ax_mo = self.fig.add_subplot(gs[1, 1])
36+
self.ax_mo.set_title('Motion Model')
37+
38+
line, = self.ax_sim.plot([0], [0])
39+
self.cid = line.figure.canvas.mpl_connect('button_press_event', self)
40+
self.line = line
41+
self.xs = list(line.get_xdata())
42+
self.ys = list(line.get_ydata())
43+
plt.show()
44+
45+
def __call__(self, event):
46+
# print('click', event)
47+
if event.inaxes != self.line.axes:
48+
return
49+
self.xs.append(event.xdata)
50+
self.ys.append(event.ydata)
51+
self.line.set_data(self.xs, self.ys)
52+
self.line.figure.canvas.draw()
53+
54+
55+
if __name__ == "__main__":
1756

1857
boat_bf = BayesFilterBoat()
58+
boat_bf.main()

MyCode/Bayes Filter/line.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from matplotlib import pyplot as plt
2+
3+
fig = plt.figure(figsize=(10, 8))
4+
gs = fig.add_gridspec(2, 2)
5+
6+
7+
ax_sim = fig.add_subplot(gs[0, :])
8+
ax_sim.set_title('Simulation')
9+
10+
11+
ax_me = fig.add_subplot(gs[1, 0])
12+
ax_me.set_title('Mesurement Model')
13+
14+
15+
ax_mo = fig.add_subplot(gs[1, 1])
16+
ax_mo.set_title('Motion Model')
17+
18+
plt.show()

0 commit comments

Comments
 (0)