From 30cd3970c3fcbcc1aec14c47507fd4534a0164e2 Mon Sep 17 00:00:00 2001 From: franckgaga Date: Wed, 3 Jun 2026 15:18:44 -0400 Subject: [PATCH 1/3] added: pretty-print `estim.direct` for all `StateEstimator`s --- src/estimator/mhe.jl | 2 +- src/state_estim.jl | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/estimator/mhe.jl b/src/estimator/mhe.jl index 5066f48d5..f4f88e02d 100644 --- a/src/estimator/mhe.jl +++ b/src/estimator/mhe.jl @@ -11,7 +11,7 @@ function print_details(io::IO, estim::MovingHorizonEstimator) println(io, "├ arrival covariance: $(nameof(typeof(estim.covestim))) ") end -"Print the differentiation backends for `SimModel`." +"Print the differentiation backends of `MovingHorizonEstimator` for `SimModel`." function print_backends(io::IO, estim::MovingHorizonEstimator, ::SimModel) println(io, "├ gradient: $(backend_str(estim.gradient))") println(io, "├ jacobian: $(backend_str(estim.jacobian))") diff --git a/src/state_estim.jl b/src/state_estim.jl index 7c8644fd1..8806f82c4 100644 --- a/src/state_estim.jl +++ b/src/state_estim.jl @@ -37,6 +37,7 @@ function Base.show(io::IO, estim::StateEstimator) println(io, "$(nameof(typeof(estim))) estimator with a sample time Ts = $(model.Ts) s:") println(io, "├ model: $(nameof(typeof(estim.model)))") print_details(io, estim) + println(io, "├ direct: $(estim.direct) ") println(io, "└ dimensions:") print_estim_dim(io, estim, n) end From ce74a341ef281c95d7bf6f88add65e6414101c54 Mon Sep 17 00:00:00 2001 From: franckgaga Date: Wed, 3 Jun 2026 15:20:58 -0400 Subject: [PATCH 2/3] removed: useless space --- src/state_estim.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/state_estim.jl b/src/state_estim.jl index 8806f82c4..563899b4f 100644 --- a/src/state_estim.jl +++ b/src/state_estim.jl @@ -37,7 +37,7 @@ function Base.show(io::IO, estim::StateEstimator) println(io, "$(nameof(typeof(estim))) estimator with a sample time Ts = $(model.Ts) s:") println(io, "├ model: $(nameof(typeof(estim.model)))") print_details(io, estim) - println(io, "├ direct: $(estim.direct) ") + println(io, "├ direct: $(estim.direct)") println(io, "└ dimensions:") print_estim_dim(io, estim, n) end From 030fa21c48a4a123cecb820e9ddef314546dfdba Mon Sep 17 00:00:00 2001 From: franckgaga Date: Wed, 3 Jun 2026 16:20:13 -0400 Subject: [PATCH 3/3] doc: update `jldocstring`s --- src/estimator/internal_model.jl | 1 + src/estimator/kalman.jl | 6 ++++++ src/estimator/luenberger.jl | 1 + src/estimator/manual.jl | 5 ++++- src/estimator/mhe.jl | 1 + src/estimator/mhe/construct.jl | 2 ++ src/state_estim.jl | 7 ++++--- 7 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/estimator/internal_model.jl b/src/estimator/internal_model.jl index 7233a59d0..aa41957a4 100644 --- a/src/estimator/internal_model.jl +++ b/src/estimator/internal_model.jl @@ -82,6 +82,7 @@ estimator is allocation-free if `model` simulations do not allocate. julia> estim = InternalModel(LinModel([tf(3, [30, 1]); tf(-2, [5, 1])], 0.5), i_ym=[2]) InternalModel estimator with a sample time Ts = 0.5 s: ├ model: LinModel +├ direct: true └ dimensions: ├ 1 manipulated inputs u ├ 2 estimated states x̂ diff --git a/src/estimator/kalman.jl b/src/estimator/kalman.jl index d08e11b4c..3a7c1ec20 100644 --- a/src/estimator/kalman.jl +++ b/src/estimator/kalman.jl @@ -119,6 +119,7 @@ julia> model = LinModel([tf(3, [30, 1]); tf(-2, [5, 1])], 0.5); julia> estim = SteadyKalmanFilter(model, i_ym=[2], σR=[1], σQint_ym=[0.01]) SteadyKalmanFilter estimator with a sample time Ts = 0.5 s: ├ model: LinModel +├ direct: true └ dimensions: ├ 1 manipulated inputs u (0 integrating states) ├ 3 estimated states x̂ @@ -410,6 +411,7 @@ julia> model = LinModel([tf(3, [30, 1]); tf(-2, [5, 1])], 0.5); julia> estim = KalmanFilter(model, i_ym=[2], σR=[1], σP_0=[100, 100], σQint_ym=[0.01]) KalmanFilter estimator with a sample time Ts = 0.5 s: ├ model: LinModel +├ direct: true └ dimensions: ├ 1 manipulated inputs u (0 integrating states) ├ 3 estimated states x̂ @@ -656,6 +658,7 @@ julia> model = NonLinModel((x,u,_,_)->0.1x+u, (x,_,_)->2x, 10.0, 1, 1, 1, solver julia> estim = UnscentedKalmanFilter(model, σR=[1], nint_ym=[2], σPint_ym_0=[1, 1]) UnscentedKalmanFilter estimator with a sample time Ts = 10.0 s: ├ model: NonLinModel +├ direct: true └ dimensions: ├ 1 manipulated inputs u (0 integrating states) ├ 3 estimated states x̂ @@ -1023,6 +1026,7 @@ julia> estim = ExtendedKalmanFilter(model, σQ=[2], σQint_ym=[2], σP_0=[0.1], ExtendedKalmanFilter estimator with a sample time Ts = 5.0 s: ├ model: NonLinModel ├ jacobian: AutoForwardDiff +├ direct: true └ dimensions: ├ 1 manipulated inputs u (0 integrating states) ├ 2 estimated states x̂ @@ -1190,8 +1194,10 @@ function update_estimate!(estim::ExtendedKalmanFilter{NT}, y0m, d0, u0) where NT return predict_estimate_kf!(estim, u0, d0, F̂) end +"Print the `jacobian` backend and `direct` flag for [`ExtendedKalmanFilter`](@ref)." function print_details(io::IO, estim::ExtendedKalmanFilter) println(io, "├ jacobian: $(backend_str(estim.jacobian))") + println(io, "├ direct: $(estim.direct)") end "Set `estim.cov.P̂` to `estim.cov.P̂_0` for the time-varying Kalman Filters." diff --git a/src/estimator/luenberger.jl b/src/estimator/luenberger.jl index d07038f78..5e660de8a 100644 --- a/src/estimator/luenberger.jl +++ b/src/estimator/luenberger.jl @@ -85,6 +85,7 @@ julia> model = LinModel([tf(3, [30, 1]); tf(-2, [5, 1])], 0.5); julia> estim = Luenberger(model, nint_ym=[1, 1], poles=[0.61, 0.62, 0.63, 0.64]) Luenberger estimator with a sample time Ts = 0.5 s: ├ model: LinModel +├ direct: true └ dimensions: ├ 1 manipulated inputs u (0 integrating states) ├ 4 estimated states x̂ diff --git a/src/estimator/manual.jl b/src/estimator/manual.jl index 7b13288bb..55ff87254 100644 --- a/src/estimator/manual.jl +++ b/src/estimator/manual.jl @@ -155,4 +155,7 @@ update_estimate!(::ManualEstimator, y0m, d0, u0) = nothing function setstate_cov!(::ManualEstimator, P̂) isnothing(P̂) || error("ManualEstimator does not compute an estimation covariance matrix P̂.") return nothing -end \ No newline at end of file +end + +"No details for `ManualEstimator`." +print_details(::IO, ::ManualEstimator) = nothing diff --git a/src/estimator/mhe.jl b/src/estimator/mhe.jl index f4f88e02d..c5ecac97d 100644 --- a/src/estimator/mhe.jl +++ b/src/estimator/mhe.jl @@ -9,6 +9,7 @@ function print_details(io::IO, estim::MovingHorizonEstimator) println(io, "├ optimizer: $(JuMP.solver_name(estim.optim)) ") print_backends(io, estim, estim.model) println(io, "├ arrival covariance: $(nameof(typeof(estim.covestim))) ") + println(io, "├ direct: $(estim.direct)") end "Print the differentiation backends of `MovingHorizonEstimator` for `SimModel`." diff --git a/src/estimator/mhe/construct.jl b/src/estimator/mhe/construct.jl index 2e1982ca1..aafa3dd78 100644 --- a/src/estimator/mhe/construct.jl +++ b/src/estimator/mhe/construct.jl @@ -328,6 +328,7 @@ MovingHorizonEstimator estimator with a sample time Ts = 10.0 s: ├ jacobian: AutoForwardDiff ├ hessian: nothing ├ arrival covariance: UnscentedKalmanFilter +├ direct: true └ dimensions: ├ 5 estimation steps He ├ 0 slack variable ε (estimation constraints) @@ -752,6 +753,7 @@ MovingHorizonEstimator estimator with a sample time Ts = 1.0 s: ├ model: LinModel ├ optimizer: OSQP ├ arrival covariance: KalmanFilter +├ direct: true └ dimensions: ├ 3 estimation steps He ├ 0 slack variable ε (estimation constraints) diff --git a/src/state_estim.jl b/src/state_estim.jl index 563899b4f..ce7ee5bcf 100644 --- a/src/state_estim.jl +++ b/src/state_estim.jl @@ -37,7 +37,6 @@ function Base.show(io::IO, estim::StateEstimator) println(io, "$(nameof(typeof(estim))) estimator with a sample time Ts = $(model.Ts) s:") println(io, "├ model: $(nameof(typeof(estim.model)))") print_details(io, estim) - println(io, "├ direct: $(estim.direct)") println(io, "└ dimensions:") print_estim_dim(io, estim, n) end @@ -45,8 +44,10 @@ end "Return additional dimensions on `estim` if any, for adequate padding with spaces." get_other_dims(::StateEstimator) = tuple() -"Print additional details of `estim` if any (no details by default)." -print_details(::IO, ::StateEstimator) = nothing +"Print only the `estim.direct` field by default." +function print_details(io::IO, estim::StateEstimator) + println(io, "├ direct: $(estim.direct)") +end "Print the overall dimensions of the state estimator `estim` with left padding `n`." function print_estim_dim(io::IO, estim::StateEstimator, n)