From 75d25bc9e4edf40def9f0e9ef418133691f95eb6 Mon Sep 17 00:00:00 2001 From: Andreas Tsouchlos Date: Wed, 27 Apr 2022 15:23:04 +0200 Subject: [PATCH] Restructured project --- .gitignore | 8 ++------ {display => kalman_filter}/__init__.py | 0 kalman_filter/__main__.py | 16 ++++++++++++++++ {examples => kalman_filter/display}/__init__.py | 0 {display => kalman_filter/display}/display_2d.py | 1 - {filter => kalman_filter/examples}/__init__.py | 0 .../examples}/gps_measurement.py | 2 +- .../examples}/gps_two_sources_animated.py | 5 +---- .../res/29_03_2022_Unterreut_8_Karlsruhe.csv | 0 ...3_2022_Unterreut_8_Karlsruhe_angle_length.csv | 0 .../examples}/second_order_system.py | 0 .../examples}/second_order_system_animated.py | 7 ++----- kalman_filter/filter/__init__.py | 0 .../filter}/kalman_filter.py | 0 main.py | 16 ---------------- 15 files changed, 22 insertions(+), 33 deletions(-) rename {display => kalman_filter}/__init__.py (100%) create mode 100644 kalman_filter/__main__.py rename {examples => kalman_filter/display}/__init__.py (100%) rename {display => kalman_filter/display}/display_2d.py (99%) rename {filter => kalman_filter/examples}/__init__.py (100%) rename {examples => kalman_filter/examples}/gps_measurement.py (96%) rename {examples => kalman_filter/examples}/gps_two_sources_animated.py (93%) rename {examples => kalman_filter/examples}/res/29_03_2022_Unterreut_8_Karlsruhe.csv (100%) rename {examples => kalman_filter/examples}/res/29_03_2022_Unterreut_8_Karlsruhe_angle_length.csv (100%) rename {examples => kalman_filter/examples}/second_order_system.py (100%) rename {examples => kalman_filter/examples}/second_order_system_animated.py (89%) create mode 100644 kalman_filter/filter/__init__.py rename {filter => kalman_filter/filter}/kalman_filter.py (100%) delete mode 100644 main.py diff --git a/.gitignore b/.gitignore index bcb4a87..8d35cb3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,2 @@ -filter/__pycache__ -filter/*.pyc -examples/__pycache__ -examples/*.pyc -display/__pycache__ -display/*.pyc +__pycache__ +*.pyc diff --git a/display/__init__.py b/kalman_filter/__init__.py similarity index 100% rename from display/__init__.py rename to kalman_filter/__init__.py diff --git a/kalman_filter/__main__.py b/kalman_filter/__main__.py new file mode 100644 index 0000000..d7aa5cc --- /dev/null +++ b/kalman_filter/__main__.py @@ -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() diff --git a/examples/__init__.py b/kalman_filter/display/__init__.py similarity index 100% rename from examples/__init__.py rename to kalman_filter/display/__init__.py diff --git a/display/display_2d.py b/kalman_filter/display/display_2d.py similarity index 99% rename from display/display_2d.py rename to kalman_filter/display/display_2d.py index fd5b209..b2c9209 100644 --- a/display/display_2d.py +++ b/kalman_filter/display/display_2d.py @@ -1,6 +1,5 @@ import matplotlib.pyplot as plt from matplotlib.animation import FuncAnimation -import numpy as np class Displayer: diff --git a/filter/__init__.py b/kalman_filter/examples/__init__.py similarity index 100% rename from filter/__init__.py rename to kalman_filter/examples/__init__.py diff --git a/examples/gps_measurement.py b/kalman_filter/examples/gps_measurement.py similarity index 96% rename from examples/gps_measurement.py rename to kalman_filter/examples/gps_measurement.py index 9ae1ee8..28c7419 100644 --- a/examples/gps_measurement.py +++ b/kalman_filter/examples/gps_measurement.py @@ -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 diff --git a/examples/gps_two_sources_animated.py b/kalman_filter/examples/gps_two_sources_animated.py similarity index 93% rename from examples/gps_two_sources_animated.py rename to kalman_filter/examples/gps_two_sources_animated.py index fdc54c9..e78ac7b 100644 --- a/examples/gps_two_sources_animated.py +++ b/kalman_filter/examples/gps_two_sources_animated.py @@ -1,9 +1,6 @@ -import matplotlib.pyplot as plt import numpy as np -from time import sleep -from matplotlib.animation import FuncAnimation -from display.display_2d import Displayer +from kalman_filter.display.display_2d import Displayer def run(kalman_filter_t): diff --git a/examples/res/29_03_2022_Unterreut_8_Karlsruhe.csv b/kalman_filter/examples/res/29_03_2022_Unterreut_8_Karlsruhe.csv similarity index 100% rename from examples/res/29_03_2022_Unterreut_8_Karlsruhe.csv rename to kalman_filter/examples/res/29_03_2022_Unterreut_8_Karlsruhe.csv diff --git a/examples/res/29_03_2022_Unterreut_8_Karlsruhe_angle_length.csv b/kalman_filter/examples/res/29_03_2022_Unterreut_8_Karlsruhe_angle_length.csv similarity index 100% rename from examples/res/29_03_2022_Unterreut_8_Karlsruhe_angle_length.csv rename to kalman_filter/examples/res/29_03_2022_Unterreut_8_Karlsruhe_angle_length.csv diff --git a/examples/second_order_system.py b/kalman_filter/examples/second_order_system.py similarity index 100% rename from examples/second_order_system.py rename to kalman_filter/examples/second_order_system.py diff --git a/examples/second_order_system_animated.py b/kalman_filter/examples/second_order_system_animated.py similarity index 89% rename from examples/second_order_system_animated.py rename to kalman_filter/examples/second_order_system_animated.py index 76f9856..5b44c4c 100644 --- a/examples/second_order_system_animated.py +++ b/kalman_filter/examples/second_order_system_animated.py @@ -1,9 +1,6 @@ -import matplotlib.pyplot as plt import numpy as np -from time import sleep -from matplotlib.animation import FuncAnimation -from display.display_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) diff --git a/kalman_filter/filter/__init__.py b/kalman_filter/filter/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/filter/kalman_filter.py b/kalman_filter/filter/kalman_filter.py similarity index 100% rename from filter/kalman_filter.py rename to kalman_filter/filter/kalman_filter.py diff --git a/main.py b/main.py deleted file mode 100644 index 9d2c364..0000000 --- a/main.py +++ /dev/null @@ -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()