Generic Instructions for Setting Up a Planning Context

Instantiating a state space

The first step for setting up a planning problem is selecting the space we are planning in. Simply create an instance of a class that inherits from ompl::base::StateSpace, or select one from the available implementations. To change the definition of the employed sampler or distance function, it is possible to provide a further specialization of such a state space. See [Implementing State Spaces]{implementingStateSpaces.html}.

base::StateSpacePtr space(new base::SE2StateSpace());
// set bounds ....

Instantiating a control space

If planning with differential constraints, a representation of the space of controls is needed as well. Simply create an instance of a class that inherits from ompl::control::ControlSpace. Usually, ompl::control::RealVectorControlSpace is sufficient. An implementation needs to be specified for the ompl::control:ControlSpace::propagate() either by inheriting from the control space class or by calling ompl::control::ControlSpace::setPropagationFunction().

base::StateSpacePtr space(new base::SE2StateSpace());
// set bounds for state space
control::ControlSpacePtr cspace(new control::RealVectorControlSpace(space));
// set bounds for cspace

Instantiating a space information class

Creating an actual instance of a space information class (ompl::base::SpaceInformation) is trivial as the constructor requires only a state space to be specified (ompl::base::StateSpace). When planning with controls (ompl::control::SpaceInformation), this constructor requires a control space (ompl::control::ControlSpace) as well. The space information class also needs to be configured before use:

Instantiating a problem definition

Instantiating a planner

In order to use a motion planner (ompl::geometric::XXX, from ompl/geometric/planners or ompl::control::XXX, from ompl/control/planners), an instance of ompl::base::SpaceInformation (ompl::control::SpaceInformation, respectively) must be available. This instance is supplied to the planner's constructor. After creation, a call to the planner's ompl::base::Planner::setup() method must be made and the planner instance is ready for use. The problem to be solved is set with ompl::base::Planner::setProblemDefinition(). The ompl::base::Planner::solve() method can be called repeatedly with different allowed time durations until a solution is found. The planning process continues with the available data structures when sequential calls to ompl::base::Planner::solve() are made. A call to ompl::base::Planner::clear() will restore a planner to its state before any calls to the ompl::base::Planner::solve() method were made.

using namespace ompl;
// set start states & goal region for the problem definition
if (pdef->getGoal()->getSolutionPath())
// do something with the solution

Using SimpleSetup

The instantiation of all the above classes is facilitated by the ompl::geometric::SimpleSetup class (ompl::control::SimpleSetup, respectively). Please see the documentation of these classes for more information. Making use of their functionality is recommended, if appropriate.