Skip to content

Commit bb52b70

Browse files
committed
addressed @slivingston review comments
1 parent 96b7b73 commit bb52b70

File tree

3 files changed

+32
-10
lines changed

3 files changed

+32
-10
lines changed

control/statefbk.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -696,11 +696,11 @@ def create_statefbk_iosystem(
696696
-------
697697
ctrl : NonlinearIOSystem
698698
Input/output system representing the controller. For the 'trajgen'
699-
design patter (default), this system takes as inputs the desired
699+
design pattern (default), this system takes as inputs the desired
700700
state `x_d`, the desired input `u_d`, and either the system state
701701
`x` or the estimated state `xhat`. It outputs the controller
702702
action `u` according to the formula `u = u_d - K(x - x_d)`. For
703-
the 'refgain' design patter, the system takes as inputs the
703+
the 'refgain' design pattern, the system takes as inputs the
704704
reference input `r` and the system or estimated state. If the
705705
keyword `integral_action` is specified, then an additional set of
706706
integrators is included in the control system (with the gain matrix
@@ -779,6 +779,11 @@ def create_statefbk_iosystem(
779779
if kwargs:
780780
raise TypeError("unrecognized keywords: ", str(kwargs))
781781

782+
# Check for consistency of positional parameters
783+
if feedfwd_gain is not None and feedfwd_pattern != 'refgain':
784+
raise ControlArgument(
785+
"feedfwd_gain specified but feedfwd_pattern != 'refgain'")
786+
782787
# Figure out what inputs to the system to use
783788
control_indices = _process_indices(
784789
control_indices, 'control', sys.input_labels, sys.ninputs)

control/tests/statefbk_test.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,8 +1145,10 @@ def test_gainsched_errors(unicycle):
11451145

11461146

11471147
@pytest.mark.parametrize("ninputs, Kf", [
1148-
(1, 1), (1, None),
1149-
(2, np.diag([1, 1])), (2, None),
1148+
(1, 1),
1149+
(1, None),
1150+
(2, np.diag([1, 1])),
1151+
(2, None),
11501152
])
11511153
def test_refgain_pattern(ninputs, Kf):
11521154
sys = ct.rss(2, 2, ninputs, strictly_proper=True)
@@ -1178,3 +1180,17 @@ def test_refgain_pattern(ninputs, Kf):
11781180
np.testing.assert_almost_equal(clsys.B, manual.B)
11791181
np.testing.assert_almost_equal(clsys.C[:sys.nstates, :], manual.C)
11801182
np.testing.assert_almost_equal(clsys.D[:sys.nstates, :], manual.D)
1183+
1184+
1185+
def test_create_statefbk_errors():
1186+
sys = ct.rss(2, 2, 1, strictly_proper=True)
1187+
sys.C = np.eye(2)
1188+
K = -np.ones((1, 4))
1189+
Kf = 1
1190+
1191+
K, _, _ = ct.lqr(sys.A, sys.B, np.eye(sys.nstates), np.eye(sys.ninputs))
1192+
with pytest.raises(NotImplementedError, match="unknown pattern"):
1193+
ct.create_statefbk_iosystem(sys, K, feedfwd_pattern='mypattern')
1194+
1195+
with pytest.raises(ControlArgument, match="feedfwd_pattern != 'refgain'"):
1196+
ct.create_statefbk_iosystem(sys, K, Kf, feedfwd_pattern='trajgen')

doc/iosys.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Example
5757

5858
To illustrate the use of the input/output systems module, we create a
5959
model for a predator/prey system, following the notation and parameter
60-
values in FBS2e.
60+
values in `Feedback Systems <http://fbsbook.org>`_.
6161

6262
We begin by defining the dynamics of the system
6363

@@ -129,7 +129,8 @@ system and computing the linearization about that point.
129129
130130
We next compute a controller that stabilizes the equilibrium point using
131131
eigenvalue placement and computing the feedforward gain using the number of
132-
lynxes as the desired output (following FBS2e, Example 7.5):
132+
lynxes as the desired output (following `Feedback Systems
133+
<http://fbsbook.org>`_, Example 7.5):
133134

134135
.. code-block:: python
135136
@@ -488,10 +489,10 @@ A reference gain controller can be created with the command::
488489

489490
ctrl, clsys = ct.create_statefbk_iosystem(sys, K, kf, feedfwd_pattern='refgain')
490491

491-
This reference gain design pattern is described in more detail in Section
492-
7.2 of FBS2e (Stabilization by State Feedback) and the trajectory
493-
generation design pattern is described in Section 8.5 (State Space
494-
Controller Design).
492+
This reference gain design pattern is described in more detail in
493+
Section 7.2 of `Feedback Systems <http://fbsbook.org>`_ (Stabilization
494+
by State Feedback) and the trajectory generation design pattern is
495+
described in Section 8.5 (State Space Controller Design).
495496

496497
If the full system state is not available, the output of a state
497498
estimator can be used to construct the controller using the command::

0 commit comments

Comments
 (0)