@@ -113,15 +113,46 @@ def test_kinematic_car(self, vehicle_flat, poly):
113113 np .testing .assert_array_almost_equal (uf , u [:, 1 ])
114114
115115 # Simulate the system and make sure we stay close to desired traj
116- T = np .linspace (0 , Tf , 500 )
116+ T = np .linspace (0 , Tf , 100 )
117117 xd , ud = traj .eval (T )
118+ resp = ct .input_output_response (vehicle_flat , T , ud , x0 )
119+ np .testing .assert_array_almost_equal (resp .states , xd , decimal = 2 )
118120
119121 # For SciPy 1.0+, integrate equations and compare to desired
120122 if StrictVersion (sp .__version__ ) >= "1.0" :
121123 t , y , x = ct .input_output_response (
122124 vehicle_flat , T , ud , x0 , return_x = True )
123125 np .testing .assert_allclose (x , xd , atol = 0.01 , rtol = 0.01 )
124126
127+ def test_flat_default_output (self , vehicle_flat ):
128+ # Construct a flat system with the default outputs
129+ flatsys = fs .FlatSystem (
130+ vehicle_flat .forward , vehicle_flat .reverse , vehicle_flat .updfcn ,
131+ inputs = vehicle_flat .ninputs , outputs = vehicle_flat .ninputs ,
132+ states = vehicle_flat .nstates )
133+
134+ # Define the endpoints of the trajectory
135+ x0 = [0. , - 2. , 0. ]; u0 = [10. , 0. ]
136+ xf = [100. , 2. , 0. ]; uf = [10. , 0. ]
137+ Tf = 10
138+
139+ # Find trajectory between initial and final conditions
140+ poly = fs .PolyFamily (6 )
141+ traj1 = fs .point_to_point (vehicle_flat , Tf , x0 , u0 , xf , uf , basis = poly )
142+ traj2 = fs .point_to_point (flatsys , Tf , x0 , u0 , xf , uf , basis = poly )
143+
144+ # Verify that the trajectory computation is correct
145+ T = np .linspace (0 , Tf , 10 )
146+ x1 , u1 = traj1 .eval (T )
147+ x2 , u2 = traj2 .eval (T )
148+ np .testing .assert_array_almost_equal (x1 , x2 )
149+ np .testing .assert_array_almost_equal (u1 , u2 )
150+
151+ # Run a simulation and verify that the outputs are correct
152+ resp1 = ct .input_output_response (vehicle_flat , T , u1 , x0 )
153+ resp2 = ct .input_output_response (flatsys , T , u1 , x0 )
154+ np .testing .assert_array_almost_equal (resp1 .outputs [0 :2 ], resp2 .outputs )
155+
125156 def test_flat_cost_constr (self ):
126157 # Double integrator system
127158 sys = ct .ss ([[0 , 1 ], [0 , 0 ]], [[0 ], [1 ]], [[1 , 0 ]], 0 )
0 commit comments