Skip to content

Commit 0ba786e

Browse files
committed
modify Compat for ControlSystemsBase
1 parent 7db4fdd commit 0ba786e

File tree

8 files changed

+35
-14
lines changed

8 files changed

+35
-14
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ModelPredictiveControl"
22
uuid = "61f9bdb8-6ae4-484a-811f-bbf86720c31c"
33
authors = ["Francis Gagnon"]
4-
version = "0.7.0"
4+
version = "0.7.1"
55

66
[deps]
77
ControlSystemsBase = "aaaaaaaa-a6ca-5380-bf3e-84a91bcd477e"
@@ -16,7 +16,7 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
1616
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
1717

1818
[compat]
19-
ControlSystemsBase = "1"
19+
ControlSystemsBase = "1.9"
2020
ForwardDiff = "0.10"
2121
Ipopt = "1"
2222
JuMP = "1"

docs/src/internals/state_estim.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
```@docs
66
ModelPredictiveControl.init_estimstoch
77
ModelPredictiveControl.augment_model
8-
ModelPredictiveControl.default_nint
98
ModelPredictiveControl.init_ukf
109
ModelPredictiveControl.init_internalmodel
1110
```

docs/src/public/state_estim.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,9 @@ ExtendedKalmanFilter
7575
```@docs
7676
InternalModel
7777
```
78+
79+
## Default output integrator quantity
80+
81+
```@docs
82+
default_nint
83+
```

src/ModelPredictiveControl.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import OSQP, Ipopt
1414
export SimModel, LinModel, NonLinModel, setop!, setstate!, updatestate!, evaloutput
1515
export StateEstimator, InternalModel, Luenberger
1616
export SteadyKalmanFilter, KalmanFilter, UnscentedKalmanFilter, ExtendedKalmanFilter
17-
export initstate!
17+
export default_nint, initstate!
1818
export PredictiveController, ExplicitMPC, LinMPC, NonLinMPC, setconstraint!, moveinput!
1919
export getinfo, sim!
2020

src/controller/nonlinmpc.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ end
386386
"""
387387
con_nonlinprog(mpc::NonLinMPC, model::NonLinModel, ΔŨ::Vector{Real})
388388
389-
Nonlinear constrains for [`NonLinMPC`](@ref) when `model` is not a [`LinModel`](ref).
389+
Nonlinear constrains for [`NonLinMPC`](@ref) when `model` is not a [`LinModel`](@ref).
390390
"""
391391
function con_nonlinprog(mpc::NonLinMPC, ::SimModel, Ŷ, ΔŨ::Vector{T}) where {T<:Real}
392392
if !isinf(mpc.C) # constraint softening activated :

src/estimator/kalman.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ The model augmentation with `nint_ym` vector adds integrators at model measured
119119
as state feedback. The method [`default_nint`](@ref) computes the default value of
120120
`nint_ym`. It can also be tweaked by following these rules on each measured output:
121121
122-
- Use 0 integrator if the model output is integrating (else it will be unobservable)
122+
- Use 0 integrator if the model output is already integrating (else it will be unobservable)
123123
- Use 1 integrator if the disturbances on the output are typically "step-like"
124124
- Use 2 integrators if the disturbances on the output are typically "ramp-like"
125125

src/predictive_control.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ setstate!(mpc::PredictiveController, x̂) = (setstate!(mpc.estim, x̂); return m
341341
Init `mpc.ΔŨ` for warm-starting and the states of `mpc.estim` [`StateEstimator`](@ref).
342342
343343
Before calling [`initstate!(::StateEstimator,_,_)`](@ref), it warm-starts ``\mathbf{ΔŨ}``:
344-
- If `model` is a [`LinModel`](ref), the vector is filled with the analytical minimum ``J``
344+
- If `model` is a [`LinModel`](@ref), the vector is filled with the analytical minimum ``J``
345345
of the unconstrained problem.
346346
- Else, the vector is filled with zeros.
347347
"""

src/state_estim.jl

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -197,15 +197,27 @@ end
197197
augment_model(::SimModel, _ , _ ) = nothing
198198

199199
@doc raw"""
200-
default_nint(model::LinModel, i_ym)
200+
default_nint(model::LinModel, i_ym=1:model.ny)
201201
202202
Get default integrator quantity per measured outputs `nint_ym` for [`LinModel`](@ref).
203203
204-
By default, one integrator is added on each measured outputs. If ``\mathbf{Â, Ĉ}``
205-
matrices of the augmented model becomes unobservable, the integrator is removed. This
206-
approach works well for stable, integrating and unstable `model`.
204+
The measured output ``\mathbf{y^m}`` indices are specified by `i_ym` argument. By default,
205+
one integrator is added on each measured outputs. If ``\mathbf{Â, Ĉ}`` matrices of the
206+
augmented model becomes unobservable, the integrator is removed. This approach works well
207+
for stable, integrating and unstable `model` (see Examples).
208+
209+
# Examples
210+
```jldoctest
211+
julia> model = LinModel(append(tf(3, [10, 1]), tf(2, [1, 0]), tf(4,[-5, 1])), 1.0);
212+
213+
julia> nint_ym = default_nint(model)
214+
3-element Vector{Int64}:
215+
1
216+
0
217+
1
218+
```
207219
"""
208-
function default_nint(model::LinModel, i_ym)
220+
function default_nint(model::LinModel, i_ym::IntRangeOrVector = 1:model.ny)
209221
nint_ym = fill(0, length(i_ym))
210222
for i in eachindex(i_ym)
211223
nint_ym[i] = 1
@@ -218,8 +230,12 @@ function default_nint(model::LinModel, i_ym)
218230
end
219231
return nint_ym
220232
end
221-
"One integrator per measured outputs by default if `model` is not a [`LinModel`](@ref)."
222-
default_nint(::SimModel, i_ym) = fill(1, length(i_ym))
233+
"""
234+
default_nint(model::SimModel, i_ym=1:model.ny)
235+
236+
One integrator on each measured output by default if `model` is not a [`LinModel`](@ref).
237+
"""
238+
default_nint(::SimModel, i_ym::IntRangeOrVector = 1:model.ny) = fill(1, length(i_ym))
223239

224240
@doc raw"""
225241
f̂(estim::StateEstimator, x̂, u, d)

0 commit comments

Comments
 (0)