Reorganize directory structure
This commit is contained in:
parent
2ff5225c01
commit
f74f06f46f
@ -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
BIN
examples/__init__.pyc
Normal file
Binary file not shown.
@ -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()
|
||||
BIN
examples/gps_measurement.pyc
Normal file
BIN
examples/gps_measurement.pyc
Normal file
Binary file not shown.
@ -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()
|
||||
BIN
examples/second_order_system.pyc
Normal file
BIN
examples/second_order_system.pyc
Normal file
Binary file not shown.
0
filter/__init__.py
Normal file
0
filter/__init__.py
Normal file
BIN
filter/__init__.pyc
Normal file
BIN
filter/__init__.pyc
Normal file
Binary file not shown.
@ -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
BIN
filter/kalman_filter.pyc
Normal file
Binary file not shown.
@ -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
11
main.py
Normal 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()
|
||||
Loading…
Reference in New Issue
Block a user