|
6 | 6 | from matplotlib.offsetbox import TextArea, DrawingArea, OffsetImage, AnnotationBbox |
7 | 7 |
|
8 | 8 |
|
| 9 | + |
9 | 10 | class BayesFilterBoat(object): |
10 | 11 |
|
11 | 12 | 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 |
13 | 16 |
|
| 17 | + def main(self): |
| 18 | + self._draw_main_window() |
14 | 19 |
|
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') |
16 | 33 |
|
| 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__": |
17 | 56 |
|
18 | 57 | boat_bf = BayesFilterBoat() |
| 58 | + boat_bf.main() |
0 commit comments