Skip to content

Commit 0712562

Browse files
committed
refactor: update arrival covariance handling in MovingHorizonEstimator
1 parent 1313f07 commit 0712562

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

check_syntax.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import JuliaFormatter
2+
include("src/estimator/mhe/execute.jl")

src/estimator/mhe/execute.jl

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ function correct_cov!(estim::MovingHorizonEstimator)
709709
correct_estimate!(estim.covestim, y0marr, d0arr)
710710
all(isfinite, estim.covestim.cov.P̂) || error("Arrival covariance P̄ is not finite")
711711
estim.P̂arr_old .= estim.covestim.cov.
712-
invert_cov!(estim, estim.P̂arr_old)
712+
update_arrival_cov!(estim)
713713
catch err
714714
if err isa PosDefException
715715
@error("Arrival covariance P̄ is not positive definite: keeping the old one")
@@ -736,7 +736,7 @@ function update_cov!(estim::MovingHorizonEstimator)
736736
update_estimate!(estim.covestim, y0marr, d0arr, u0arr)
737737
all(isfinite, estim.covestim.cov.P̂) || error("Arrival covariance P̄ is not finite")
738738
estim.P̂arr_old .= estim.covestim.cov.
739-
invert_cov!(estim, estim.P̂arr_old)
739+
update_arrival_cov!(estim)
740740
catch err
741741
if err isa PosDefException
742742
@error("Arrival covariance P̄ is not positive definite: keeping the old one")
@@ -764,6 +764,19 @@ function invert_cov!(estim::MovingHorizonEstimator, P̄)
764764
return nothing
765765
end
766766

767+
"Update the arrival covariance matrix at the next time step based on the covariance estimator type."
768+
function update_arrival_cov!(estim::MovingHorizonEstimator)
769+
_update_arrival_cov!(estim, estim.covestim)
770+
end
771+
772+
function _update_arrival_cov!(estim::MovingHorizonEstimator, ::StateEstimator)
773+
invert_cov!(estim, estim.P̂arr_old)
774+
end
775+
776+
function _update_arrival_cov!(estim::MovingHorizonEstimator, ::SteadyKalmanFilter)
777+
return nothing
778+
end
779+
767780
"""
768781
obj_nonlinprog(estim::MovingHorizonEstimator, ::LinModel, _ , _ , _ , Z̃)
769782

0 commit comments

Comments
 (0)