30 #ifndef EXOTICA_OMPL_CONTROL_SOLVER_OMPL_CONTROL_SOLVER_H_ 31 #define EXOTICA_OMPL_CONTROL_SOLVER_OMPL_CONTROL_SOLVER_H_ 37 #include <exotica_ompl_control_solver/ompl_control_solver_initializer.h> 40 #include <ompl/base/goals/GoalState.h> 41 #include <ompl/base/spaces/SE2StateSpace.h> 42 #include <ompl/control/SimpleSetup.h> 43 #include <ompl/control/SpaceInformation.h> 44 #include <ompl/control/spaces/RealVectorControlSpace.h> 46 namespace ob = ompl::base;
47 namespace oc = ompl::control;
57 oc::SpaceInformationPtr si,
60 const ob::State *state,
61 const oc::Control *control,
62 const double duration,
63 ob::State *result)
const override 66 space_->copyState(result, state);
90 void Integrate(ob::State *ob_x,
const oc::Control *oc_u,
double dt)
const 92 const int NU = dynamics_solver_->get_num_controls();
93 const int NX = dynamics_solver_->get_num_positions() + dynamics_solver_->get_num_velocities();
95 double *
x = ob_x->as<ob::RealVectorStateSpace::StateType>()->
values;
96 double *u = oc_u->as<oc::RealVectorControlSpace::ControlType>()->
values;
98 Eigen::VectorXd eig_x = Eigen::Map<Eigen::VectorXd>(x, NX);
99 Eigen::VectorXd eig_u = Eigen::Map<Eigen::VectorXd>(u, NU);
101 Eigen::VectorXd x_new = dynamics_solver_->Simulate(eig_x, eig_u, dt);
102 std::memcpy(x, x_new.data(), NX *
sizeof(double));
111 void Solve(Eigen::MatrixXd &solution)
override;
119 template <
typename PlannerType>
122 ob::PlannerPtr planner(
new PlannerType(si));
137 bool isStateValid(
const oc::SpaceInformationPtr si,
const ob::State *state)
145 #endif // EXOTICA_OMPL_CONTROL_SOLVER_OMPL_CONTROL_SOLVER_H_
std::vector< double > values
std::unique_ptr< oc::SimpleSetup > setup_
DynamicsSolverPtr dynamics_solver_
static ob::PlannerPtr AllocatePlanner(const oc::SpaceInformationPtr &si)
void Integrate(ob::State *ob_x, const oc::Control *oc_u, double dt) const
OMPLControlSolverInitializer init_
!< Shared pointer to the dynamics solver.
oc::SpaceInformationPtr space_
DynamicTimeIndexedShootingProblemPtr prob_
std::shared_ptr< exotica::DynamicsSolver > DynamicsSolverPtr
void setIntegrationTimeStep(double timeStep)
DynamicsSolverPtr dynamics_solver_
!< Shared pointer to the planning problem.
bool isStateValid(const oc::SpaceInformationPtr si, const ob::State *state)
double getIntegrationTimeStep() const
std::shared_ptr< exotica::DynamicTimeIndexedShootingProblem > DynamicTimeIndexedShootingProblemPtr
ConfiguredPlannerAllocator planner_allocator_
OMPLStatePropagator(oc::SpaceInformationPtr si, DynamicsSolverPtr dynamics_solver_)
std::shared_ptr< PlanningProblem > PlanningProblemPtr
std::function< ob::PlannerPtr(const oc::SpaceInformationPtr &si)> ConfiguredPlannerAllocator
void propagate(const ob::State *state, const oc::Control *control, const double duration, ob::State *result) const override