Skip to content

Commit 6bb2a16

Browse files
authored
Merge pull request #489 from JuliaControl/ukf_cleanup
changed: cleanup in `UnscentedKalmanFilter` implementation
2 parents f7cffa1 + 8fe94ba commit 6bb2a16

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

‎src/estimator/kalman.jl‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -794,8 +794,9 @@ function correct_estimate!(estim::UnscentedKalmanFilter, y0m, d0)
794794
X̂0[:, nx̂+2:end] .= @views X̂0[:, nx̂+2:end] .- γ_sqrtP̂
795795
ŷ0 = estim.buffer.ŷ
796796
for j in axes(Ŷ0m, 2)
797-
@views ĥ!(ŷ0, estim, estim.model, X̂0[:, j], d0)
798-
@views Ŷ0m[:, j] .= ŷ0[estim.i_ym]
797+
x̂0_j, ŷ0m_j = @views X̂0[:, j], Ŷ0m[:, j]
798+
ĥ!(ŷ0, estim, estim.model, x̂0_j, d0)
799+
ŷ0m_j .= @views ŷ0[estim.i_ym]
799800
end
800801
ŷ0m = @views ŷ0[estim.i_ym]
801802
mul!(ŷ0m, Ŷ0m, m̂)
@@ -887,12 +888,13 @@ function update_estimate!(estim::UnscentedKalmanFilter, u0, y0m, d0)
887888
X̂0corr .= x̂0corr
888889
X̂0corr[:, 2:nx̂+1] .= @views X̂0corr[:, 2:nx̂+1] .+ γ_sqrtP̂corr
889890
X̂0corr[:, nx̂+2:end] .= @views X̂0corr[:, nx̂+2:end] .- γ_sqrtP̂corr
890-
X̂0next = X̂0corr
891+
X̂0next = X̂0corr # X̂0next is an alias of X̂0corr
891892
for j in axes(X̂0next, 2)
892-
@views x̂0corr .= X̂0corr[:, j]
893-
@views f̂!(X̂0next[:, j], û0, k̄, estim, estim.model, x̂0corr, u0, d0)
893+
x̂0corr_j, x̂0next_j = @views X̂0corr[:, j], X̂0next[:, j]
894+
@views f̂!(x̂0next, û0, k̄, estim, estim.model, x̂0corr_j, u0, d0)
895+
x̂0next_j .= x̂0next
894896
end
895-
x̂0next .= mul!(x̂0corr, X̂0next, m̂)
897+
mul!(x̂0next, X̂0next, m̂)
896898
X̄0next = estim.X̄0
897899
X̄0next .= X̂0next .- x̂0next
898900
Ŝ_X̄0nextᵀ = estim.X̂0'

0 commit comments

Comments
 (0)