using std::shared_ptr;
int main(
int argc,
char** argv)
{
static const size_t STATE_DIM = 2;
static const size_t CONTROL_DIM = 1;
using SystemPtr = SwitchedSystem::SystemPtr;
using SwitchedSystems = SwitchedSystem::SwitchedSystems;
using Controller = std::shared_ptr<Controller<STATE_DIM, CONTROL_DIM>>;
double switchTime = 1.1624;
modeSequence.
addPhase(1, timeHorizon - switchTime);
Eigen::Matrix<double, STATE_DIM, 1> x_nominal, x_final;
Eigen::Matrix<double, CONTROL_DIM, 1> u_nominal;
Eigen::Matrix<double, STATE_DIM, STATE_DIM> Q, Q_final;
Eigen::Matrix<double, CONTROL_DIM, CONTROL_DIM> R;
x_nominal.setZero();
x_final << 10.0, 6.0;
u_nominal.setZero();
Q.setZero();
Q_final.setIdentity();
R.setIdentity();
std::shared_ptr<CostFunctionQuadratic<STATE_DIM, CONTROL_DIM>> quadraticCostFunction(
System::state_matrix_t A1_continuous, A2_continuous;
A1_continuous << 1.5, 0.0, 0.0, 1.0;
A2_continuous << 0.5, 0.866, 0.866, -0.5;
System::state_control_matrix_t B1_continuous, B2_continuous;
B1_continuous << 1.0, 1.0;
B2_continuous << 1.0, 1.0;
SystemPtr sysPtr1(
new System(A1_continuous, B1_continuous));
SystemPtr sysPtr2(
new System(A2_continuous, B2_continuous));
SwitchedSystems switchedSystems;
switchedSystems.push_back(sysPtr1);
switchedSystems.push_back(sysPtr2);
System::control_vector_t u0;
u0.setZero();
sysPtr1->setController(controller);
sysPtr2->setController(controller);
SwitchedLinearSystems switchedLinearSystems;
switchedLinearSystems.push_back(linSys1);
switchedLinearSystems.push_back(linSys2);
std::shared_ptr<SwitchedSystem> switchedSystem(new SwitchedSystem(switchedSystems, modeSequence, controller));
std::shared_ptr<SwitchedLinearSystem> switchedLinearSystem(
System::state_vector_t
x0;
x0 << 1.0, 1.0;
std::shared_ptr<ct::optcon::ConstraintContainerAD<STATE_DIM, CONTROL_DIM>> generalConstraints_1(
new ct::optcon::ConstraintContainerAD<STATE_DIM, CONTROL_DIM>());
generalConstraints_1->addIntermediateConstraint(phase1Constraint, verbose);
std::shared_ptr<ct::optcon::ConstraintContainerAD<STATE_DIM, CONTROL_DIM>> generalConstraints_2(
new ct::optcon::ConstraintContainerAD<STATE_DIM, CONTROL_DIM>());
generalConstraints_2->addIntermediateConstraint(phase2Constraint, verbose);
switchedConstraintContainers;
switchedConstraintContainers.push_back(generalConstraints_1);
switchedConstraintContainers.push_back(generalConstraints_2);
std::shared_ptr<SwitchedLinearConstraintContainer<STATE_DIM, CONTROL_DIM>> switchedConstraints(
switchedConstraints->initialize();
ilqr_settings.
dt = 0.001;
ilqr_settings.
integrator =
ct::core::IntegrationType::EULERCT;
ilqr_settings.
discretization = NLOptConSettings::APPROXIMATION::FORWARD_EULER;
ilqr_settings.
lqocp_solver = NLOptConSettings::LQOCP_SOLVER::HPIPM_SOLVER;
int kNUM_STEPS = ilqr_settings.
computeK(timeHorizon);
timeHorizon, x0, switchedSystem, quadraticCostFunction, switchedLinearSystem);
}