Skip to content

Commit 5a961bd

Browse files
committed
debug: allow arg in setstate! with SteadyKalmanFilter
1 parent b2ba5df commit 5a961bd

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

src/estimator/construct.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,15 @@ struct KalmanCovariances{
5656
::Q̂C, R̂::R̂C, P̂_0, He
5757
) where {NT<:Real, Q̂C<:AbstractMatrix{NT}, R̂C<:AbstractMatrix{NT}}
5858
if isnothing(P̂_0)
59-
P̂_0 = zeros(NT, 0, 0)
59+
P̂_0 = zeros(NT, 0, 0) # does not apply to steady-state Kalman filter
60+
= zeros(NT, size(Q̂)) # will hold the steady-state error covariance
61+
else
62+
= copy(P̂_0)
6063
end
6164
P̂_0 = Hermitian(P̂_0, :L)
65+
= Hermitian(P̂, :L)
6266
= Hermitian(Q̂, :L)
6367
= Hermitian(R̂, :L)
64-
= copy(Q̂)
6568
# the following variables are only for the moving horizon estimator:
6669
invP̄, invQ̂, invR̂ = copy(P̂_0), copy(Q̂), copy(R̂)
6770
try

src/estimator/kalman.jl

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,6 @@ function setmodel_estimator!(estim::SteadyKalmanFilter, model, _ , _ , _ , Q̂,
221221
return nothing
222222
end
223223

224-
"Throw an error if P̂ != nothing."
225-
function setstate_cov!(::SteadyKalmanFilter, P̂)
226-
isnothing(P̂) || error("SteadyKalmanFilter does not compute an estimation covariance matrix P̂.")
227-
return nothing
228-
end
229-
230224
@doc raw"""
231225
correct_estimate!(estim::SteadyKalmanFilter, y0m, d0)
232226

src/estimator/mhe/construct.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,10 @@ This syntax allows nonzero off-diagonal elements in ``\mathbf{P̂_i}, \mathbf{Q
423423
where ``\mathbf{P̂_i}`` is the initial estimation covariance, provided by `P̂_0` argument. The
424424
keyword argument `covestim` also allows specifying a custom [`StateEstimator`](@ref) object
425425
for the estimation of covariance at the arrival ``\mathbf{P̂}_{k-N_k}(k-N_k+p)``. The
426-
supported types are [`KalmanFilter`](@ref), [`UnscentedKalmanFilter`](@ref) and
427-
[`ExtendedKalmanFilter`](@ref).
426+
supported types are [`SteadyKalmanFilter`](@ref), [`KalmanFilter`](@ref),
427+
[`UnscentedKalmanFilter`](@ref) and [`ExtendedKalmanFilter`](@ref). A constant arrival
428+
covariance is supported with [`SteadyKalmanFilter`](@ref), and by setting the `P̂` argument
429+
of [`setstate!`](@ref) at the desired value.
428430
"""
429431
function MovingHorizonEstimator(
430432
model::SM, He, i_ym, nint_u, nint_ym, P̂_0, Q̂, R̂, Cwt=Inf;

0 commit comments

Comments
 (0)