|
18 | 18 | from control.matlab import ss, tf, bode, rss |
19 | 19 | from control.tests.conftest import slycotonly |
20 | 20 |
|
| 21 | +from matplotlib.testing.decorators import image_comparison |
| 22 | + |
21 | 23 | pytestmark = pytest.mark.usefixtures("mplcleanup") |
22 | 24 |
|
23 | 25 |
|
@@ -345,3 +347,25 @@ def test_phase_wrap(TF, wrap_phase, min_phase, max_phase): |
345 | 347 | mag, phase, omega = ctrl.bode(TF, wrap_phase=wrap_phase) |
346 | 348 | assert(min(phase) >= min_phase) |
347 | 349 | assert(max(phase) <= max_phase) |
| 350 | + |
| 351 | +@pytest.fixture |
| 352 | +def pvtol_inner(): |
| 353 | + m = 4 # mass of aircraft |
| 354 | + J = 0.0475 # inertia around pitch axis |
| 355 | + r = 0.25 # distance to center of force |
| 356 | + g = 9.8 # gravitational constant |
| 357 | + c = 0.05 # damping factor (estimated) |
| 358 | + |
| 359 | + # Transfer functions for dynamics |
| 360 | + Pi = ctrl.tf([r], [J, 0, 0]) # inner loop (roll) |
| 361 | + |
| 362 | + k, a, b = 200, 2, 50 # control parameters |
| 363 | + Ci = k * ctrl.tf([1, a], [1, b]) # lead compensator |
| 364 | + |
| 365 | + return (Pi, Ci) |
| 366 | + |
| 367 | +# Regression test for Gang of 4 plots |
| 368 | +@image_comparison(baseline_images=['gangof4-pvtol'], extensions=['png']) |
| 369 | +def test_gangof4_pvtol(pvtol_inner): |
| 370 | + plt.figure(num=None, figsize=(8, 6), dpi=80) |
| 371 | + ctrl.gangof4(*pvtol_inner) |
0 commit comments