37#include <ompl/base/spaces/DubinsStateSpace.h>
38#include <ompl/base/spaces/ReedsSheppStateSpace.h>
39#include <ompl/geometric/planners/rrt/RRTstar.h>
40#include <ompl/geometric/planners/cforest/CForest.h>
41#include <ompl/base/objectives/PathLengthOptimizationObjective.h>
42#include <ompl/geometric/SimpleSetup.h>
43#include <ompl/tools/benchmark/Benchmark.h>
44#include <boost/program_options.hpp>
49namespace po = boost::program_options;
51bool isStateValid(
double radiusSquared,
const ob::State *state)
54 double x = s->getX(), y = s->getY();
55 x = std::abs(x - std::floor(x));
56 y = std::abs(y - std::floor(y));
57 x = std::min(x, 1. - x);
58 y = std::min(y, 1. - y);
59 return x * x + y * y > radiusSquared;
62int main(
int argc,
char **argv)
64 int distance, gridLimit, runCount;
65 double obstacleRadius, turningRadius, runtimeLimit;
67 auto space(std::make_shared<ob::SE2StateSpace>());
69 po::options_description desc(
"Options");
71 desc.add_options()(
"help",
"show help message")(
"dubins",
"use Dubins state space")(
72 "dubinssym",
"use symmetrized Dubins state space")(
"reedsshepp",
"use Reeds-Shepp state space")(
73 "distance", po::value<int>(&distance)->default_value(3),
"integer grid distance between start and goal")(
74 "obstacle-radius", po::value<double>(&obstacleRadius)->default_value(.25),
75 "radius of obstacles")(
"turning-radius", po::value<double>(&turningRadius)->default_value(.5),
76 "turning radius of robot (ignored for default point robot)")(
77 "grid-limit", po::value<int>(&gridLimit)->default_value(10),
"size of the grid")(
78 "runtime-limit", po::value<double>(&runtimeLimit)->default_value(2),
"time limit for every test")(
79 "run-count", po::value<int>(&runCount)->default_value(100),
"number of times to run each planner");
82 po::store(po::parse_command_line(argc, argv, desc), vm);
85 if (vm.count(
"help") != 0u)
87 std::cout << desc <<
"\n";
91 if (vm.count(
"dubins") != 0u)
92 space = std::make_shared<ob::DubinsStateSpace>(turningRadius);
93 if (vm.count(
"dubinssym") != 0u)
94 space = std::make_shared<ob::DubinsStateSpace>(turningRadius,
true);
95 if (vm.count(
"reedsshepp") != 0u)
96 space = std::make_shared<ob::ReedsSheppStateSpace>(turningRadius);
100 bounds.setLow(-.5 * gridLimit);
101 bounds.setHigh(.5 * gridLimit);
102 space->setBounds(bounds);
108 double radiusSquared = obstacleRadius * obstacleRadius;
109 ss.setStateValidityChecker([radiusSquared](
const ob::State *state) {
return isStateValid(radiusSquared, state); });
113 start->setXY(0., 0.5);
115 goal->setXY(0., (
double)distance + .5);
117 ss.setStartAndGoalStates(start, goal);
120 ss.getSpaceInformation()->setStateValidityCheckingResolution(0.05 / gridLimit);
121 ss.getProblemDefinition()->setOptimizationObjective(
122 std::make_shared<ompl::base::PathLengthOptimizationObjective>(ss.getSpaceInformation()));
125 double memoryLimit = 4096;
129 b.addPlanner(std::make_shared<og::RRTstar>(ss.getSpaceInformation()));
130 b.addPlanner(std::make_shared<og::CForest>(ss.getSpaceInformation()));
131 b.benchmark(request);
132 b.saveResultsToFile(
"circleGrid.log");
The lower and upper bounds for an Rn space.
A state in SE(2): (x, y, yaw).
Definition of a scoped state.
Definition of an abstract state.
const T * as() const
Cast this instance to a desired type.
Create the set of classes typically needed to solve a geometric problem.
This namespace contains sampling based planning routines shared by both planning under geometric cons...
This namespace contains code that is specific to planning under geometric constraints.