Skip to content

Commit 2655b9f

Browse files
committed
wip: KalmanFilter with new cov struct
1 parent a400ad0 commit 2655b9f

2 files changed

Lines changed: 7 additions & 9 deletions

File tree

src/estimator/construct.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ struct KalmanCovariances{
7070
inv!(invR̂)
7171
invQ̂_He = repeatdiag(invQ̂, He)
7272
invR̂_He = repeatdiag(invR̂, He)
73-
isdiag(invQ̂_He) && (invQ̂_He = Diagonal(invQ̂_He)) # Q̂C(invQ̂_He) does not work on Julia 1.10
74-
isdiag(invR̂_He) && (invR̂_He = Diagonal(invR̂_He)) # R̂C(invR̂_He) does not work on Julia 1.10
7573
invQ̂_He = Hermitian(invQ̂_He, :L)
7674
invR̂_He = Hermitian(invR̂_He, :L)
7775
return new{NT, Q̂C, R̂C}(P̂_0, P̂, Q̂, R̂, invP̄, invQ̂_He, invR̂_He)

src/estimator/kalman.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,7 +1174,7 @@ end
11741174
function init_estimate_cov!(
11751175
estim::Union{KalmanFilter, UnscentedKalmanFilter, ExtendedKalmanFilter}, _ , _ , _
11761176
)
1177-
estim.P̂ .= estim.P̂_0
1177+
estim.cov.P̂ .= estim.cov.P̂_0
11781178
return nothing
11791179
end
11801180

@@ -1187,8 +1187,8 @@ Allows code reuse for [`KalmanFilter`](@ref), [`ExtendedKalmanFilterKalmanFilter
11871187
See [`update_estimate_kf!`](@ref) for more information.
11881188
"""
11891189
function correct_estimate_kf!(estim::Union{KalmanFilter, ExtendedKalmanFilter}, y0m, d0, Ĉm)
1190-
R̂, K̂ = estim.R̂, estim.
1191-
x̂0, P̂ = estim.x̂0, estim.
1190+
R̂, K̂ = estim.cov.R̂, estim.
1191+
x̂0, P̂ = estim.x̂0, estim.cov.
11921192
# in-place operations to reduce allocations:
11931193
P̂_Ĉmᵀ =
11941194
mul!(P̂_Ĉmᵀ, P̂, Ĉm')
@@ -1213,7 +1213,7 @@ function correct_estimate_kf!(estim::Union{KalmanFilter, ExtendedKalmanFilter},
12131213
end
12141214
P̂corr = estim.buffer.
12151215
mul!(P̂corr, I_minus_K̂_Ĉm, P̂)
1216-
estim.P̂ .= Hermitian(P̂corr, :L)
1216+
estim.cov.P̂ .= Hermitian(P̂corr, :L)
12171217
return nothing
12181218
end
12191219

@@ -1227,8 +1227,8 @@ They predict the state `x̂` and covariance `P̂` with the same equations. See
12271227
[`update_estimate`](@ref) methods for the equations.
12281228
"""
12291229
function predict_estimate_kf!(estim::Union{KalmanFilter, ExtendedKalmanFilter}, u0, d0, Â)
1230-
x̂0corr, P̂corr = estim.x̂0, estim.
1231-
= estim.
1230+
x̂0corr, P̂corr = estim.x̂0, estim.cov.
1231+
= estim.cov.
12321232
x̂0next, û0, k0 = estim.buffer.x̂, estim.buffer.û, estim.buffer.k
12331233
# in-place operations to reduce allocations:
12341234
f̂!(x̂0next, û0, k0, estim, estim.model, x̂0corr, u0, d0)
@@ -1240,6 +1240,6 @@ function predict_estimate_kf!(estim::Union{KalmanFilter, ExtendedKalmanFilter},
12401240
P̂next .= Â_P̂corr_Âᵀ .+
12411241
x̂0next .+= estim.f̂op .- estim.x̂op
12421242
estim.x̂0 .= x̂0next
1243-
estim.P̂ .= Hermitian(P̂next, :L)
1243+
estim.cov.P̂ .= Hermitian(P̂next, :L)
12441244
return nothing
12451245
end

0 commit comments

Comments
 (0)