13 #include <ompl/geometric/planners/rrt/RRT.h>
15 #include <omplapp/apps/SE3RigidBodyPlanning.h>
16 #include <omplapp/config.h>
17 #include <omplapp/geometry/detail/FCLContinuousMotionValidator.h>
24 std::string problem =
"Apartment";
25 std::string environment_mesh = std::string(OMPLAPP_RESOURCE_DIR) +
"/3D/" + problem +
"_env.dae";
26 std::string robot_mesh = std::string(OMPLAPP_RESOURCE_DIR) +
"/3D/" + problem +
"_robot.dae";
29 setup.setEnvironmentMesh(environment_mesh);
30 setup.setRobotMesh(robot_mesh);
34 bounds.low[0] = -73.76;
35 bounds.low[1] = -179.59;
36 bounds.low[2] = -0.03;
37 bounds.high[0] = 295.77;
38 bounds.high[1] = 168.26;
39 bounds.high[2] = 90.39;
46 start->rotation().setIdentity();
52 goal->rotation().setIdentity();
55 setup.setStartAndGoalStates(start, goal);
63 std::string problem =
"Easy";
64 std::string environment_mesh = std::string(OMPLAPP_RESOURCE_DIR) +
"/3D/" + problem +
"_env.dae";
65 std::string robot_mesh = std::string(OMPLAPP_RESOURCE_DIR) +
"/3D/" + problem +
"_robot.dae";
68 setup.setEnvironmentMesh(environment_mesh);
69 setup.setRobotMesh(robot_mesh);
73 bounds.low[0] = 14.46;
74 bounds.low[1] = -24.25;
75 bounds.low[2] = -504.86;
76 bounds.high[0] = 457.96;
77 bounds.high[1] = 321.25;
78 bounds.high[2] = -72.86;
85 start->rotation().setIdentity();
91 goal->rotation().setIdentity();
94 setup.setStartAndGoalStates(start, goal);
102 std::string problem =
"cubicles";
103 std::string environment_mesh = std::string(OMPLAPP_RESOURCE_DIR) +
"/3D/" + problem +
"_env.dae";
104 std::string robot_mesh = std::string(OMPLAPP_RESOURCE_DIR) +
"/3D/" + problem +
"_robot.dae";
107 setup.setEnvironmentMesh(environment_mesh);
108 setup.setRobotMesh(robot_mesh);
112 bounds.low[0] = -508.88;
113 bounds.low[1] = -230.13;
114 bounds.low[2] = -123.75;
115 bounds.high[0] = 319.62;
116 bounds.high[1] = 531.87;
117 bounds.high[2] = 101.00;
124 start->rotation().setIdentity();
130 goal->rotation().setIdentity();
133 setup.setStartAndGoalStates(start, goal);
136 setup.getSpaceInformation()->getStateSpace()->as<
base::SE3StateSpace>()->setBounds(bounds);
139 void test(
unsigned int tries, std::vector<std::vector<double>> ×, std::vector<int> &attempts,
bool fcl =
false,
140 bool continuous =
false)
142 std::cout <<
"Evaluating " << (continuous ?
"continuous" :
"discrete") <<
" " << (fcl ?
"FCL" :
"PQP") <<
" checker"
145 std::vector<double> time;
146 unsigned int successful = 0;
147 unsigned int problem = 0;
151 unsigned int nr_attempts = 0;
154 std::cout <<
"- Apartment problem " << std::flush;
155 else if (problem == 1)
156 std::cout <<
"- Cubicles problem " << std::flush;
157 else if (problem == 2)
158 std::cout << R
"(- 'Easy' problem )" << std::flush;
166 configureApartmentProblem(setup);
169 configureCubiclesProblem(setup);
172 configureEasyProblem(setup);
176 setup.setStateValidityCheckerType(fcl ? app::FCL : app::PQP);
182 setup.getSpaceInformation()->setMotionValidator(std::make_shared<app::FCLContinuousMotionValidator>(
183 setup.getSpaceInformation(), setup.getMotionModel()));
186 setup.getSpaceInformation()->setStateValidityCheckingResolution(0.01);
187 setup.setPlanner(std::make_shared<geometric::RRT>(setup.getSpaceInformation()));
190 while (successful < tries)
196 if (setup.haveExactSolutionPath() || continuous)
199 time.push_back(setup.getLastPlanComputationTime());
200 std::cout <<
'.' << std::flush;
203 std::cout <<
'x' << std::flush;
207 times.push_back(time);
211 attempts.push_back(nr_attempts);
212 std::cout << std::endl;
218 int main(
int argc,
char **argv)
221 unsigned int nr_tries;
224 nr_tries = atoi(argv[1]);
227 if (nr_tries == std::numeric_limits<unsigned int>::min() ||
228 nr_tries == std::numeric_limits<unsigned int>::max())
236 std::vector<std::vector<double>> pqp_times;
237 std::vector<std::vector<double>> dfcl_times;
238 std::vector<std::vector<double>> cfcl_times;
239 std::vector<int> pqp_attempts;
240 std::vector<int> dfcl_attempts;
241 std::vector<int> cfcl_attempts;
243 std::cout <<
"Comparing collision checkers:" << std::endl;
244 std::cout <<
"Each problem is executed until " << nr_tries <<
" attempts are successful (30 sec limit)"
248 test(nr_tries, pqp_times, pqp_attempts);
251 test(nr_tries, dfcl_times, dfcl_attempts,
true);
254 test(nr_tries, cfcl_times, cfcl_attempts,
true,
true);
256 std::cout << std::endl <<
"Analysis:" << std::endl;
259 for (
size_t i = 0; i < pqp_times.size(); ++i)
262 auto pqp_time = pqp_times[i].begin() + pqp_times[i].size() / 2u;
263 auto dfcl_time = dfcl_times[i].begin() + dfcl_times[i].size() / 2u;
264 auto cfcl_time = cfcl_times[i].begin() + cfcl_times[i].size() / 2u;
266 std::nth_element(pqp_times[i].begin(), pqp_time, pqp_times[i].end());
267 std::nth_element(dfcl_times[i].begin(), dfcl_time, dfcl_times[i].end());
268 std::nth_element(cfcl_times[i].begin(), cfcl_time, cfcl_times[i].end());
270 std::cout << std::endl;
272 std::cout <<
" Apartment problem - Median Time (s)" << std::endl;
274 std::cout <<
" Cubicles problem - Median Time (s)" << std::endl;
276 std::cout << R
"( 'Easy' problem - Median Time (s))" << std::endl;
278 isOdd = pqp_times[i].size() % 2 == 1;
279 std::cout << " Discrete PQP: " << (isOdd ? *pqp_time : .5 * (*pqp_time + *(pqp_time + 1))) <<
" "
280 << nr_tries <<
"/" << pqp_attempts[i] <<
" planning attempts successful" << std::endl;
281 isOdd = dfcl_times[i].size() % 2 == 1;
282 std::cout <<
" Discrete FCL: " << (isOdd ? *dfcl_time : .5 * (*dfcl_time + *(dfcl_time + 1))) <<
" "
283 << nr_tries <<
"/" << dfcl_attempts[i] <<
" planning attempts successful" << std::endl;
284 isOdd = cfcl_times[i].size() % 2 == 1;
285 std::cout <<
" Continuous FCL: " << (isOdd ? *cfcl_time : .5 * (*cfcl_time + *(cfcl_time + 1))) <<
" "
286 << nr_tries <<
" total attempts" << std::endl;
291 int main(
int,
char **)
293 std::cerr <<
"ERROR: PQP collision checker is not installed" << std::endl;