Skip to content

Commit 4dc08bf

Browse files
committed
global
1 parent e09543a commit 4dc08bf

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

examples/lqg_mpc_disturbance.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ X = [x[]] # For storage
8585
U = Float64[]
8686
u_mpc = [0.0]
8787
for i = 1:50
88+
global x, xh, u_mpc
8889
y = G.C*x # Compute the true measurement output
8990
xh = obs.A * xh + obs.B*[u_mpc; y] # Predict one step with the observer, u here is the control signal from the previous iteration, if using the predictor, use u from the current iteration and perform the observer update in the end of the loop instead
9091
u_disturbance = i * Ts 10 ? 1.0 : 0.0
@@ -96,11 +97,10 @@ for i = 1:50
9697
push!(U, u_mpc[])
9798
end
9899

100+
using Test
101+
@test (G.C*X[end])[] 1 rtol=1e-4
99102

100103
plot(X*G.C', layout=2, sp=1, label="\$y\$")
101104
plot!(U, sp=2, label="\$u\$")
102105
hline!([1.0 3.0], linestyle=:dash, color=:black, label=["Reference" "\$u_{max}\$"], sp=[1 2])
103106

104-
105-
using Test
106-
@test (G.C*X[end])[] 1 rtol=1e-4

0 commit comments

Comments
 (0)