|
1 | 1 | # Linearize the closed loop system consisting of the winch, kite and upper force controller. |
2 | 2 |
|
3 | 3 | using Pkg |
4 | | -if ! ("ControlPlots" ∈ keys(Pkg.project().dependencies)) |
| 4 | +if ! ("RobustAndOptimalControl" ∈ keys(Pkg.project().dependencies)) |
5 | 5 | using TestEnv; TestEnv.activate() |
6 | 6 | using Test |
7 | 7 | end |
@@ -94,16 +94,28 @@ function open_loop_system(winch, v_set, v_wind) |
94 | 94 | return C * sys |
95 | 95 | end |
96 | 96 |
|
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 |
106 | 116 | 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