forward
inverse
Grid-based: A*, Dijkstra's
Tree-based: RRT and its variants
Graph-based: PRM and its variants

from ompl import base as ob
from ompl import geometric as og
def isStateValid(state):
# Some arbitrary condition on the state
return state.getX() < 0.6
def plan():
# create an SE2 state space
space = ob.SE2StateSpace()
# set lower and upper bounds
bounds = ob.RealVectorBounds(2)
bounds.setLow(-1)
bounds.setHigh(1)
space.setBounds(bounds)
# construct an instance of space information from this state space
si = ob.SpaceInformation(space)
# set state validity checking for this space
si.setStateValidityChecker(ob.StateValidityCheckerFn(isStateValid))
# create a random start state
start = ob.State(space)
start.random()
# create a random goal state
goal = ob.State(space)
goal.random()
# create a problem instance
pdef = ob.ProblemDefinition(si)
# set the start and goal states
pdef.setStartAndGoalStates(start, goal)
# create a planner for the defined space
planner = og.RRTConnect(si)
# set the problem we are trying to solve for the planner
planner.setProblemDefinition(pdef)
# perform setup steps for the planner
planner.setup()
# attempt to solve the problem within one second of planning time
solved = planner.solve(1.0)
if solved:
# get the goal representation from the problem definition (not the same as the goal state)
# and inquire about the found path
path = pdef.getSolutionPath()
print("Found solution:\\n%s" % path)
else:
print("No solution found")
if __name__ == "__main__":
plan()
Motion Planning Library: OMPL specializes in implementing sampling-based motion planners, such as RRT and PRM.
Abstract Framework: It focuses on planning within a mathematical space and does not include concepts of robots, such as kinematics, collision checking, or path execution.
Planning-Only Tool: OMPL is designed purely for motion planning and does not handle sensors, actuators, or executing planned paths.
Complementary Software: To apply OMPL in real-world robotics, additional software is required for tasks like kinematics and collision checking.
OMPL is a motion planning library focused on implementing randomized motion planners. Its planners are abstract, meaning OMPL itself has no concept of a robot. MoveIt! integrates seamlessly with OMPL, using it as the primary or default set of planners while also configuring OMPL to provide the necessary back-end support for robotics problems. Unlike OMPL, MoveIt! addresses kinematics, path planning, collision checking, 3D perception, and robot interaction, effectively serving as a “mission” control for robotic systems.

MoveIt!'s main interface is the move_group: