Skip to content

Commit 9b3dd7c

Browse files
committed
more comprehensive system construction tests
1 parent af1f668 commit 9b3dd7c

2 files changed

Lines changed: 21 additions & 12 deletions

File tree

control/sisotool.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def _SisotoolUpdate(sys, fig, K, bode_plot_params, tvect=None):
185185
def rootlocus_pid_designer(plant, gain='P', sign=+1, input_signal='r',
186186
Kp0=0, Ki0=0, Kd0=0, tau=0.01,
187187
C_ff=0, derivative_in_feedback_path=False,
188-
noplot=False):
188+
plot=True):
189189
"""Manual PID controller design based on root locus using Sisotool
190190
191191
Uses `Sisotool` to investigate the effect of adding or subtracting an
@@ -262,7 +262,8 @@ def rootlocus_pid_designer(plant, gain='P', sign=+1, input_signal='r',
262262
derivative_in_feedback_path : bool (optional)
263263
Whether to place the derivative term in feedback transfer function
264264
`C_b` instead of the forward transfer function `C_f`.
265-
noplot : bool (optional)
265+
plot : bool (optional)
266+
Whether to create Sisotool interactive plot.
266267
267268
Returns
268269
----------
@@ -328,6 +329,6 @@ def rootlocus_pid_designer(plant, gain='P', sign=+1, input_signal='r',
328329
C_ff, e_summer, u_summer),
329330
inplist=['input', input_signal],
330331
outlist=['output', 'y'])
331-
if ~noplot:
332+
if plot:
332333
sisotool(loop, kvect=(0.,))
333334
return _convert_to_statespace(loop[1, 1])

control/tests/sisotool_test.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -151,18 +151,26 @@ def plant(self, request):
151151
'syscont221':StateSpace([[-.3, 0],[1,0]],[[-1,],[.1,]], [0, -.3], 0)}
152152
return plants[request.param]
153153

154-
# check
155-
# cont or discrete, vary P I or D
156-
# @pytest.mark.parametrize('plant', (syscont, sysdisc1))
157-
@pytest.mark.parametrize('plant', ('syscont', 'sysdisc1'), indirect=True)
154+
# test permutations of system construction without plotting
155+
@pytest.mark.parametrize('plant', ('syscont', 'sysdisc1', 'syscont221'), indirect=True)
158156
@pytest.mark.parametrize('gain', ('P', 'I', 'D'))
159-
@pytest.mark.parametrize("kwargs", [{'Kp0':0.1, 'noplot':True},])
160-
def test_pid_designer_1(self, plant, gain, kwargs):
161-
rootlocus_pid_designer(plant, gain, **kwargs)
162-
157+
@pytest.mark.parametrize('sign', (1,))
158+
@pytest.mark.parametrize('input_signal', ('r', 'd'))
159+
@pytest.mark.parametrize('Kp0', (0,))
160+
@pytest.mark.parametrize('Ki0', (1.,))
161+
@pytest.mark.parametrize('Kd0', (0.1,))
162+
@pytest.mark.parametrize('tau', (0.01,))
163+
@pytest.mark.parametrize('C_ff', (0, 1,))
164+
@pytest.mark.parametrize('derivative_in_feedback_path', (True, False,))
165+
@pytest.mark.parametrize("kwargs", [{'plot':False},])
166+
def test_pid_designer_1(self, plant, gain, sign, input_signal, Kp0, Ki0, Kd0, tau, C_ff,
167+
derivative_in_feedback_path, kwargs):
168+
rootlocus_pid_designer(plant, gain, sign, input_signal, Kp0, Ki0, Kd0, tau, C_ff,
169+
derivative_in_feedback_path, **kwargs)
170+
171+
# test creation of sisotool plot
163172
# input from reference or disturbance
164173
@pytest.mark.parametrize('plant', ('syscont', 'syscont221'), indirect=True)
165-
# @pytest.mark.parametrize('plant', (syscont, syscont221))
166174
@pytest.mark.parametrize("kwargs", [
167175
{'input_signal':'r', 'Kp0':0.01, 'derivative_in_feedback_path':True},
168176
{'input_signal':'d', 'Kp0':0.01, 'derivative_in_feedback_path':True},])

0 commit comments

Comments
 (0)