@@ -20,9 +20,10 @@ struct SteadyKalmanFilter <: StateEstimator
2020 Q̂:: Hermitian{Float64, Matrix{Float64}}
2121 R̂:: Hermitian{Float64, Matrix{Float64}}
2222 K:: Matrix{Float64}
23- function SteadyKalmanFilter (model, i_ym, nint_ym, Asm, Csm, Q̂, R̂)
23+ function SteadyKalmanFilter (model, i_ym, nint_ym, Q̂, R̂)
2424 nu, nx, ny = model. nu, model. nx, model. ny
2525 nym, nyu = length (i_ym), ny - length (i_ym)
26+ Asm, Csm, nint_ym = init_estimstoch (i_ym, nint_ym)
2627 nxs = size (Asm,1 )
2728 nx̂ = nx + nxs
2829 validate_kfcov (nym, nx̂, Q̂, R̂)
@@ -128,16 +129,22 @@ function SteadyKalmanFilter(
128129 nint_ym:: IntVectorOrInt = fill (1 , length (i_ym)),
129130 σQ_int:: Vector = fill (0.1 , max (sum (nint_ym), 0 ))
130131)
131- if nint_ym == 0 # alias for no output integrator at all :
132- nint_ym = fill (0 , length (i_ym));
133- end
134- Asm, Csm = init_estimstoch (i_ym, nint_ym)
135132 # estimated covariances matrices (variance = σ²) :
136133 Q̂ = Diagonal {Float64} ([σQ ; σQ_int ]. ^ 2 );
137134 R̂ = Diagonal {Float64} (σR.^ 2 );
138- return SteadyKalmanFilter (model, i_ym, nint_ym, Asm, Csm, Q̂ , R̂)
135+ return SteadyKalmanFilter (model, i_ym, nint_ym, Q̂ , R̂)
139136end
140137
138+ @doc raw """
139+ SteadyKalmanFilter(model, i_ym, nint_ym, Q̂, R̂)
140+
141+ Construct the estimator from the augmented covariance matrices `Q̂` and `R̂`.
142+
143+ This syntax allows nonzero off-diagonal elements in ``\m athbf{Q̂, R̂}``.
144+ """
145+ SteadyKalmanFilter (model:: LinModel , i_ym, nint_ym, Q̂, R̂)
146+
147+
141148@doc raw """
142149 updatestate!(estim::SteadyKalmanFilter, u, ym, d=Float64[])
143150
@@ -191,9 +198,17 @@ struct KalmanFilter <: StateEstimator
191198 P̂0:: Hermitian{Float64, Matrix{Float64}}
192199 Q̂:: Hermitian{Float64, Matrix{Float64}}
193200 R̂:: Hermitian{Float64, Matrix{Float64}}
194- function KalmanFilter (model, i_ym, nint_ym, Asm, Csm, P̂0, Q̂, R̂)
201+ @doc raw """
202+ KalmanFilter(model, i_ym, nint_ym, P̂0 ,Q̂, R̂)
203+
204+ Construct the estimator from the augmented covariance matrices `P̂0`, `Q̂` and `R̂`.
205+
206+ This syntax allows nonzero off-diagonal elements in ``\m athbf{P̂}_{-1}(0)\m athbf{, Q̂, R̂}``.
207+ """
208+ function KalmanFilter (model, i_ym, nint_ym, P̂0, Q̂, R̂)
195209 nu, nx, ny = model. nu, model. nx, model. ny
196210 nym, nyu = length (i_ym), ny - length (i_ym)
211+ Asm, Csm, nint_ym = init_estimstoch (i_ym, nint_ym)
197212 nxs = size (Asm,1 )
198213 nx̂ = nx + nxs
199214 validate_kfcov (nym, nx̂, Q̂, R̂, P̂0)
@@ -260,17 +275,23 @@ function KalmanFilter(
260275 σP0_int:: Vector = fill (10 , max (sum (nint_ym), 0 )),
261276 σQ_int:: Vector = fill (0.1 , max (sum (nint_ym), 0 ))
262277)
263- if nint_ym == 0 # alias for no output integrator at all :
264- nint_ym = fill (0 , length (i_ym));
265- end
266- Asm, Csm = init_estimstoch (i_ym, nint_ym)
267278 # estimated covariances matrices (variance = σ²) :
268279 P̂0 = Diagonal {Float64} ([σP0 ; σP0_int ]. ^ 2 );
269280 Q̂ = Diagonal {Float64} ([σQ ; σQ_int ]. ^ 2 );
270281 R̂ = Diagonal {Float64} (σR.^ 2 );
271- return KalmanFilter (model, i_ym, nint_ym, Asm, Csm, P̂0, Q̂ , R̂)
282+ return KalmanFilter (model, i_ym, nint_ym, P̂0, Q̂ , R̂)
272283end
273284
285+ @doc raw """
286+ KalmanFilter(model, i_ym, nint_ym, P̂0, Q̂, R̂)
287+
288+ Construct the estimator from the augmented covariance matrices `P̂0`, `Q̂` and `R̂`.
289+
290+ This syntax allows nonzero off-diagonal elements in ``\m athbf{P̂}_{-1}(0), \m athbf{Q̂, R̂}``.
291+ """
292+ KalmanFilter (model:: LinModel , i_ym, nint_ym, P̂0 ,Q̂, R̂)
293+
294+
274295@doc raw """
275296 updatestate!(estim::KalmanFilter, u, ym, d=Float64[])
276297
@@ -341,10 +362,11 @@ struct UnscentedKalmanFilter{M<:SimModel} <: StateEstimator
341362 m̂:: Vector{Float64}
342363 Ŝ:: Diagonal{Float64, Vector{Float64}}
343364 function UnscentedKalmanFilter {M} (
344- model:: M , i_ym, nint_ym, Asm, Csm, P̂0, Q̂, R̂, α, β, κ
365+ model:: M , i_ym, nint_ym, P̂0, Q̂, R̂, α, β, κ
345366 ) where {M<: SimModel }
346367 nu, nx, ny = model. nu, model. nx, model. ny
347368 nym, nyu = length (i_ym), ny - length (i_ym)
369+ Asm, Csm, nint_ym = init_estimstoch (i_ym, nint_ym)
348370 nxs = size (Asm,1 )
349371 nx̂ = nx + nxs
350372 validate_kfcov (nym, nx̂, Q̂, R̂, P̂0)
@@ -424,17 +446,23 @@ function UnscentedKalmanFilter(
424446 β:: Real = 2 ,
425447 κ:: Real = 0
426448) where {M<: SimModel }
427- if nint_ym == 0 # alias for no output integrator at all :
428- nint_ym = fill (0 , length (i_ym));
429- end
430- Asm, Csm = init_estimstoch (i_ym, nint_ym)
431449 # estimated covariances matrices (variance = σ²) :
432450 P̂0 = Diagonal {Float64} ([σP0 ; σP0_int ]. ^ 2 );
433451 Q̂ = Diagonal {Float64} ([σQ ; σQ_int ]. ^ 2 );
434452 R̂ = Diagonal {Float64} (σR.^ 2 );
435- return UnscentedKalmanFilter {M} (model, i_ym, nint_ym, Asm, Csm, P̂0, Q̂ , R̂, α, β, κ)
453+ return UnscentedKalmanFilter {M} (model, i_ym, nint_ym, P̂0, Q̂ , R̂, α, β, κ)
436454end
437455
456+ @doc raw """
457+ UnscentedKalmanFilter(model, i_ym, nint_ym, P̂0, Q̂, R̂, α, β, κ)
458+
459+ Construct the estimator from the augmented covariance matrices `P̂0`, `Q̂` and `R̂`.
460+
461+ This syntax allows nonzero off-diagonal elements in ``\m athbf{P̂}_{-1}(0), \m athbf{Q̂, R̂}``.
462+ """
463+ UnscentedKalmanFilter {M} (model:: SimModel , i_ym, nint_ym, P̂0, Q̂, R̂, α, β, κ) where {M}
464+
465+
438466@doc raw """
439467 init_ukf(nx̂, α, β, κ)
440468
0 commit comments