38 #include <ompl/base/spaces/SE2StateSpace.h>
39 #include <ompl/base/spaces/RealVectorStateSpace.h>
40 #include <ompl/base/SpaceInformation.h>
41 #include <ompl/base/StateSpace.h>
42 #include <ompl/multilevel/planners/qrrt/QRRT.h>
44 #include <boost/math/constants/constants.hpp>
50 bool boxConstraint(
const double values[])
52 const double &x = values[0] - 0.5;
53 const double &y = values[1] - 0.5;
54 double pos_cnstr = sqrt(x * x + y * y);
55 return (pos_cnstr > 0.2);
57 bool isStateValid_SE2(
const State *state)
62 return boxConstraint(R2->values) && (SO2->value < boost::math::constants::pi<double>() / 2.0);
64 bool isStateValid_R2(
const State *state)
67 return boxConstraint(R2->values);
73 auto SE2(std::make_shared<SE2StateSpace>());
77 SE2->setBounds(bounds);
79 si_SE2->setStateValidityChecker(isStateValid_SE2);
82 auto R2(std::make_shared<RealVectorStateSpace>(2));
85 si_R2->setStateValidityChecker(isStateValid_R2);
88 std::vector<SpaceInformationPtr> si_vec;
89 si_vec.push_back(si_R2);
90 si_vec.push_back(si_SE2);
94 SE2State start_SE2(SE2);
95 SE2State goal_SE2(SE2);
96 start_SE2->setXY(0, 0);
98 goal_SE2->setXY(1, 1);
102 pdef->setStartAndGoalStates(start_SE2, goal_SE2);
105 auto planner = std::make_shared<ompl::multilevel::QRRT>(si_vec);
108 planner->setProblemDefinition(pdef);
115 std::cout << std::string(80,
'-') << std::endl;
116 std::cout <<
"Bundle Space Path (SE2):" << std::endl;
117 std::cout << std::string(80,
'-') << std::endl;
118 pdef->getSolutionPath()->print(std::cout);
120 std::cout << std::string(80,
'-') << std::endl;
121 std::cout <<
"Base Space Path (R2) :" << std::endl;
122 std::cout << std::string(80,
'-') << std::endl;
124 pdefR2->getSolutionPath()->print(std::cout);
125 std::cout << std::string(80,
'-') << std::endl;