Skip to content

Commit 0bed6e6

Browse files
committed
overkill
1 parent ccf5a67 commit 0bed6e6

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/DiscreteKalmanFilter.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ State is `[angle, gyro_bias]`.
1919
mutable struct DiscreteKalmanFilter
2020
x::SVector{2, Float32} # State [angle, bias]
2121
P::SMatrix{2, 2, Float32, 4} # Covariance
22-
Q::SMatrix{2, 2, Float32, 4} # Process noise covariance
23-
R::SMatrix{1, 1, Float32, 1} # Measurement noise covariance
22+
const Q::SMatrix{2, 2, Float32, 4} # Process noise covariance
23+
const R::SMatrix{1, 1, Float32, 1} # Measurement noise covariance
2424
end
2525

2626
"""
@@ -45,7 +45,7 @@ Prediction step: propagate state and covariance using gyro measurement `u` as in
4545
x = A * x + B * u
4646
P = A * P * A' + Q
4747
"""
48-
function predict!(kf::DiscreteKalmanFilter, u::Float32)
48+
@inline @fastmath function predict!(kf::DiscreteKalmanFilter, u::Float32)
4949
kf.x = Ad * kf.x + Bd * u
5050
kf.P = Ad * kf.P * Ad' + kf.Q
5151
nothing
@@ -61,7 +61,7 @@ Update step: correct state and covariance using accelerometer angle measurement
6161
x = x + K * (y - C * x)
6262
P = (I - K * C) * P
6363
"""
64-
function correct!(kf::DiscreteKalmanFilter, y::Float32)
64+
@inline @fastmath function correct!(kf::DiscreteKalmanFilter, y::Float32)
6565
# Innovation covariance (1×1 matrix)
6666
S = Cd * kf.P * Cd' + kf.R
6767

0 commit comments

Comments
 (0)