| 14 | |
| 15 | @pytest.fixture |
| 16 | def lqr_problem(): |
| 17 | nx = 3 |
| 18 | nu = 3 |
| 19 | space = VectorSpace(nx) |
| 20 | x0 = space.rand() |
| 21 | A = np.eye(nx) |
| 22 | A[0, 1] = -0.2 |
| 23 | A[1, 0] = 0.2 |
| 24 | B = np.eye(nx, nu) |
| 25 | c = np.zeros(nx) |
| 26 | dyn = LinearDiscreteDynamics(A, B, c) |
| 27 | Q = 1e-2 * np.eye(nx) |
| 28 | R = 1e-2 * np.eye(nu) |
| 29 | N = 1e-5 * np.eye(nx, nu) |
| 30 | cost = aligator.QuadraticCost(w_x=Q, w_u=R, w_cross=N) |
| 31 | problem = aligator.TrajOptProblem(x0, nu, space, cost) |
| 32 | nsteps = 10 |
| 33 | for _ in range(nsteps): |
| 34 | stage = aligator.StageModel(cost, dyn) |
| 35 | problem.addStage(stage) |
| 36 | return problem, nx, nu, x0 |
| 37 | |
| 38 | |
| 39 | def test_fddp_lqr(lqr_problem): |