@@ -80,7 +80,7 @@ function update_estimate!(estim::MovingHorizonEstimator{NT}, u, ym, d) where NT<
80
80
x̂ .= X̂[end - nx̂+ 1 : end ]
81
81
if Nk == estim. He
82
82
uarr, ymarr, darr = estim. U[1 : model. nu], estim. Ym[1 : nym], estim. D[1 : model. nd]
83
- update_cov! (estim. P̂arr_old, estim, model , uarr, ymarr, darr)
83
+ update_cov! (estim, model, estim. x̂arr_old, estim . P̂arr_old , uarr, ymarr, darr)
84
84
estim. invP̄. data .= Hermitian (inv (estim. P̂arr_old), :L )
85
85
end
86
86
return nothing
@@ -324,16 +324,16 @@ function trunc_bounds(estim::MovingHorizonEstimator{NT}, Bmin, Bmax, n) where NT
324
324
end
325
325
326
326
" Update the covariance `P̂` with the `KalmanFilter` if `model` is a `LinModel`."
327
- function update_cov! (P̂, estim:: MovingHorizonEstimator , :: LinModel , u, ym, d)
327
+ function update_cov! (estim:: MovingHorizonEstimator , :: LinModel , _ , P̂ , u, ym, d)
328
328
return update_estimate_kf! (estim, u, ym, d, estim. Â, estim. Ĉ[estim. i_ym, :], P̂)
329
329
end
330
330
" Update it with the `ExtendedKalmanFilter` if model is not a `LinModel`."
331
- function update_cov! (P̂, estim:: MovingHorizonEstimator , model:: SimModel , u, ym, d)
331
+ function update_cov! (estim:: MovingHorizonEstimator , model:: SimModel , x̂, P̂ , u, ym, d)
332
332
# TODO : also support UnscentedKalmanFilter
333
333
x̂next, ŷ = similar (estim. x̂), similar (model. yop)
334
- F̂ = ForwardDiff. jacobian ((x̂next, x̂) -> f̂! (x̂next, estim, estim. model, x̂, u, d), x̂next, estim . x̂)
335
- Ĥ = ForwardDiff. jacobian ((ŷ, x̂) -> ĥ! (ŷ, estim, estim. model, x̂, d), ŷ, estim . x̂)
336
- return update_estimate_kf! (estim, u, ym, d, F̂, Ĥ[estim. i_ym, :], P̂)
334
+ F̂ = ForwardDiff. jacobian ((x̂next, x̂) -> f̂! (x̂next, estim, estim. model, x̂, u, d), x̂next, x̂)
335
+ Ĥ = ForwardDiff. jacobian ((ŷ, x̂) -> ĥ! (ŷ, estim, estim. model, x̂, d), ŷ, x̂)
336
+ return update_estimate_kf! (estim, u, ym, d, F̂, Ĥ[estim. i_ym, :], P̂)
337
337
end
338
338
339
339
0 commit comments