@@ -428,7 +428,7 @@ represents the measured outputs of ``\mathbf{ĥ}`` function (and unmeasured one
428428
429429# Arguments
430430- `model::SimModel` : (deterministic) model for the estimations.
431- - `α=1e-3` : alpha parameter, spread of the state distribution ``(0 ≤ α ≤ 1)``.
431+ - `α=1e-3` : alpha parameter, spread of the state distribution ``(0 < α ≤ 1)``.
432432- `β=2` : beta parameter, skewness and kurtosis of the states distribution ``(β ≥ 0)``.
433433- `κ=0` : kappa parameter, another spread parameter ``(0 ≤ κ ≤ 3)``.
434434- `<keyword arguments>` of [`SteadyKalmanFilter`](@ref) constructor.
@@ -565,22 +565,7 @@ noise, respectively.
565565 ISBN9780470045343.
566566"""
567567function update_estimate! (estim:: UnscentedKalmanFilter{NT} , u, ym, d) where NT<: Real
568- return update_estimate_ukf! (estim, u, ym, d, estim. P̂, estim. x̂)
569- end
570-
571- """
572- update_estimate_ukf!(estim::StateEstimator, u, ym, d, P̂, x̂=nothing)
573-
574- Update Unscented Kalman Filter estimates and covariance matrices.
575-
576- Allows code reuse for [`UnscentedKalmanFilter`](@ref) and [`MovingHorizonEstimator`](@ref).
577- See [`update_estimate!(::UnscentedKalmanFilter, ::Any, ::Any, ::Any)`(@ref) docstring
578- for the equations. If `isnothing(x̂)`, only the covariance `P̂` is updated.
579- """
580- function update_estimate_ukf! (
581- estim:: StateEstimator{NT} , u, ym, d, P̂, x̂= nothing
582- ) where NT<: Real
583- Q̂, R̂, K̂ = estim. Q̂, estim. R̂, estim. K̂
568+ x̂, P̂, Q̂, R̂, K̂ = estim. x̂, estim. P̂, estim. Q̂, estim. R̂, estim. K̂
584569 nym, nx̂, nσ = estim. nym, estim. nx̂, estim. nσ
585570 γ, m̂, Ŝ = estim. γ, estim. m̂, estim. Ŝ
586571 # --- initialize matrices ---
@@ -815,34 +800,29 @@ function validate_kfcov(nym, nx̂, Q̂, R̂, P̂0=nothing)
815800end
816801
817802"""
818- update_estimate_kf!(estim::StateEstimator, u, ym, d, Â, Ĉm, P̂, x̂=nothing )
803+ update_estimate_kf!(estim::StateEstimator, u, ym, d, Â, Ĉm, P̂, x̂)
819804
820805Update time-varying/extended Kalman Filter estimates with augmented `Â` and `Ĉm` matrices.
821806
822807Allows code reuse for [`KalmanFilter`](@ref), [`ExtendedKalmanFilterKalmanFilter`](@ref).
823808They update the state `x̂` and covariance `P̂` with the same equations. The extended filter
824809substitutes the augmented model matrices with its Jacobians (`Â = F̂` and `Ĉm = Ĥm`).
825810The implementation uses in-place operations and explicit factorization to reduce
826- allocations. See e.g. [`KalmanFilter`](@ref) docstring for the equations. If `isnothing(x̂)`,
827- only the covariance `P̂` is updated.
811+ allocations. See e.g. [`KalmanFilter`](@ref) docstring for the equations.
828812"""
829- function update_estimate_kf! (
830- estim:: StateEstimator{NT} , u, ym, d, Â, Ĉm, P̂, x̂= nothing
831- ) where NT<: Real
832- Q̂, R̂, M̂ = estim. Q̂, estim. R̂, estim. M̂
813+ function update_estimate_kf! (estim:: StateEstimator{NT} , u, ym, d, Â, Ĉm, P̂, x̂) where NT<: Real
814+ Q̂, R̂, M̂, K̂ = estim. Q̂, estim. R̂, estim. M̂, estim. K̂
833815 mul! (M̂, P̂, Ĉm' )
834816 rdiv! (M̂, cholesky! (Hermitian (Ĉm * P̂ * Ĉm' .+ R̂)))
835- if ! isnothing (x̂)
836- mul! (estim. K̂, Â, M̂)
837- x̂next, ŷ = Vector {NT} (undef, estim. nx̂), Vector {NT} (undef, estim. model. ny)
838- ĥ! (ŷ, estim, estim. model, x̂, d)
839- ŷm = @views ŷ[estim. i_ym]
840- v̂ = ŷm
841- v̂ .= ym .- ŷm
842- f̂! (x̂next, estim, estim. model, x̂, u, d)
843- mul! (x̂next, estim. K̂, v̂, 1 , 1 )
844- estim. x̂ .= x̂next
845- end
817+ mul! (K̂, Â, M̂)
818+ x̂next, ŷ = Vector {NT} (undef, estim. nx̂), Vector {NT} (undef, estim. model. ny)
819+ ĥ! (ŷ, estim, estim. model, x̂, d)
820+ ŷm = @views ŷ[estim. i_ym]
821+ v̂ = ŷm
822+ v̂ .= ym .- ŷm
823+ f̂! (x̂next, estim, estim. model, x̂, u, d)
824+ mul! (x̂next, K̂, v̂, 1 , 1 )
825+ estim. x̂ .= x̂next
846826 P̂. data .= Â * (P̂ .- M̂ * Ĉm * P̂) * Â' .+ Q̂ # .data is necessary for Hermitians
847827 return nothing
848828end
0 commit comments