Skip to content

Commit 6fb787d

Browse files
authored
Merge pull request #420 from JuliaControl/test_dist_rej_nmpc
test: new `NonLinMPC` disturbance rejection test with `MultipleShooting` and `nint_u` options
2 parents 55b7999 + 151b1bd commit 6fb787d

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

‎test/3_test_predictive_control.jl‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,6 +1128,26 @@ end
11281128
end
11291129
@test u ≈ [2] atol=1e-2
11301130
@test ym ≈ r atol=1e-2
1131+
f(x,u,_,model) = model.A*x + model.Bu*u
1132+
h(x,_,model) = model.C*x
1133+
nlmodel = NonLinModel(f, h, linmodel.Ts, 1, 1, 1, 0, p=linmodel, solver=nothing)
1134+
nlmodel = setop!(nlmodel, yop=[10])
1135+
u, ym = let nlmodel=nlmodel, r=r, outdist=outdist
1136+
estim = UnscentedKalmanFilter(nlmodel, nint_u=[1])
1137+
nmpc_nint_u_ms = NonLinMPC(estim; Hp=10, transcription=MultipleShooting())
1138+
nlmodel.x0 .= 0
1139+
ym, u = nlmodel() - outdist, [0.0]
1140+
for i=1:25
1141+
ym = nlmodel() - outdist
1142+
preparestate!(nmpc_nint_u_ms, ym)
1143+
u = moveinput!(nmpc_nint_u_ms, r)
1144+
updatestate!(nmpc_nint_u_ms, u, ym)
1145+
updatestate!(nlmodel, u)
1146+
end
1147+
u, ym
1148+
end
1149+
@test u ≈ [2] atol=1e-2
1150+
@test ym ≈ r atol=1e-2
11311151
end
11321152

11331153
@testitem "NonLinMPC and ManualEstimator v.s. default" setup=[SetupMPCtests] begin

0 commit comments

Comments
 (0)