@@ -13,15 +13,9 @@ struct SimResult{O<:Union{SimModel, StateEstimator, PredictiveController}}
13
13
end
14
14
15
15
@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>)
23
17
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.
25
19
26
20
See Arguments for the available options. The noises are provided as standard deviations σ
27
21
vectors. 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
30
24
them (see Examples below).
31
25
32
26
# 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)``.
45
39
46
40
# Examples
47
41
```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 );
49
43
50
- julia> res = sim!(plant, 5 , [0], [0], x0=[1]);
44
+ julia> res = sim!(plant, 15 , [0], [0], x0=[1]);
51
45
52
46
julia> using Plots; plot(res, plotu=false, plotd=false, plotx=true)
53
47
```
93
87
94
88
@doc raw """
95
89
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;
100
94
<keyword arguments>
101
95
)
102
96
@@ -105,15 +99,15 @@ Closed-loop simulation of `estim` estimator for `N` time steps, default to input
105
99
See Arguments for the available options.
106
100
107
101
# 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.
113
107
- `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).
117
111
118
112
# Examples
119
113
```julia-repl
@@ -140,26 +134,26 @@ end
140
134
@doc raw """
141
135
sim!(
142
136
mpc::PredictiveController,
143
- N::Int,
137
+ N::Int,
144
138
ry = mpc.estim.model.yop .+ 1,
145
139
d = mpc.estim.model.dop;
146
140
<keyword arguments>
147
141
)
148
142
149
143
Closed-loop simulation of `mpc` controller for `N` time steps, default to setpoint bumps.
150
144
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).
153
147
154
148
# Examples
155
149
```julia-repl
156
150
julia> model = LinModel([tf(3, [30, 1]); tf(2, [5, 1])], 4);
157
151
158
152
julia> mpc = setconstraint!(LinMPC(model, Mwt=[0, 1], Nwt=[0.01], Hp=30), ŷmin=[0, -Inf]);
159
153
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]);
161
155
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)
163
157
```
164
158
"""
165
159
function sim! (
0 commit comments