Skip to content

Commit a006525

Browse files
committed
test: new linearize test with no meas. dist. and AutoFiniteDiff
1 parent 4af3d73 commit a006525

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/controller/execute.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ function initpred!(mpc::PredictiveController, model::LinModel, d, D̂, R̂y, R̂
208208
F .+= mpc.B # F = F + B
209209
mul!(F, mpc.K, mpc.estim.x̂0, 1, 1) # F = F + K*x̂0
210210
mul!(F, mpc.V, mpc.estim.lastu0, 1, 1) # F = F + V*lastu0
211-
if model.nd 0
211+
if model.nd > 0
212212
mul!(F, mpc.G, mpc.d0, 1, 1) # F = F + G*d0
213213
mul!(F, mpc.J, mpc.D̂0, 1, 1) # F = F + J*D̂0
214214
end
@@ -256,7 +256,7 @@ is an [`InternalModel`](@ref). The function returns `mpc.F`.
256256
function initpred_common!(mpc::PredictiveController, model::SimModel, d, D̂, R̂y, R̂u)
257257
mul!(mpc.Tu_lastu0, mpc.Tu, mpc.estim.lastu0)
258258
mpc.ŷ .= evaloutput(mpc.estim, d)
259-
if model.nd 0
259+
if model.nd > 0
260260
mpc.d0 .= d .- model.dop
261261
mpc.D̂0 .=.- mpc.Dop
262262
mpc.D̂e[1:model.nd] .= d

test/1_test_sim_model.jl

+5
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,11 @@ end
355355
Ynl, Yl
356356
end
357357
@test all(isapprox.(Ynl, Yl, atol=1e-6))
358+
359+
f2!(xnext, x, u, _, _) = (xnext .= x .+ u)
360+
h2!(y, x, _, _) = (y .= x)
361+
nonlinmodel4 = NonLinModel(f2!,h2!,Ts,1,1,1,0,solver=nothing,jacobian=AutoFiniteDiff())
362+
@test_nowarn linearize(nonlinmodel4, x=[1], u=[2])
358363
end
359364

360365
@testitem "NonLinModel real time simulations" setup=[SetupMPCtests] begin

0 commit comments

Comments
 (0)