AerospaceNU / AerospaceNU/stm32-avionics

Calculate kalman gain at runtime using curve fit

未关闭
#109 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
has attachment
主要语言
C
星标
5
派生
0
PR 合并指标
30 天内没有已合并 PR

描述

![image](https://github.com/AerospaceNU/stm32-avionics/assets/29715865/92756099-65ed-4265-9b89-589acd92851a)

For a linear system, kalman gain varies linearly with discretization timestep (loop speed). Proof is left as an exercise for the reader.

```
import control as ct
import frccontrol as fct
import numpy as np
import matplotlib.pyplot as plt

sysc = ct.ss(np.array([[0, 1], [0, 0]]), np.array(
[[0], [1]]), np.array([1, 0]), np.array([0]))

# units of m and m/s
state_std_devs = [0.5, 3]
# units of m
measurement_std_devs = [80]

dt_list = []
gain_list = []

for dt in np.arange(0.001, 0.011, 0.001):
observer = fct.KalmanFilter(sysc, state_std_devs, measurement_std_devs, dt)

print(f"{dt}, {observer.K[0]}, {observer.K[1]}")

gain_list.append(observer.K)
dt_list.append(dt * 1000)

gain_list = np.array(gain_list)

plt.figure()
plt.scatter(dt_list, gain_list[:,0], label="K[0,0]")
plt.scatter(dt_list, gain_list[:,1], label="K[1,0]")

plt.title("Kalman gain vs discretization timestep")
plt.xlabel("dt, ms")
plt.ylabel("gain, output per error")

plt.legend()

plt.show()
```

requirements.txt
```
frccontrol
control
numpy
matplotlib
```

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。