Skip to content

Commit 3c1f59f

Browse files
committed
doc: some details on Kalman filter tuning in SteadyKalmanFilter docstring
1 parent 16a4217 commit 3c1f59f

File tree

3 files changed

+30
-21
lines changed

3 files changed

+30
-21
lines changed

src/estimator/execute.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ Prepare `estim.x̂0` estimate with meas. outputs `ym` and dist. `d` for the curr
203203
204204
This function should be called at the beginning of each discrete time step. Its behavior
205205
depends if `estim` is a [`StateEstimator`](@ref) in the current/filter (1.) or
206-
delayed/predictor (2.) form:
206+
delayed/predictor (2.) formulation:
207207
208208
1. If `estim.direct` is `true`, it removes the operating points with [`remove_op!`](@ref),
209209
calls [`correct_estimate!`](@ref), and returns the corrected state estimate

src/estimator/kalman.jl

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,12 @@ The arguments are in standard deviations σ, i.e. same units than outputs and st
9292
matrices ``\mathbf{Â, B̂_u, B̂_d, Ĉ, D̂_d}`` are `model` matrices augmented with the stochastic
9393
model, which is specified by the numbers of integrator `nint_u` and `nint_ym` (see Extended
9494
Help). Likewise, the covariance matrices are augmented with ``\mathbf{Q̂ = \text{diag}(Q,
95-
Q_{int_u}, Q_{int_{ym}})}`` and ``\mathbf{R̂ = R}``. The matrices ``\mathbf{Ĉ^m, D̂_d^m}`` are
96-
the rows of ``\mathbf{Ĉ, D̂_d}`` that correspond to measured outputs ``\mathbf{y^m}`` (and
97-
unmeasured ones, for ``\mathbf{Ĉ^u, D̂_d^u}``). The Kalman filter will estimate the current
98-
state with the newest measurements ``\mathbf{x̂}_k(k)`` if `direct == true`, else it will
99-
predict the state of the next time step ``\mathbf{x̂}_k(k+1)``.
95+
Q_{int_u}, Q_{int_{ym}})}`` and ``\mathbf{R̂ = R}``. The Extended Help provide some guidelines
96+
on the covariance tuning. The matrices ``\mathbf{Ĉ^m, D̂_d^m}`` are the rows of
97+
``\mathbf{Ĉ, D̂_d}`` that correspond to measured outputs ``\mathbf{y^m}`` (and unmeasured
98+
ones, for ``\mathbf{Ĉ^u, D̂_d^u}``). The Kalman filter will estimate the current state with
99+
the newest measurements ``\mathbf{x̂}_k(k)`` if `direct` is `true`, else it will predict the
100+
state of the next time step ``\mathbf{x̂}_k(k+1)``.
100101
101102
# Arguments
102103
!!! info
@@ -135,6 +136,11 @@ SteadyKalmanFilter estimator with a sample time Ts = 0.5 s, LinModel and:
135136
136137
# Extended Help
137138
!!! details "Extended Help"
139+
The `σR` argument is generally fixed at the estimated standard deviations of the sensor
140+
noises. The `σQ`, `σQint_u` and `σQint_ym` arguments can be used to tune the filter
141+
response. Increasing them make the filter more responsive to disturbances but more
142+
sensitive to measurement noise.
143+
138144
The model augmentation with `nint_u` vector adds integrators at model manipulated inputs,
139145
and `nint_ym`, at measured outputs. They create the integral action when the estimator
140146
is used in a controller as state feedback. By default, the method [`default_nint`](@ref)
@@ -628,11 +634,12 @@ UnscentedKalmanFilter estimator with a sample time Ts = 10.0 s, NonLinModel and:
628634
629635
# Extended Help
630636
!!! details "Extended Help"
631-
The Extended Help of [`SteadyKalmanFilter`](@ref) details the augmentation with `nint_ym`
632-
and `nint_u` arguments. The default augmentation scheme is identical, that is `nint_u=0`
633-
and `nint_ym` computed by [`default_nint`](@ref). Note that the constructor does not
634-
validate the observability of the resulting augmented [`NonLinModel`](@ref). In such
635-
cases, it is the user's responsibility to ensure that it is still observable.
637+
The Extended Help of [`SteadyKalmanFilter`](@ref) details the tuning of the covariances
638+
and the augmentation with `nint_ym` and `nint_u` arguments. The default augmentation
639+
scheme is identical, that is `nint_u=0` and `nint_ym` computed by [`default_nint`](@ref).
640+
Note that the constructor does not validate the observability of the resulting augmented
641+
[`NonLinModel`](@ref). In such cases, it is the user's responsibility to ensure that it
642+
is still observable.
636643
"""
637644
function UnscentedKalmanFilter(
638645
model::SM;

src/estimator/mhe/construct.jl

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -302,11 +302,12 @@ MovingHorizonEstimator estimator with a sample time Ts = 10.0 s, Ipopt optimizer
302302
optimization by default, but it can be postponed to [`updatestate!`](@ref) with
303303
`direct=false`.
304304
305-
The Extended Help of [`SteadyKalmanFilter`](@ref) details the augmentation with `nint_ym`
306-
and `nint_u` arguments. The default augmentation scheme is identical, that is `nint_u=0`
307-
and `nint_ym` computed by [`default_nint`](@ref). Note that the constructor does not
308-
validate the observability of the resulting augmented [`NonLinModel`](@ref). In such
309-
cases, it is the user's responsibility to ensure that it is still observable.
305+
The Extended Help of [`SteadyKalmanFilter`](@ref) details the tuning of the covariances
306+
and the augmentation with `nint_ym` and `nint_u` arguments. The default augmentation
307+
scheme is identical, that is `nint_u=0` and `nint_ym` computed by [`default_nint`](@ref).
308+
Note that the constructor does not validate the observability of the resulting augmented
309+
[`NonLinModel`](@ref). In such cases, it is the user's responsibility to ensure that it
310+
is still observable.
310311
311312
The estimation covariance at arrival ``\mathbf{P̂}_{k-N_k}(k-N_k+p)`` gives an uncertainty
312313
on the state estimate at the beginning of the window ``k-N_k+p``, that is, in the past.
@@ -341,8 +342,8 @@ MovingHorizonEstimator estimator with a sample time Ts = 10.0 s, Ipopt optimizer
341342
problems with two or more types of bounds, to ensure feasibility (e.g. on the estimated
342343
state ``\mathbf{x̂}`` and sensor noise ``\mathbf{v̂}``). Note that if `Cwt≠Inf`, the
343344
attribute `nlp_scaling_max_gradient` of `Ipopt` is set to `10/Cwt` (if not already set),
344-
to scale the small values of ``ϵ``. Use the second constructor to specify the covariance
345-
estimation method.
345+
to scale the small values of ``ϵ``. Use the second constructor to specify the arrival
346+
covariance estimation method.
346347
"""
347348
function MovingHorizonEstimator(
348349
model::SM;
@@ -391,9 +392,10 @@ default_optim_mhe(::SimModel) = JuMP.Model(DEFAULT_NONLINMHE_OPTIMIZER, add_brid
391392
392393
Construct the estimator from the augmented covariance matrices `P̂_0`, `Q̂` and `R̂`.
393394
394-
This syntax allows nonzero off-diagonal elements in ``\mathbf{P̂}_{-1}(0), \mathbf{Q̂, R̂}``.
395-
The keyword argument `covestim` also allows specifying a custom [`StateEstimator`](@ref)
396-
object for the estimation of covariance at the arrival ``\mathbf{P̂}_{k-N_k}(k-N_k+1)``. The
395+
This syntax allows nonzero off-diagonal elements in ``\mathbf{P̂_i}, \mathbf{Q̂, R̂}``,
396+
where ``\mathbf{P̂_i}`` is the initial estimation covariance, provided by `P̂_0` argument. The
397+
keyword argument `covestim` also allows specifying a custom [`StateEstimator`](@ref) object
398+
for the estimation of covariance at the arrival ``\mathbf{P̂}_{k-N_k}(k-N_k+1)``. The
397399
supported types are [`KalmanFilter`](@ref), [`UnscentedKalmanFilter`](@ref) and
398400
[`ExtendedKalmanFilter`](@ref).
399401
"""

0 commit comments

Comments
 (0)