We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 86ebb1c + 0f37e9f commit b7e7ae9Copy full SHA for b7e7ae9
2 files changed
control/statefbk.py
@@ -195,7 +195,7 @@ def lqr(*args, **keywords):
195
#
196
197
# Get the system description
198
- if (len(args) < 4):
+ if (len(args) < 3):
199
raise ControlArgument("not enough input arguments")
200
201
try:
control/tests/statefbk_test.py
@@ -136,7 +136,27 @@ def testAcker(self):
136
np.testing.assert_array_almost_equal(np.sort(poles),
137
np.sort(placed), decimal=4)
138
139
-def suite():
+ def check_LQR(self, K, S, poles, Q, R):
140
+ S_expected = np.array(np.sqrt(Q * R))
141
+ K_expected = S_expected / R
142
+ poles_expected = np.array([-K_expected])
143
+ np.testing.assert_array_almost_equal(S, S_expected)
144
+ np.testing.assert_array_almost_equal(K, K_expected)
145
+ np.testing.assert_array_almost_equal(poles, poles_expected)
146
+
147
148
+ def test_LQR_integrator(self):
149
+ A, B, Q, R = 0., 1., 10., 2.
150
+ K, S, poles = lqr(A, B, Q, R)
151
+ self.check_LQR(K, S, poles, Q, R)
152
153
+ def test_LQR_3args(self):
154
+ sys = ss(0., 1., 1., 0.)
155
+ Q, R = 10., 2.
156
+ K, S, poles = lqr(sys, Q, R)
157
158
159
+def test_suite():
160
return unittest.TestLoader().loadTestsFromTestCase(TestStatefbk)
161
162
if __name__ == '__main__':
0 commit comments