13 #include "AnytimePathShorteningDemo.h"
15 #include <ompl/geometric/planners/AnytimePathShortening.h>
16 #include <ompl/tools/benchmark/Benchmark.h>
18 #include <omplapp/apps/SE2RigidBodyPlanning.h>
19 #include <omplapp/apps/SE3MultiRigidBodyPlanning.h>
20 #include <omplapp/apps/SE3RigidBodyPlanning.h>
21 #include <omplapp/config.h>
27 std::shared_ptr<geometric::SimpleSetup> allocProblem(
const ProblemType &probType)
36 return std::make_shared<app::SE2RigidBodyPlanning>();
38 return std::make_shared<app::SE3RigidBodyPlanning>();
40 return std::make_shared<app::SE3MultiRigidBodyPlanning>(2);
42 OMPL_ERROR(
"Unknown problem type in allocProblem");
47 void setStartAndGoalStates(
const ProblemType &probType, std::shared_ptr<geometric::SimpleSetup> &setup)
49 std::string robot_fname = std::string(OMPLAPP_RESOURCE_DIR);
50 std::string env_fname = std::string(OMPLAPP_RESOURCE_DIR);
56 robot_fname +=
"/2D/Barriers_easy_robot.dae";
57 env_fname +=
"/2D/Barriers_easy_env.dae";
69 goal->setYaw(3.14159);
72 setup->setStartAndGoalStates(start, goal);
78 robot_fname +=
"/3D/cubicles_robot.dae";
79 env_fname +=
"/3D/cubicles_env.dae";
86 start->rotation().setIdentity();
93 goal->rotation().setIdentity();
96 setup->setStartAndGoalStates(start, goal);
102 robot_fname +=
"/3D/Easy_robot.dae";
103 env_fname +=
"/3D/Easy_env.dae";
144 setup->setStartAndGoalStates(start, goal);
149 OMPL_ERROR(
"FATAL: Unknown problem type in setStartAndGoalStates");
157 void solve(
const ProblemType &probType,
const OptimizationType &optType,
const double &runtime,
158 const std::vector<PlannerType> &planners)
160 auto setup(allocProblem(probType));
162 setStartAndGoalStates(probType, setup);
165 setup->getSpaceInformation()->setStateValidityCheckingResolution(0.01);
167 base::PlannerPtr planner;
171 planner = std::make_shared<geometric::AnytimePathShortening>(setup->getSpaceInformation());
176 planner = std::make_shared<geometric::AnytimePathShortening>(setup->getSpaceInformation());
181 planner = std::make_shared<geometric::AnytimePathShortening>(setup->getSpaceInformation());
185 planner = allocPlanner(planners[0], setup->getSpaceInformation());
196 for (
auto i : planners)
198 base::PlannerPtr subPlanner = allocPlanner(i, setup->getSpaceInformation());
202 std::cout <<
"Planner suite: " << std::endl;
203 for (
size_t i = 0; i < planners.size(); ++i)
209 std::cout <<
"Planner suite: " << std::endl;
210 std::cout <<
"1: " << planner->getName() << std::endl;
219 if (probType == BARRIERS)
220 benchmark.setExperimentName(
"Barriers*");
221 else if (probType == CUBICLES)
222 benchmark.setExperimentName(
"Cubicles*");
224 benchmark.setExperimentName(
"EasySwap*");
225 benchmark.addPlanner(planner);
226 benchmark.benchmark(request);
227 benchmark.saveResultsToFile();
230 int main(
int argc,
char **argv)
242 std::cout <<
"Usage:" << std::endl;
243 std::cout <<
"demo_AnytimePathShortening ([barriers|cubicles|easy] [shortcut|hybridize|alternate|none] "
244 "[runtime(seconds)] [planner1] (planner2)...)|(input file)"
250 ProblemType probType;
251 OptimizationType optType;
253 std::vector<PlannerType> planners;
254 parseArguments(argc, argv, probType, optType, runtime, planners);
255 if (!validArguments(probType, optType, runtime, planners))
258 solve(probType, optType, runtime, planners);