@@ -13,15 +13,9 @@ struct SimResult{O<:Union{SimModel, StateEstimator, PredictiveController}}
1313end
1414
1515@doc raw """
16- sim!(
17- plant::SimModel,
18- N::Int,
19- u::Vector{<:Real} = plant.uop .+ 1,
20- d::Vector{<:Real} = plant.dop;
21- <keyword arguments>
22- )
16+ sim!(plant::SimModel, N::Int, u=plant.uop.+1, d=plant.dop; <keyword arguments>)
2317
24- Open-loop simulation of `plant` model for `N` time steps, default to input bumps.
18+ Open-loop simulation of `plant` for `N` time steps, default to input bumps.
2519
2620See Arguments for the available options. The noises are provided as standard deviations σ
2721vectors. The simulated sensor and process noises of `plant` are specified by `y_noise` and
@@ -30,24 +24,24 @@ visualized by calling `plot` from [`Plots.jl`](https://github.com/JuliaPlots/Plo
3024them (see Examples below).
3125
3226# Arguments
33- - `plant::SimModel` : plant model to simulate
34- - `N::Int` : simulation length in time steps
35- - `u = estim.model.uop .+ 1` : manipulated input ``\m athbf{u}`` value
36- - `d = estim.model.dop` : plant measured disturbance ``\m athbf{d}`` value
37- - `u_step = zeros(plant.nu)` : step disturbance on manipulated input ``\m athbf{u}``
38- - `u_noise = zeros(plant.nu)` : additive gaussian noise on manipulated input ``\m athbf{u}``
39- - `y_step = zeros(plant.ny)` : step disturbance on plant outputs ``\m athbf{y}``
40- - `y_noise = zeros(plant.ny)` : additive gaussian noise on plant outputs ``\m athbf{y}``
41- - `d_step = zeros(plant.nd)` : step on measured disturbances ``\m athbf{d}``
42- - `d_noise = zeros(plant.nd)` : additive gaussian noise on measured dist. ``\m athbf{d}``
43- - `x_noise = zeros(plant.nx)` : additive gaussian noise on plant states ``\m athbf{x}``
44- - `x0 = zeros(plant.nx)` : plant initial state ``\m athbf{x}(0)``
27+ - `plant::SimModel` : plant model to simulate.
28+ - `N::Int` : simulation length in time steps.
29+ - `u = estim.model.uop .+ 1` : manipulated input ``\m athbf{u}`` value.
30+ - `d = estim.model.dop` : plant measured disturbance ``\m athbf{d}`` value.
31+ - `u_step = zeros(plant.nu)` : step load disturbance on plant inputs ``\m athbf{u}``.
32+ - `u_noise = zeros(plant.nu)` : additive gaussian noise on plant inputs ``\m athbf{u}``.
33+ - `y_step = zeros(plant.ny)` : step disturbance on plant outputs ``\m athbf{y}``.
34+ - `y_noise = zeros(plant.ny)` : additive gaussian noise on plant outputs ``\m athbf{y}``.
35+ - `d_step = zeros(plant.nd)` : step on measured disturbances ``\m athbf{d}``.
36+ - `d_noise = zeros(plant.nd)` : additive gaussian noise on measured dist. ``\m athbf{d}``.
37+ - `x_noise = zeros(plant.nx)` : additive gaussian noise on plant states ``\m athbf{x}``.
38+ - `x0 = zeros(plant.nx)` : plant initial state ``\m athbf{x}(0)``.
4539
4640# Examples
4741```julia-repl
48- julia> plant = NonLinModel((x,u,d)->0.1x+u+d, (x,_)->2x, 10, 1, 1, 1);
42+ julia> plant = NonLinModel((x,u,d)->0.1x+u+d, (x,_)->2x, 10, 1, 1, 1, 1 );
4943
50- julia> res = sim!(plant, 5 , [0], [0], x0=[1]);
44+ julia> res = sim!(plant, 15 , [0], [0], x0=[1]);
5145
5246julia> using Plots; plot(res, plotu=false, plotd=false, plotx=true)
5347```
9387
9488@doc raw """
9589 sim!(
96- estim::StateEstimator,
97- N::Int,
98- u = estim.model.uop .+ 1,
99- d = estim.model.dop;
90+ estim::StateEstimator,
91+ N::Int,
92+ u = estim.model.uop .+ 1,
93+ d = estim.model.dop;
10094 <keyword arguments>
10195 )
10296
@@ -105,15 +99,15 @@ Closed-loop simulation of `estim` estimator for `N` time steps, default to input
10599See Arguments for the available options.
106100
107101# Arguments
108- - `estim::StateEstimator` : state estimator to simulate
109- - `N::Int` : simulation length in time steps
110- - `u = estim.model.uop .+ 1` : manipulated input ``\m athbf{u}`` value
111- - `d = estim.model.dop` : plant measured disturbance ``\m athbf{d}`` value
112- - `plant::SimModel = estim.model` : simulated plant model
102+ - `estim::StateEstimator` : state estimator to simulate.
103+ - `N::Int` : simulation length in time steps.
104+ - `u = estim.model.uop .+ 1` : manipulated input ``\m athbf{u}`` value.
105+ - `d = estim.model.dop` : plant measured disturbance ``\m athbf{d}`` value.
106+ - `plant::SimModel = estim.model` : simulated plant model.
113107- `x̂0 = nothing` : `mpc.estim` state estimator initial state ``\m athbf{x̂}(0)``, if `nothing`
114- then ``\m athbf{x̂}`` is initialized with [`initstate!`](@ref)
115- - `lastu = plant.uop` : last plant input ``\m athbf{u}`` for ``\m athbf{x̂}`` initialization
116- - `<keyword arguments>` of [`sim!(::SimModel)`](@ref)
108+ then ``\m athbf{x̂}`` is initialized with [`initstate!`](@ref).
109+ - `lastu = plant.uop` : last plant input ``\m athbf{u}`` for ``\m athbf{x̂}`` initialization.
110+ - `<keyword arguments>` of [`sim!(::SimModel, ::Int )`](@ref).
117111
118112# Examples
119113```julia-repl
@@ -140,26 +134,26 @@ end
140134@doc raw """
141135 sim!(
142136 mpc::PredictiveController,
143- N::Int,
137+ N::Int,
144138 ry = mpc.estim.model.yop .+ 1,
145139 d = mpc.estim.model.dop;
146140 <keyword arguments>
147141 )
148142
149143Closed-loop simulation of `mpc` controller for `N` time steps, default to setpoint bumps.
150144
151- `ry` is the output setpoint value applied at ``t = 0`` second . The keyword arguments are
152- identical to [`sim!(::StateEstimator)`](@ref).
145+ The argument `ry` is output setpoint `` \m athbf{r_y}`` value applied at ``t = 0``. The
146+ keyword arguments are identical to [`sim!(::StateEstimator, ::Int )`](@ref).
153147
154148# Examples
155149```julia-repl
156150julia> model = LinModel([tf(3, [30, 1]); tf(2, [5, 1])], 4);
157151
158152julia> mpc = setconstraint!(LinMPC(model, Mwt=[0, 1], Nwt=[0.01], Hp=30), ŷmin=[0, -Inf]);
159153
160- julia> res = sim!(mpc, 25, [0; 0], y_noise=[0.1], y_step=[-10,0]);
154+ julia> res = sim!(mpc, 25, [0, 0], y_noise=[0.1], y_step=[-10, 0]);
161155
162- julia> using Plots; plot(res, plotRy =true, plotŷ=true, plotŷmin=true, plotu=true)
156+ julia> using Plots; plot(res, plotry =true, plotŷ=true, plotŷmin=true, plotu=true)
163157```
164158"""
165159function sim! (
0 commit comments