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 92bd703 + a05b9d5 commit 2cb0520Copy full SHA for 2cb0520
control/flatsys/flatsys.py
@@ -721,8 +721,7 @@ def solve_flat_ocp(
721
722
# Process final time
723
timepts = np.atleast_1d(timepts)
724
- Tf = timepts[-1]
725
- T0 = timepts[0] if len(timepts) > 1 else T0
+ T0 = timepts[0] if len(timepts) > 1 else 0
726
727
# Process keyword arguments
728
if trajectory_constraints is None:
control/tests/flatsys_test.py
@@ -452,6 +452,29 @@ def test_flat_solve_ocp(self, basis):
452
np.testing.assert_almost_equal(x_const, x_nlconst)
453
np.testing.assert_almost_equal(u_const, u_nlconst)
454
455
+ def test_solve_flat_ocp_scalar_timepts(self):
456
+ # scalar timepts gives expected result
457
+ f = fs.LinearFlatSystem(ct.ss(ct.tf([1],[1,1])))
458
+
459
+ def terminal_cost(x, u):
460
+ return (x-5).dot(x-5)+u.dot(u)
461
462
+ traj1 = fs.solve_flat_ocp(f, [0, 1], x0=[23],
463
+ terminal_cost=terminal_cost)
464
465
+ traj2 = fs.solve_flat_ocp(f, 1, x0=[23],
466
467
468
+ teval = np.linspace(0, 1, 101)
469
470
+ r1 = traj1.response(teval)
471
+ r2 = traj2.response(teval)
472
473
+ np.testing.assert_array_equal(r1.x, r2.x)
474
+ np.testing.assert_array_equal(r1.y, r2.y)
475
+ np.testing.assert_array_equal(r1.u, r2.u)
476
477
478
def test_bezier_basis(self):
479
bezier = fs.BezierFamily(4)
480
time = np.linspace(0, 1, 100)
0 commit comments