@@ -905,6 +905,33 @@ def test_gainsched_unicycle(unicycle, method):
905905 np .testing .assert_allclose (
906906 resp .states [:, - 1 ], Xd [:, - 1 ], atol = 1e-2 , rtol = 1e-2 )
907907
908+
909+ def test_gainsched_default_indices ():
910+ # Define a linear system to test
911+ sys = ct .ss ([[- 1 , 0.1 ], [0 , - 2 ]], [[0 ], [1 ]], np .eye (2 ), 0 )
912+
913+ # Define gains at origin + corners of unit cube
914+ points = [[0 , 0 ]] + list (itertools .product ([- 1 , 1 ], [- 1 , 1 ]))
915+
916+ # Define gain to be constant
917+ K , _ , _ = ct .lqr (sys , np .eye (sys .nstates ), np .eye (sys .ninputs ))
918+ gains = [K for p in points ]
919+
920+ # Define the paramters for the simulations
921+ timepts = np .linspace (0 , 10 , 100 )
922+ X0 = np .ones (sys .nstates ) * 0.9
923+
924+ # Create a controller and simulate the initial response
925+ gs_ctrl , gs_clsys = ct .create_statefbk_iosystem (sys , (gains , points ))
926+ gs_resp = ct .input_output_response (gs_clsys , timepts , 0 , X0 )
927+
928+ # Verify that we get the same result as a constant gain
929+ ck_clsys = ct .ss (sys .A - sys .B @ K , sys .B , sys .C , 0 )
930+ ck_resp = ct .input_output_response (ck_clsys , timepts , 0 , X0 )
931+
932+ np .testing .assert_allclose (gs_resp .states , ck_resp .states )
933+
934+
908935def test_gainsched_errors (unicycle ):
909936 # Set up gain schedule (same as previous test)
910937 speeds = [1 , 5 , 10 ]
0 commit comments