Skip to content

Commit 362f46d

Browse files
committed
add gangof4 unit test using mpl.image_comparison
1 parent a64f7f1 commit 362f46d

4 files changed

Lines changed: 26 additions & 0 deletions

File tree

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ Untitled*.ipynb
2323
# Files created by or for emacs (RMM, 29 Dec 2017)
2424
*~
2525
TAGS
26+
result_images/
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/Users/murray/Dropbox/macosx/src/python-control/murrayrm/control/tests/baseline_images/freqresp_test/gangof4-pvtol.png
38.4 KB
Loading

‎control/tests/freqresp_test.py‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
from control.matlab import ss, tf, bode, rss
1919
from control.tests.conftest import slycotonly
2020

21+
from matplotlib.testing.decorators import image_comparison
22+
2123
pytestmark = pytest.mark.usefixtures("mplcleanup")
2224

2325

@@ -345,3 +347,25 @@ def test_phase_wrap(TF, wrap_phase, min_phase, max_phase):
345347
mag, phase, omega = ctrl.bode(TF, wrap_phase=wrap_phase)
346348
assert(min(phase) >= min_phase)
347349
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

Comments
 (0)