|
1 | 1 | include("planar_flat.jl") # Get FlatDyadBot |
2 | | - |
3 | 2 | using DyadControlSystems |
4 | 3 | import DyadControlSystems as JSC |
5 | 4 | using LinearAlgebra |
|
56 | 55 | # - 2 controlled outputs: same as measurements (regulate both) |
57 | 56 | # - 1 control input: torque (tau) |
58 | 57 | lqg_spec = JSC.LQGAnalysisSpec(; |
59 | | - name = :SegwayLQG, |
| 58 | + name = :DyadBotLQG, |
60 | 59 | model = plant, |
61 | 60 | measurement = ["y_x", "y_theta"], # What we measure |
62 | 61 | controlled_output = ["y_x", "y_xd", "y_theta", "y_thetad"], # What we want to control |
63 | 62 | control_input = ["u"], # Control input |
| 63 | + loop_openings = ["u"], |
64 | 64 | q1_diag = [10.0, 0.1, 1, 0.1], # Penalty on controlled outputs (x, theta) |
65 | 65 | q2_diag = [0.0001], # Penalty on control input (tau) |
66 | 66 | r1_diag = [1.0], # Disturbance noise covariance |
@@ -139,22 +139,24 @@ plot(sol, idxs=[ |
139 | 139 |
|
140 | 140 | ## |
141 | 141 |
|
142 | | -# LT = lqg_asol.Cfb*system_mapping(lqg_asol.P_ext) |
| 142 | +Lo = system_mapping(lqg_asol.P_ext)*lqg_asol.Cfb |
| 143 | +Li = lqg_asol.Cfb*system_mapping(lqg_asol.P_ext) |
143 | 144 |
|
144 | 145 | # ## |
145 | | -# L2 = get_named_looptransfer(lqg_cl, [lqg_cl.u]) |
146 | | -# L2 = -minreal(L2, 1e-8) |
| 146 | +L2 = get_named_looptransfer(lqg_cl, [lqg_cl.u]) |
| 147 | +L2 = -minreal(L2, 1e-8) |
| 148 | + |
| 149 | +S2 = get_named_sensitivity(lqg_cl, [lqg_cl.u]) |
147 | 150 |
|
148 | | -# S2 = get_named_sensitivity(lqg_cl, [lqg_cl.u]) |
149 | 151 |
|
150 | 152 |
|
151 | | -# dmi = diskmargin(LT, offset=0) |
152 | | -# dmi2 = diskmargin(L2, offset=0) # offset due to hard to cancel pole/zero pair in origin |
| 153 | +dmi = diskmargin(Li, offset=0) |
| 154 | +dmi2 = diskmargin(L2, offset=0) # offset due to hard to cancel pole/zero pair in origin |
153 | 155 |
|
154 | | -# plot(dmi) |
155 | | -# plot!(dmi2) |
| 156 | +plot(dmi) |
| 157 | +plot!(dmi2) |
156 | 158 |
|
157 | | -# bodeplot([LT, L2], adjust_phase_start=false) # why not identical? |
| 159 | +bodeplot([Li, L2], adjust_phase_start=false) # Verify equal |
158 | 160 |
|
159 | 161 | # ## |
160 | 162 | # P_ext = system_mapping(lqg_asol.P_ext) |
|
0 commit comments