Skip to content

Commit e3c723a

Browse files
committed
added: last manipulated input lastu in getinfo for MPC
1 parent 5339554 commit e3c723a

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

src/controller/execute.jl

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,11 @@ The function should be called after calling [`moveinput!`](@ref). It returns the
100100
- `:R̂y` or *`:Rhaty`* : predicted output setpoint over ``H_p``, ``\mathbf{R̂_y}``
101101
- `:R̂u` or *`:Rhatu`* : predicted manipulated input setpoint over ``H_p``, ``\mathbf{R̂_u}``
102102
- `:x̂end` or *`:xhatend`* : optimal terminal states, ``\mathbf{x̂}_i(k+H_p)``
103-
- `:J` : objective value optimum, ``J``
104-
- `:U` : optimal manipulated inputs over ``H_p``, ``\mathbf{U}``
105-
- `:u` : current optimal manipulated input, ``\mathbf{u}(k)``
106-
- `:d` : current measured disturbance, ``\mathbf{d}(k)``
103+
- `:J` : objective value optimum, ``J``
104+
- `:U` : optimal manipulated inputs over ``H_p``, ``\mathbf{U}``
105+
- `:u` : current optimal manipulated input, ``\mathbf{u}(k)``
106+
- `:d` : current measured disturbance, ``\mathbf{d}(k)``
107+
- `:lastu` : last manipulated input, ``\mathbf{u}(k-1)``
107108
108109
For [`LinMPC`](@ref) and [`NonLinMPC`](@ref), the following fields are also available:
109110
@@ -161,20 +162,21 @@ function getinfo(mpc::PredictiveController{NT}) where NT<:Real
161162
J = obj_nonlinprog!(Ŷ0, U0, mpc, Ue, Ŷe, ΔŨ)
162163
Ŷs = similar(mpc.Yop)
163164
predictstoch!(Ŷs, mpc, mpc.estim)
164-
info[:ΔU] = Z̃[1:mpc.Hc*model.nu]
165-
info[] = getϵ(mpc, Z̃)
166-
info[:J] = J
167-
info[:U] = U
168-
info[:u] = info[:U][1:model.nu]
169-
info[:d] = mpc.d0 + model.dop
170-
info[:D̂] =
171-
info[:x̂] = mpc.estim.x̂0 .+ mpc.estim.x̂op
172-
info[:ŷ] = mpc.
173-
info[:Ŷ] =
174-
info[:x̂end] = x̂0end + mpc.estim.x̂op
175-
info[:Ŷs] = Ŷs
176-
info[:R̂y] = mpc.R̂y
177-
info[:R̂u] = mpc.R̂u
165+
info[:ΔU] = Z̃[1:mpc.Hc*model.nu]
166+
info[] = getϵ(mpc, Z̃)
167+
info[:J] = J
168+
info[:U] = U
169+
info[:u] = info[:U][1:model.nu]
170+
info[:lastu] = mpc.lastu0 .+ model.uop
171+
info[:d] = mpc.d0 + model.dop
172+
info[:D̂] =
173+
info[:x̂] = mpc.estim.x̂0 .+ mpc.estim.x̂op
174+
info[:ŷ] = mpc.
175+
info[:Ŷ] =
176+
info[:x̂end] = x̂0end + mpc.estim.x̂op
177+
info[:Ŷs] = Ŷs
178+
info[:R̂y] = mpc.R̂y
179+
info[:R̂u] = mpc.R̂u
178180
# --- non-Unicode fields ---
179181
info[:DeltaU] = info[:ΔU]
180182
info[:epsilon] = info[]

0 commit comments

Comments
 (0)