13 #include <ompl/base/objectives/PathLengthOptimizationObjective.h>
14 #include <ompl/geometric/planners/rrt/RRTConnect.h>
15 #include <ompl/geometric/planners/rrt/RRTstar.h>
16 #include <ompl/tools/multiplan/OptimizePlan.h>
17 #include <omplapp/apps/SE3RigidBodyPlanning.h>
18 #include <omplapp/config.h>
28 std::string robot_fname = std::string(OMPLAPP_RESOURCE_DIR) +
"/3D/cubicles_robot.dae";
29 std::string env_fname = std::string(OMPLAPP_RESOURCE_DIR) +
"/3D/cubicles_env.dae";
30 setup.setRobotMesh(robot_fname);
31 setup.setEnvironmentMesh(env_fname);
38 start->rotation().setIdentity();
45 goal->rotation().setIdentity();
48 setup.setStartAndGoalStates(start, goal);
51 setup.getSpaceInformation()->setStateValidityCheckingResolution(0.01);
54 setup.getProblemDefinition()->setOptimizationObjective(
55 std::make_shared<base::PathLengthOptimizationObjective>(setup.getSpaceInformation()));
59 std::stringstream res;
62 setup.setPlanner(std::make_shared<geometric::RRTstar>(setup.getSpaceInformation()));
63 res <<
"RRT*" << std::endl;
64 for (
double time = 1.0; time < 10.1; time = time + 1.0)
69 if (setup.solve(time) && setup.haveExactSolutionPath())
70 length = setup.getSolutionPath().length();
71 res <<
"time = " << setup.getLastPlanComputationTime() <<
" \t length = " << length << std::endl;
75 res <<
"RRTConnect with path hybridization (one thread)" << std::endl;
76 for (
double time = 1.0; time < 10.1; time = time + 1.0)
82 op.addPlanner(std::make_shared<geometric::RRTConnect>(setup.getSpaceInformation()));
89 if (op.solve(time, 30, 1) && setup.haveExactSolutionPath())
92 length = setup.getSolutionPath().length();
97 res <<
"time = " <<
duration <<
"s \t length = " << length << std::endl;
100 res <<
"RRTConnect with path hybridization (four threads)" << std::endl;
101 for (
double time = 1.0; time < 10.1; time = time + 1.0)
107 op.addPlanner(std::make_shared<geometric::RRTConnect>(setup.getSpaceInformation()));
108 op.addPlanner(std::make_shared<geometric::RRTConnect>(setup.getSpaceInformation()));
109 op.addPlanner(std::make_shared<geometric::RRTConnect>(setup.getSpaceInformation()));
110 op.addPlanner(std::make_shared<geometric::RRTConnect>(setup.getSpaceInformation()));
112 double length = -1.0;
117 if (op.solve(time, 30, 4) && setup.haveExactSolutionPath())
120 length = setup.getSolutionPath().length();
125 res <<
"time = " <<
duration <<
"s \t length = " << length << std::endl;
128 std::cout << res.str();