Skip to content

Commit b982e75

Browse files
committed
Add RobustAndOptimalControl
1 parent fc6671e commit b982e75

File tree

2 files changed

+26
-14
lines changed

2 files changed

+26
-14
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@ NOMAD = "02130f1c-4665-5b79-af82-ff1385104aa0"
5151
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
5252

5353
[targets]
54-
test = ["Test", "ControlPlots", "Documenter", "Aqua", "NOMAD"]
54+
test = ["Test", "ControlPlots", "Documenter", "Aqua", "NOMAD", "RobustAndOptimalControl"]

mwes/mwe_07.jl

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Linearize the closed loop system consisting of the winch, kite and upper force controller.
22

33
using Pkg
4-
if ! ("ControlPlots" keys(Pkg.project().dependencies))
4+
if ! ("RobustAndOptimalControl" keys(Pkg.project().dependencies))
55
using TestEnv; TestEnv.activate()
66
using Test
77
end
@@ -94,16 +94,28 @@ function open_loop_system(winch, v_set, v_wind)
9494
return C * sys
9595
end
9696

97-
for v_wind in range(7.5, 9, length=2)
98-
global sys
99-
local v_set
100-
v_set = 0.57*v_wind
101-
# @info "Linearizing for v_wind: $v_wind m/s, v_ro: $(round(v_set, digits=2)) m/s"
102-
sys = open_loop_system(winch, v_set, v_wind)
103-
# gm, pm, wgm, wpm = margin(sys; adjust_phase_start=false)
104-
# @info "Gain margin: $gm, Phase margin: $pm, Gain crossover frequency: $wgm, Phase crossover frequency: $wpm"
105-
# bode_plot(sys; from=0.76, to=2.85, title="Linearized System, v_wind=8..9 m/s")
97+
function margins(sys)
98+
margins = []
99+
for v_wind in range(1, 9, length=9)
100+
global sys
101+
local v_set, dm
102+
v_set = 0.57*v_wind
103+
sys = open_loop_system(winch, v_set, v_wind)
104+
dm = diskmargin(sys)
105+
push!(margins, dm.margin)
106+
end
107+
min_margin = minimum(margins)
108+
if min_margin < 0.3
109+
@error "System is unstable with a minimum margin of: $min_margin"
110+
elseif min_margin < 0.5
111+
@warn "System is marginally stable with a minimum margin of: $min_margin"
112+
else
113+
@info "System is stable with a minimum margin of: $min_margin"
114+
end
115+
return margins
106116
end
107-
dm = diskmargin(sys)
108-
@info "$dm"
109-
plot(dm)
117+
margins(sys)
118+
119+
# dm = diskmargin(sys)
120+
# @info "$dm"
121+
# plot(dm)

0 commit comments

Comments
 (0)