diff --git a/display/__init__.py b/display/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/display/__init__.pyc b/display/__init__.pyc new file mode 100644 index 0000000..af18ee2 Binary files /dev/null and b/display/__init__.pyc differ diff --git a/display/dislpay_2d.py b/display/dislpay_2d.py new file mode 100644 index 0000000..1da68b8 --- /dev/null +++ b/display/dislpay_2d.py @@ -0,0 +1,35 @@ +import matplotlib.pyplot as plt +from matplotlib.animation import FuncAnimation +import numpy as np +import matplotlib.gridspec as gridspec +from mpl_toolkits.axes_grid1.inset_locator import zoomed_inset_axes +import functools + + +class Displayer: + def __init__(self, width, height): + self._fig, self._ax = plt.subplots() + self._fig.set_figwidth(width) + self._fig.set_figheight(height) + self._xdata, self._ydata = [], [] + self._obj, = plt.plot([], [], 'ro') + self._circle = plt.Circle((5, 5), 1, color='r', fill=False) + + self._objects = [self._obj, self._circle] + + def __init_animation(self): + self._ax.set_xlim(0, 20) + self._ax.set_ylim(0, 20) + self._ax.add_patch(self._circle) + return self._objects + + def __update_animation(self, t): + self._obj.set_data([t, t]) + self._circle.center = (t, t) + self._circle.radius = t*0.1 + return self._objects + + def animate(self, n_steps): + anim = FuncAnimation(self._fig, self.__update_animation, frames=np.linspace(0, n_steps-1, n_steps), + init_func=self.__init_animation, blit=True) + plt.show() \ No newline at end of file diff --git a/display/dislpay_2d.pyc b/display/dislpay_2d.pyc new file mode 100644 index 0000000..ab6997d Binary files /dev/null and b/display/dislpay_2d.pyc differ diff --git a/examples/gps_fusion.py b/examples/gps_fusion.py new file mode 100644 index 0000000..56a34d7 --- /dev/null +++ b/examples/gps_fusion.py @@ -0,0 +1,13 @@ +import matplotlib.pyplot as plt +import numpy as np +from time import sleep +from matplotlib.animation import FuncAnimation + +from display.dislpay_2d import Displayer + + + +def run(): + disp = Displayer(width=6, height=6) + # disp.show_object([1, 1], 4, "green") + disp.animate(n_steps = 100) \ No newline at end of file diff --git a/examples/gps_fusion.pyc b/examples/gps_fusion.pyc new file mode 100644 index 0000000..9d3ff79 Binary files /dev/null and b/examples/gps_fusion.pyc differ diff --git a/examples/gps_measurement.py b/examples/gps_measurement.py index 88ac914..b512d8f 100644 --- a/examples/gps_measurement.py +++ b/examples/gps_measurement.py @@ -1,4 +1,3 @@ -from filter.kalman_filter import LinearKalmanFilter import matplotlib.pyplot as plt import csv import numpy as np @@ -53,7 +52,7 @@ The reset of the parameters are empirically determined """ -def simulate(kalman_filter_t): +def run(kalman_filter_t): # Read data x0_actual = [48.993552704, 8.371038159] diff --git a/examples/gps_measurement.pyc b/examples/gps_measurement.pyc index f438252..a1b0186 100644 Binary files a/examples/gps_measurement.pyc and b/examples/gps_measurement.pyc differ diff --git a/examples/second_order_system.py b/examples/second_order_system.py index 68e7f8f..14410b2 100644 --- a/examples/second_order_system.py +++ b/examples/second_order_system.py @@ -1,4 +1,3 @@ -from filter.kalman_filter import LinearKalmanFilter import matplotlib.pyplot as plt import numpy as np @@ -25,7 +24,7 @@ The reset of the parameters are empirically determined """ -def simulate(kalman_filter_t): +def run(kalman_filter_t): # Simulation parameter definitions n_iterations = 500 diff --git a/examples/second_order_system.pyc b/examples/second_order_system.pyc index 13edb6d..e952e39 100644 Binary files a/examples/second_order_system.pyc and b/examples/second_order_system.pyc differ diff --git a/main.py b/main.py index 4e067e6..773b78b 100644 --- a/main.py +++ b/main.py @@ -1,11 +1,13 @@ from examples import gps_measurement as gps from examples import second_order_system as sos -from filter.kalman_filter import LinearKalmanFilter +from examples import gps_fusion def main(): - gps.simulate(LinearKalmanFilter) - #sos.simulate(LinearKalmanFilter) + #gps.run(LinearKalmanFilter) + #sos.run(LinearKalmanFilter) + gps_fusion.run() + if __name__ == '__main__': main()