Skip to content

Commit c843b02

Browse files
committed
debug: correct signature
1 parent c5eff2a commit c843b02

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

src/controller/execute.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ It also stores `u - mpc.estim.model.uop` at `mpc.lastu0` for converting the inpu
1010
function initstate!(mpc::PredictiveController, u, ym, d=mpc.estim.buffer.empty)
1111
= initstate!(mpc.estim, u, ym, d)
1212
mpc.lastu0 .= u .- mpc.estim.model.uop
13-
init_decision!(mpc, mpc.transcription, x̂)
13+
init_decision!(mpc, mpc.transcription)
1414
return
1515
end
1616

src/controller/transcription.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -771,9 +771,9 @@ end
771771
772772
Init the decision vector ``\mathbf{Z̃ = ΔŨ}`` with zeros for [`SingleShooting`](@ref).
773773
"""
774-
init_decision!(mpc::PredictiveController, ::SingleShooting, _) = (mpc.Z̃ .= 0; nothing)
774+
init_decision!(mpc::PredictiveController, ::SingleShooting) = (mpc.Z̃ .= 0; nothing)
775775

776-
@dow raw"""
776+
@doc raw"""
777777
init_decision!(mpc::PredictiveController, ::TranscriptionMethod)
778778
779779
Also init the state part of the decision vector for other [`TranscriptionMethod`](@ref)s.
@@ -782,7 +782,7 @@ The ``\mathbf{X̂_0}`` component is assumed constant over ``H_p`` at the current
782782
in `mpc.estim.x̂0`.
783783
"""
784784
function init_decision!(mpc::PredictiveController, ::TranscriptionMethod)
785-
nΔU, nx̂ = mpc.Hc*mpc.model.nu, mpc.estim.nx̂
785+
nΔU, nx̂ = mpc.Hc*mpc.estim.model.nu, mpc.estim.nx̂
786786
mpc.Z̃ .= 0
787787
for j=1:mpc.Hp
788788
iRow = nΔU .+ (1:nx̂) .+ nx̂*(j-1)

src/plot_sim.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,11 @@ function sim_closedloop!(
286286
X̂_data = Matrix{NT}(undef, estim.nx̂, N)
287287
setstate!(plant, x_0)
288288
lastd, lasty = d, evaloutput(plant, d)
289+
# 1st `setstate!`, for correct `mpc.Z̃` initialization in `initstate!`:
290+
isnothing(x̂_0) || setstate!(est_mpc, x̂_0)
291+
# calling `initstate!` no matter what, to initialize `mpc.Z̃` and covariance matrices:
289292
initstate!(est_mpc, lastu, lasty[estim.i_ym], lastd)
293+
# 2nd `setstate!`, since `initstate!` overwrite the state for `LinModel`:
290294
isnothing(x̂_0) || setstate!(est_mpc, x̂_0)
291295
@progressif progress name="$(nameof(typeof(est_mpc))) simulation" for i=1:N
292296
d = lastd + d_step + d_noise.*randn(plant.nd)

0 commit comments

Comments
 (0)