Skip to content

Commit

Permalink
Merge pull request #600 from bnavigator/fix-598
Browse files Browse the repository at this point in the history
Include InfValue into settling min/max calculation for step_info
  • Loading branch information
bnavigator committed Apr 1, 2021
2 parents 9edc768 + e06197c commit f1a9860
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
24 changes: 22 additions & 2 deletions control/tests/timeresp_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,23 @@ def siso_tf_kneg(self):
'SteadyStateValue': -1.0}
return T

@pytest.fixture
def siso_tf_asymptotic_from_neg1(self):
# Peak_value = Undershoot = y_final(y(t=inf))
T = TSys(TransferFunction([-1, 1], [1, 1]))
T.step_info = {
'RiseTime': 2.197,
'SettlingTime': 4.605,
'SettlingMin': 0.9,
'SettlingMax': 1.0,
'Overshoot': 0,
'Undershoot': 100.0,
'Peak': 1.0,
'PeakTime': 0.0,
'SteadyStateValue': 1.0}
T.kwargs = {'step_info': {'T': np.arange(0, 5, 1e-3)}}
return T

@pytest.fixture
def siso_tf_step_matlab(self):
# example from matlab online help
Expand Down Expand Up @@ -348,7 +365,8 @@ def tsystem(self,
pole_cancellation, no_pole_cancellation, siso_tf_type1,
siso_tf_kpos, siso_tf_kneg,
siso_tf_step_matlab, siso_ss_step_matlab,
mimo_ss_step_matlab, mimo_tf_step_info):
mimo_ss_step_matlab, mimo_tf_step_info,
siso_tf_asymptotic_from_neg1):
systems = {"siso_ss1": siso_ss1,
"siso_ss2": siso_ss2,
"siso_tf1": siso_tf1,
Expand All @@ -373,6 +391,7 @@ def tsystem(self,
"siso_ss_step_matlab": siso_ss_step_matlab,
"mimo_ss_step_matlab": mimo_ss_step_matlab,
"mimo_tf_step": mimo_tf_step_info,
"siso_tf_asymptotic_from_neg1": siso_tf_asymptotic_from_neg1,
}
return systems[request.param]

Expand Down Expand Up @@ -466,7 +485,8 @@ def assert_step_info_match(self, sys, info, info_ref):
"siso_ss_step_matlab",
"siso_tf_kpos",
"siso_tf_kneg",
"siso_tf_type1"],
"siso_tf_type1",
"siso_tf_asymptotic_from_neg1"],
indirect=["tsystem"])
def test_step_info(self, tsystem, systype, time_2d, yfinal):
"""Test step info for SISO systems."""
Expand Down
4 changes: 2 additions & 2 deletions control/timeresp.py
Original file line number Diff line number Diff line change
Expand Up @@ -912,8 +912,8 @@ def step_info(sysdata, T=None, T_num=None, yfinal=None,
if settled < len(T):
settling_time = T[settled]

settling_min = (yout[tr_upper_index:]).min()
settling_max = (yout[tr_upper_index:]).max()
settling_min = min((yout[tr_upper_index:]).min(), InfValue)
settling_max = max((yout[tr_upper_index:]).max(), InfValue)

# Overshoot
y_os = (sgnInf * yout).max()
Expand Down

0 comments on commit f1a9860

Please sign in to comment.