Skip to content

Commit e26ddad

Browse files
committed
debug : input setpoints ru now works
added : unit test for input setpoint weight Lwt
1 parent 401b0b6 commit e26ddad

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

docs/make.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ makedocs(
2222
pages = [
2323
"Home" => "index.md",
2424
"Manual" => [
25+
"Installation" => "manual/installation.md",
2526
"Examples" => [
26-
"Installation" => "manual/installation.md",
2727
"Linear Design" => "manual/linmpc.md",
2828
"Nonlinear Design" => "manual/nonlinmpc.md",
2929
],

src/plot_sim.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ sim_getu!(::StateEstimator, u, _ , _ ) = u
221221
sim_getu!(mpc::PredictiveController, ry, d, ym) = moveinput!(mpc, ry, d; ym)
222222

223223
"Plots.jl recipe for `SimResult` objects constructed with `SimModel` objects."
224-
@recipe function simresultplot(
224+
@recipe function plot(
225225
res::SimResult{<:SimModel};
226226
plotu = true,
227227
plotd = true,
@@ -297,7 +297,7 @@ sim_getu!(mpc::PredictiveController, ry, d, ym) = moveinput!(mpc, ry, d; ym)
297297
end
298298

299299
"Plots.jl recipe for `SimResult` objects constructed with `StateEstimator` objects."
300-
@recipe function simresultplot(
300+
@recipe function plot(
301301
res::SimResult{<:StateEstimator};
302302
plotŷ = true,
303303
plotu = true,
@@ -407,7 +407,7 @@ end
407407
end
408408

409409
"Plots.jl recipe for `SimResult` objects constructed with `PredictiveController` objects."
410-
@recipe function simresultplot(
410+
@recipe function plot(
411411
res::SimResult{<:PredictiveController};
412412
plotry = true,
413413
plotŷmin = true,

src/predictive_control.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ function initpred!(mpc::PredictiveController, model::LinModel, d, D̂, R̂y)
422422
if ~isempty(mpc.R̂u)
423423
lastu = mpc.estim.lastu0 + model.uop
424424
= mpc.T_Hp*lastu - mpc.R̂u
425-
mpc.q̃[:] += 2(mpc.L_Hp*mpc.T_Hp)'*
425+
mpc.q̃[:] += 2(mpc.L_Hp*mpc.S̃_Hp)'*
426426
mpc.p[:] += [V̂'*mpc.L_Hp*V̂]
427427
end
428428
return nothing

test/test_predictive_control.jl

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,21 @@ end
5757
end
5858

5959
@testset "LinMPC moves and getinfo" begin
60-
mpc = LinMPC(LinModel(tf(5, [2, 1]), 3), Nwt=[0], Hp=1000, Hc=1)
60+
mpc1 = LinMPC(LinModel(tf(5, [2, 1]), 3), Nwt=[0], Hp=1000, Hc=1)
6161
r = [5]
62-
u = moveinput!(mpc, r)
62+
u = moveinput!(mpc1, r)
6363
@test u [1] atol=1e-2
64-
u = mpc(r)
64+
u = mpc1(r)
6565
@test u [1] atol=1e-2
66-
info, _ = getinfo(mpc)
66+
info, _ = getinfo(mpc1)
6767
@test info[:u] u
6868
@test info[:Ŷ][end] 5 atol=1e-2
69+
mpc2 = LinMPC(LinModel(tf(5, [2, 1]), 3), Nwt=[0], Cwt=Inf, Hp=1000, Hc=1)
70+
u = moveinput!(mpc2, [5])
71+
@test u [1] atol=1e-2
72+
mpc3 = LinMPC(LinModel(tf(5, [2, 1]), 3), Mwt=[0], Nwt=[0], Lwt=[1], ru=[12])
73+
u = moveinput!(mpc3, [0])
74+
@test u [12] atol=1e-2
6975
end
7076

7177
@testset "LinMPC other methods" begin

0 commit comments

Comments
 (0)