14 #include "../../testSystems/LinkedMasses.h" 16 TEST(HPIPMInterfaceTest, compareSolvers)
25 std::shared_ptr<LQOCProblem_t> lqocProblem_hpipm(
new LQOCProblem_t(N));
26 std::shared_ptr<LQOCProblem_t> lqocProblem_gnriccati(
new LQOCProblem_t(N));
34 stateOffset.setConstant(0.1);
50 Q, R, -stateOffset, u0, -stateOffset, Q);
53 std::shared_ptr<ct::core::LinearSystem<state_dim, control_dim>> system(
new LinkedMasses());
55 dt, system, ct::optcon::NLOptConSettings::APPROXIMATION::MATRIX_EXPONENTIAL);
58 lqocProblem_hpipm->setFromTimeInvariantLinearQuadraticProblem(discretizedSystem, costFunction, stateOffset, dt);
59 lqocProblem_gnriccati->setFromTimeInvariantLinearQuadraticProblem(discretizedSystem, costFunction, stateOffset, dt);
63 ct::optcon::HPIPMInterface<state_dim, control_dim> hpipm;
64 hpipm.setProblem(lqocProblem_hpipm);
66 hpipm.computeStatesAndControls();
67 hpipm.computeFeedbackMatrices();
89 ASSERT_EQ(x_sol_hpipm.size(), x_sol_gnrccati.size());
90 ASSERT_EQ(u_sol_hpipm.size(), u_sol_gnrccati.size());
93 for (
size_t i = 0;
i < x_sol_hpipm.size();
i++)
95 ASSERT_LT((x_sol_hpipm[
i] - x_sol_gnrccati[
i]).array().abs().maxCoeff(), 1e-6);
99 for (
size_t i = 0;
i < u_sol_hpipm.size();
i++)
101 ASSERT_LT((u_sol_hpipm[
i] - u_sol_gnrccati[
i]).array().abs().maxCoeff(), 1e-6);
105 for (
size_t i = 0;
i < K_sol_hpipm.size();
i++)
107 ASSERT_LT((K_sol_hpipm[
i] - K_sol_gnriccati[
i]).array().abs().maxCoeff(), 1e-6);
111 for (
size_t i = 0;
i < lv_sol_hpipm.size();
i++)
113 ASSERT_LT((lv_sol_hpipm[
i] - lv_sol_gnriccati[
i]).array().abs().maxCoeff(), 1e-6);
const ct::core::ControlVectorArray< CONTROL_DIM, SCALAR > & getSolutionControl()
return solution for control
Definition: LQOCSolver.hpp:86
virtual void compute_lv() override
compute iLQR-style lv
Definition: GNRiccatiSolver-impl.hpp:78
virtual const ct::core::ControlVectorArray< CONTROL_DIM, SCALAR > & get_lv()
return iLQR-style feedforward lv
Definition: LQOCSolver.hpp:95
virtual void solve() override
solve the LQOC problem
Definition: GNRiccatiSolver-impl.hpp:28
A simple quadratic cost function.
Definition: CostFunctionQuadraticSimple.hpp:23
const size_t state_dim
Definition: ConstraintExampleOutput.cpp:17
const double dt
Definition: LQOCSolverTiming.cpp:18
Defines a Linear-Quadratic Optimal Control Problem, which is optionally constrained.
Definition: LQOCProblem.hpp:57
for i
Definition: mpc_unittest_plotting.m:14
void setProblem(std::shared_ptr< LQOCProblem_t > lqocProblem)
Definition: LQOCSolver.hpp:42
const ct::core::FeedbackArray< STATE_DIM, CONTROL_DIM, SCALAR > & getSolutionFeedback()
Definition: LQOCSolver.hpp:90
Definition: GNRiccatiSolver.hpp:22
TEST(HPIPMInterfaceTest, compareSolvers)
Definition: HPIPMInterfaceTest.h:16
virtual void computeStatesAndControls() override
extract the solution (can be overriden if additional extraction steps required in specific solver) ...
Definition: GNRiccatiSolver-impl.hpp:56
virtual void computeFeedbackMatrices() override
return TVLQR feedback matrices
Definition: GNRiccatiSolver-impl.hpp:73
Definition: LinkedMasses.h:29
const ct::core::StateVectorArray< STATE_DIM, SCALAR > & getSolutionState()
return solution for state
Definition: LQOCSolver.hpp:84
StateVector< state_dim > x0
Definition: ConstrainedNLOCTest.cpp:14
const size_t control_dim
Definition: ConstraintExampleOutput.cpp:18