Reorganize directory structure

This commit is contained in:
Andreas Tsouchlos 2022-04-21 13:19:07 +02:00
parent 2ff5225c01
commit f74f06f46f
15 changed files with 25 additions and 25 deletions

View File

@ -15,7 +15,5 @@ $ pip install numpy matplotlib geopy
From the root directory of this repository run
```bash
$ python -m kalman_filter
```
Which example is run can be changed in `kalman_filter/__main__.py`
$ python main.py
```

BIN
examples/__init__.pyc Normal file

Binary file not shown.

View File

@ -1,6 +1,7 @@
from .kalman_filter import *
from filter.kalman_filter import LinearKalmanFilter
import matplotlib.pyplot as plt
import csv
import numpy as np
import geopy.distance
@ -52,11 +53,11 @@ The reset of the parameters are empirically determined
"""
def simulate():
def simulate(kalman_filter_t):
# Read data
x0_actual = [48.993552704, 8.371038159]
x_measurement = read_csv_lat_long('res/29_03_2022_Unterreut_8_Karlsruhe.csv')
x_measurement = read_csv_lat_long('examples/res/29_03_2022_Unterreut_8_Karlsruhe.csv')
# Simulation parameter definitions
@ -90,7 +91,7 @@ def simulate():
# Simulation
f = KalmanFilter(x0, P0, H, Q, F, G)
f = kalman_filter_t(x0, P0, H, Q, F, G)
for i in range(1, n_iterations):
@ -126,4 +127,4 @@ def simulate():
ax3.plot(t, x_error_measurement*1000, label="Error in measured position in m")
ax3.legend()
plt.show()
plt.show()

Binary file not shown.

View File

@ -1,5 +1,6 @@
from .kalman_filter import *
from filter.kalman_filter import LinearKalmanFilter
import matplotlib.pyplot as plt
import numpy as np
"""
@ -24,7 +25,7 @@ The reset of the parameters are empirically determined
"""
def simulate():
def simulate(kalman_filter_t):
# Simulation parameter definitions
n_iterations = 500
@ -52,7 +53,7 @@ def simulate():
# Simulation
f = KalmanFilter(x0, P0, H, Q, F, G)
f = kalman_filter_t(x0, P0, H, Q, F, G)
for i in range(1, n_iterations):
@ -72,5 +73,4 @@ def simulate():
plt.plot(t, x_actual[:, 0])
plt.plot(t, x_kalman[:, 0])
plt.plot(t, x_measurement[:, 0])
plt.show()
plt.show()

Binary file not shown.

0
filter/__init__.py Normal file
View File

BIN
filter/__init__.pyc Normal file

Binary file not shown.

View File

@ -30,7 +30,7 @@ def identity_gen(A):
#
class KalmanFilter:
class LinearKalmanFilter:
def __init__(self, x0, P0, H, Q, F, G):
self.x = x0 # Initial state
self.P = P0 # Initial uncertainty

BIN
filter/kalman_filter.pyc Normal file

Binary file not shown.

View File

@ -1,10 +0,0 @@
from . import gps_measurement as gps
from . import second_order_system as sos
def main():
gps.simulate()
# sos.simulate()
if __name__ == '__main__':
main()

11
main.py Normal file
View File

@ -0,0 +1,11 @@
from examples import gps_measurement as gps
from examples import second_order_system as sos
from filter.kalman_filter import LinearKalmanFilter
def main():
gps.simulate(LinearKalmanFilter)
#sos.simulate(LinearKalmanFilter)
if __name__ == '__main__':
main()