Compare commits
6 Commits
18aa441f82
...
2a7f22c4e3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2a7f22c4e3 | ||
|
|
40a9bc5d98 | ||
|
|
c77e229d9c | ||
|
|
75d25bc9e4 | ||
|
|
ca7ba62e6b | ||
|
|
2ed95e235b |
8
.gitignore
vendored
8
.gitignore
vendored
@ -1,6 +1,2 @@
|
||||
filter/__pycache__
|
||||
filter/*.pyc
|
||||
examples/__pycache__
|
||||
examples/*.pyc
|
||||
display/__pycache__
|
||||
display/*.pyc
|
||||
__pycache__
|
||||
*.pyc
|
||||
|
||||
@ -15,5 +15,7 @@ $ pip install numpy matplotlib geopy
|
||||
From the root directory of this repository run
|
||||
|
||||
```bash
|
||||
$ python main.py
|
||||
```
|
||||
$ python -m kalman_filter
|
||||
```
|
||||
|
||||
Which example runs can be configured in `kalman_filter/__main__.py`
|
||||
|
||||
16
kalman_filter/__main__.py
Normal file
16
kalman_filter/__main__.py
Normal file
@ -0,0 +1,16 @@
|
||||
from kalman_filter.examples import gps_measurement as gps
|
||||
from kalman_filter.examples import second_order_system as sos
|
||||
from kalman_filter.examples import second_order_system_animated as sos_anim
|
||||
from kalman_filter.examples import gps_two_sources_animated as gps_ts_anim
|
||||
from kalman_filter.filter.kalman_filter import LinearKalmanFilter
|
||||
|
||||
|
||||
def main():
|
||||
#gps.run(LinearKalmanFilter)
|
||||
#sos.run(LinearKalmanFilter)
|
||||
sos_anim.run(LinearKalmanFilter)
|
||||
#gps_ts_anim.run(LinearKalmanFilter)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@ -1,6 +1,5 @@
|
||||
import matplotlib.pyplot as plt
|
||||
from matplotlib.animation import FuncAnimation
|
||||
import numpy as np
|
||||
|
||||
|
||||
class Displayer:
|
||||
@ -44,7 +43,7 @@ class Displayer:
|
||||
self._objects.append(self._circle_map[obj_name])
|
||||
|
||||
|
||||
# Functions to be used in the animation callback
|
||||
# Functions to be used in the callback
|
||||
|
||||
|
||||
def move_object(self, obj_name, position):
|
||||
@ -63,7 +62,7 @@ class Displayer:
|
||||
self._circle_map[obj_name].set_alpha(1)
|
||||
|
||||
|
||||
# Start the animation
|
||||
# Display functions
|
||||
|
||||
|
||||
def animate(self, n_steps, anim_callback):
|
||||
@ -78,4 +77,17 @@ class Displayer:
|
||||
interval=self._frame_interval,
|
||||
init_func=self.__init_animation,
|
||||
blit=False)
|
||||
plt.show()
|
||||
plt.show()
|
||||
|
||||
|
||||
def save_frames(self, frames, callback, prefix="fig-", ext="png"):
|
||||
n_steps = max(frames) + 1
|
||||
|
||||
self.__init_animation()
|
||||
|
||||
for t in range(1, n_steps):
|
||||
callback(self, t)
|
||||
self._ax.legend()
|
||||
|
||||
if t in frames:
|
||||
self._fig.savefig(prefix + str(t) + "." + ext, transparent=True, bbox_inches='tight')
|
||||
@ -56,7 +56,7 @@ def run(kalman_filter_t):
|
||||
# Read data
|
||||
|
||||
x0_ground_truth = [48.993552704, 8.371038159]
|
||||
x_measurement = read_csv_lat_long('examples/res/29_03_2022_Unterreut_8_Karlsruhe.csv')
|
||||
x_measurement = read_csv_lat_long('kalman_filter/examples/res/29_03_2022_Unterreut_8_Karlsruhe.csv')
|
||||
|
||||
|
||||
# Simulation parameter definitions
|
||||
@ -1,9 +1,6 @@
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
from time import sleep
|
||||
from matplotlib.animation import FuncAnimation
|
||||
|
||||
from display.dislpay_2d import Displayer
|
||||
from kalman_filter.display.display_2d import Displayer
|
||||
|
||||
|
||||
def run(kalman_filter_t):
|
||||
@ -78,4 +75,5 @@ def run(kalman_filter_t):
|
||||
disp.register_object("filtered", "blue")
|
||||
disp.register_object("ground_truth", "green")
|
||||
|
||||
disp.animate(n_steps=n_iterations, anim_callback=update)
|
||||
#disp.animate(n_steps=n_iterations, anim_callback=update)
|
||||
disp.save_frames([1, 20, 70], update)
|
||||
@ -1,9 +1,6 @@
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
from time import sleep
|
||||
from matplotlib.animation import FuncAnimation
|
||||
|
||||
from display.dislpay_2d import Displayer
|
||||
from kalman_filter.display.display_2d import Displayer
|
||||
|
||||
|
||||
def run(kalman_filter_t):
|
||||
@ -55,7 +52,7 @@ def run(kalman_filter_t):
|
||||
disp.move_object("measurement", [x_measurement[:, 0][t], 0])
|
||||
disp.set_circle_radius("measurement", std_dev[0])
|
||||
disp.move_object("filtered", [x_kalman[:, 0][t], 0])
|
||||
disp.set_circle_radius("filtered", P_kalman[:,0][t])
|
||||
disp.set_circle_radius("filtered", np.sqrt(P_kalman[:,0][t]))
|
||||
disp.move_object("ground_truth", [x_ground_truth[:, 0][t], 0])
|
||||
disp.set_circle_radius("ground_truth", 0)
|
||||
|
||||
0
kalman_filter/filter/__init__.py
Normal file
0
kalman_filter/filter/__init__.py
Normal file
16
main.py
16
main.py
@ -1,16 +0,0 @@
|
||||
from examples import gps_measurement as gps
|
||||
from examples import second_order_system as sos
|
||||
from examples import second_order_system_animated as sos_anim
|
||||
from examples import gps_two_sources_animated as gps_ts_anim
|
||||
from filter.kalman_filter import LinearKalmanFilter
|
||||
|
||||
|
||||
def main():
|
||||
#gps.run(LinearKalmanFilter)
|
||||
#sos.run(LinearKalmanFilter)
|
||||
#sos_anim.run(LinearKalmanFilter)
|
||||
gps_ts_anim.run(LinearKalmanFilter)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Loading…
Reference in New Issue
Block a user