Created basic outline of Displayer class
This commit is contained in:
parent
f74f06f46f
commit
2141f7d833
0
display/__init__.py
Normal file
0
display/__init__.py
Normal file
BIN
display/__init__.pyc
Normal file
BIN
display/__init__.pyc
Normal file
Binary file not shown.
35
display/dislpay_2d.py
Normal file
35
display/dislpay_2d.py
Normal file
@ -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()
|
||||
BIN
display/dislpay_2d.pyc
Normal file
BIN
display/dislpay_2d.pyc
Normal file
Binary file not shown.
13
examples/gps_fusion.py
Normal file
13
examples/gps_fusion.py
Normal file
@ -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)
|
||||
BIN
examples/gps_fusion.pyc
Normal file
BIN
examples/gps_fusion.pyc
Normal file
Binary file not shown.
@ -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]
|
||||
|
||||
Binary file not shown.
@ -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
|
||||
|
||||
Binary file not shown.
8
main.py
8
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()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user