Skip to content

Commit 4384a5c

Browse files
committed
BFB mesure, motion models are ready
1 parent 7e5dcd9 commit 4384a5c

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

MyCode/Bayes Filter/bayes_filter_viz.py

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

88

9-
109
class BayesFilterBoat(object):
1110

1211
def __init__(self):
@@ -18,22 +17,37 @@ def main(self):
1817
self._draw_main_window()
1918

2019
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))
20+
self.fig = plt.figure(figsize=(10, 8), constrained_layout=False)
2421
gs = self.fig.add_gridspec(2, 2)
2522

2623
# sim axis
2724
self.ax_sim = self.fig.add_subplot(gs[0, :])
2825
self.ax_sim.set_title('Simulation')
26+
self.set_ylim(self.ax_sim)
27+
self.ax_sim.set_xlim(-1, 11)
2928

3029
# Mesurement model
3130
self.ax_me = self.fig.add_subplot(gs[1, 0])
32-
self.ax_me.set_title('Mesurement Model')
31+
32+
self.me_y = np.ones(shape=(3,))/3
33+
self.me_x = np.arange(len(self.me_y)) - 1
34+
35+
self.ax_me.set_title(r'Mesurement model $p(Z_t|X_t)$')
36+
bar_plot(self.ax_me, self.me_x, self.me_y, color='r')
37+
self.set_ylim(self.ax_me)
3338

3439
# Motion model
3540
self.ax_mo = self.fig.add_subplot(gs[1, 1])
36-
self.ax_mo.set_title('Motion Model')
41+
self.ax_mo.set_title(r'Motion model $p(X_{t+1}|X_t)$')
42+
43+
self.mo_p = [0, 0.75, 0.25]
44+
self.mo_y = np.array(self.mo_p)
45+
self.mo_x = np.arange(len(self.mo_y))
46+
47+
bar_plot(self.ax_mo, self.mo_x, self.mo_y, color='b')
48+
self.ax_mo.axvline(0.25, c='k', ls='--')
49+
self.ax_mo.axvline(-0.25, c='k', ls='--')
50+
self.set_ylim(self.ax_mo)
3751

3852
line, = self.ax_sim.plot([0], [0])
3953
self.cid = line.figure.canvas.mpl_connect('button_press_event', self)
@@ -42,6 +56,11 @@ def _draw_main_window(self):
4256
self.ys = list(line.get_ydata())
4357
plt.show()
4458

59+
def set_ylim(self, ax):
60+
ax.set_ylim(0, 1)
61+
ax.set_axisbelow(True)
62+
ax.grid(ls='--')
63+
4564
def __call__(self, event):
4665
# print('click', event)
4766
if event.inaxes != self.line.axes:

0 commit comments

Comments
 (0)