Skip to content

Commit 5a2b3e0

Browse files
committed
debug: MovingHorizonEstimator now uses covestim buffer
Ensure that the type used in the covariance estimator are not views (does not work with the EKF with `strict=Val(true)` option of DI.jl)
1 parent cf7ac4c commit 5a2b3e0

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/estimator/mhe/execute.jl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,10 @@ end
445445
"Correct the covariance estimate at arrival using `covestim` [`StateEstimator`](@ref)."
446446
function correct_cov!(estim::MovingHorizonEstimator)
447447
nym, nd = estim.nym, estim.model.nd
448-
y0marr, d0arr = @views estim.Y0m[1:nym], estim.D0[1:nd]
448+
buffer = estim.covestim.buffer
449+
y0marr, d0arr = buffer.ym, buffer.d
450+
y0marr .= @views estim.Y0m[1:nym]
451+
d0arr .= @views estim.D0[1:nd]
449452
estim.covestim.x̂0 .= estim.x̂0arr_old
450453
estim.covestim.P̂ .= estim.P̂arr_old
451454
try
@@ -468,7 +471,11 @@ end
468471
"Update the covariance estimate at arrival using `covestim` [`StateEstimator`](@ref)."
469472
function update_cov!(estim::MovingHorizonEstimator)
470473
nu, nd, nym = estim.model.nu, estim.model.nd, estim.nym
471-
u0arr, y0marr, d0arr = @views estim.U0[1:nu], estim.Y0m[1:nym], estim.D0[1:nd]
474+
buffer = estim.covestim.buffer
475+
u0arr, y0marr, d0arr = buffer.u, buffer.ym, buffer.d
476+
u0arr .= @views estim.U0[1:nu]
477+
y0marr .= @views estim.Y0m[1:nym]
478+
d0arr .= @views estim.D0[1:nd]
472479
estim.covestim.x̂0 .= estim.x̂0arr_old
473480
estim.covestim.P̂ .= estim.P̂arr_old
474481
try

0 commit comments

Comments
 (0)