@@ -452,6 +452,29 @@ def test_flat_solve_ocp(self, basis):
|
452 | 452 | np.testing.assert_almost_equal(x_const, x_nlconst) |
453 | 453 | np.testing.assert_almost_equal(u_const, u_nlconst) |
454 | 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 | +terminal_cost=terminal_cost) |
| 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 | + |
455 | 478 | def test_bezier_basis(self): |
456 | 479 | bezier = fs.BezierFamily(4) |
457 | 480 | time = np.linspace(0, 1, 100) |
|