Skip to content

tesseract_robotics.tesseract_motion_planners_ompl

OMPL (Open Motion Planning Library) planner bindings.

Overview

OMPL provides sampling-based planners for complex environments where optimization-based planners may get stuck in local minima.

Python
from tesseract_robotics.tesseract_motion_planners_ompl import (
    OMPLMotionPlanner,
    OMPLPlanProfile, OMPLRealVectorPlanProfile,
    RRTConnectConfigurator, RRTstarConfigurator, SBLConfigurator,
    ProfileDictionary_addOMPLProfile,
)

OMPLMotionPlanner

The OMPL motion planner. It derives from MotionPlanner (tesseract_motion_planners), so it is accepted wherever a MotionPlanner is.

Python
from tesseract_robotics.tesseract_motion_planners_ompl import OMPLMotionPlanner
from tesseract_robotics.tesseract_motion_planners import PlannerRequest

planner = OMPLMotionPlanner()

request = PlannerRequest()
request.env = env
request.instructions = program
request.profiles = profiles

response = planner.solve(request)

Profiles

OMPLRealVectorPlanProfile

Configure OMPL planning behavior. The profile has three sub-configs: solver_config, collision_check_config, and contact_manager_config.

Python
from tesseract_robotics.tesseract_motion_planners_ompl import (
    OMPLRealVectorPlanProfile, RRTConnectConfigurator,
)

profile = OMPLRealVectorPlanProfile()

# Solver settings
profile.solver_config.planning_time = 5.0   # seconds
profile.solver_config.simplify = True       # simplify path after planning
profile.solver_config.optimize = True       # run path optimization

# Add planner configurator(s)
profile.solver_config.addPlanner(RRTConnectConfigurator())

# State-validation resolution (for collision checking)
profile.collision_check_config.longest_valid_segment_length = 0.01
Attribute Config Description
solver_config.planning_time solver Max planning time (seconds)
solver_config.simplify solver Simplify path after planning
solver_config.optimize solver Run path optimization
solver_config.max_solutions solver Cap on returned paths
collision_check_config.longest_valid_segment_length collision State-validation resolution
collision_check_config.type collision CollisionEvaluatorType (discrete vs continuous)

Planner Configurators

Each OMPLPlannerType has a configurator class, <type>Configurator. Each one default-constructs with OMPL's defaults; getType() returns its OMPLPlannerType. A range of 0 lets OMPL pick the step size.

OMPLPlannerType Configurator Fields
SBL SBLConfigurator range
EST ESTConfigurator range, goal_bias
LBKPIECE1 LBKPIECE1Configurator range, border_fraction, min_valid_path_fraction
BKPIECE1 BKPIECE1Configurator range, border_fraction, failed_expansion_score_factor, min_valid_path_fraction
KPIECE1 KPIECE1Configurator range, goal_bias, border_fraction, failed_expansion_score_factor, min_valid_path_fraction
BiTRRT BiTRRTConfigurator range, temp_change_factor, cost_threshold, init_temperature, frontier_threshold, frontier_node_ratio
RRT RRTConfigurator range, goal_bias
RRTConnect RRTConnectConfigurator range
RRTstar RRTstarConfigurator range, goal_bias, delay_collision_checking
TRRT TRRTConfigurator range, goal_bias, temp_change_factor, init_temperature, frontier_threshold, frontier_node_ratio
PRM PRMConfigurator max_nearest_neighbors
PRMstar PRMstarConfigurator none
LazyPRMstar LazyPRMstarConfigurator none
SPARS SPARSConfigurator max_failures, dense_delta_fraction, sparse_delta_fraction, stretch_factor

RRTConnect is the default and usually the fastest. The PRM family and the asymptotically optimal planners (RRTstar, PRMstar) use the whole planning_time.

Python
from tesseract_robotics.tesseract_motion_planners_ompl import (
    PRMstarConfigurator, RRTstarConfigurator,
)

config = RRTstarConfigurator()
config.goal_bias = 0.1

profile.solver_config.planners = [config, PRMstarConfigurator()]

planning.profiles.create_ompl_planner_configurators builds them by type name and sets shared fields on the configurators that have them:

Python
from tesseract_robotics.planning.profiles import create_ompl_planner_configurators

profile.solver_config.planners = create_ompl_planner_configurators(
    planners=["RRTConnect", "KPIECE1"], num_planners=2, range=0.1
)

create (which builds the OMPL planner from an ompl::base::SpaceInformation) is not bound: it takes and returns OMPL types.

OMPLSolverConfig.planners

solver_config.planners is the list of configurators, one parallel planner each. The default profile holds two RRTConnectConfigurator. The list is copied on access; its configurators are shared with the config. cfg.planners.append(x) changes the copy, not cfg, but cfg.planners[0].range = 0.5 changes the configurator cfg holds. Assign a new list, or use addPlanner / clearPlanners, which change it in place. len(cfg.planners) replaces the removed getNumPlanners().

Python
cfg = profile.solver_config
cfg.planners = [RRTConnectConfigurator()]  # replace
cfg.addPlanner(SBLConfigurator())          # append in place
assert len(cfg.planners) == 2

OMPLSolverConfig and OMPLRealVectorMoveProfile compare by value and are unhashable. Upstream compares planners by count only, so two configs that hold different configurator types of the same number compare equal. profile.createSolverConfig() returns the solver config the planner uses for that profile (a copy of solver_config).

Adding Profiles

Python
from tesseract_robotics.tesseract_command_language import ProfileDictionary
from tesseract_robotics.tesseract_motion_planners_ompl import (
    OMPLRealVectorPlanProfile, ProfileDictionary_addOMPLProfile,
    RRTConnectConfigurator
)

# Create profile
profile = OMPLRealVectorPlanProfile()
profile.solver_config.planning_time = 10.0
profile.solver_config.addPlanner(RRTConnectConfigurator())

# Add to dictionary (dict, namespace, profile_name, profile)
profiles = ProfileDictionary()
ProfileDictionary_addOMPLProfile(profiles, "OMPLMotionPlannerTask", "DEFAULT", profile)

# Use with planner request
request.profiles = profiles

ProfileDictionary.hasProfile / getProfile take a profile key. OMPLMoveProfile.createKey(), inherited by every OMPL move profile, returns it without building a profile:

Python
assert profiles.hasProfile(
    OMPLRealVectorPlanProfile.createKey(), "OMPLMotionPlannerTask", "DEFAULT"
)

Complete Example

Python
from tesseract_robotics.tesseract_motion_planners_ompl import (
    OMPLMotionPlanner, OMPLRealVectorPlanProfile,
    RRTConnectConfigurator, ProfileDictionary_addOMPLProfile
)
from tesseract_robotics.tesseract_motion_planners import PlannerRequest
from tesseract_robotics.tesseract_command_language import ProfileDictionary

# Configure OMPL profile
profile = OMPLRealVectorPlanProfile()
profile.solver_config.planning_time = 5.0
profile.solver_config.simplify = True
profile.solver_config.addPlanner(RRTConnectConfigurator())

profiles = ProfileDictionary()
ProfileDictionary_addOMPLProfile(profiles, "OMPLMotionPlannerTask", "DEFAULT", profile)

# Create request
request = PlannerRequest()
request.env = env
request.instructions = program
request.profiles = profiles

# Solve
planner = OMPLMotionPlanner()
response = planner.solve(request)

if response.successful:
    trajectory = response.results
    print(f"Found path with {len(trajectory)} waypoints")
else:
    print(f"Planning failed: {response.message}")

Tips

  1. RRTConnect is usually the best starting point - fast and reliable
  2. Increase planning_time for complex environments
  3. Use simplify=True to reduce waypoints
  4. Lower collision resolution (longest_valid_segment_length) for narrow passages
  5. OMPL finds paths, not smooth trajectories - use TrajOpt for smoothing

Auto-generated API Reference

tesseract_motion_planners_ompl Python bindings

OMPLPlanProfile module-attribute

Python
OMPLPlanProfile: TypeAlias = OMPLMoveProfile

OMPLRealVectorPlanProfile module-attribute

Python
OMPLRealVectorPlanProfile: TypeAlias = OMPLRealVectorMoveProfile

OMPLSolverConfig

planning_time property writable

Python
planning_time: float

Max planning time allowed in seconds (default: 5.0)

max_solutions property writable

Python
max_solutions: int

Max number of solutions to find before exiting (default: 10)

simplify property writable

Python
simplify: bool

Simplify trajectory (default: false). Ignores n_output_states if true.

optimize property writable

Python
optimize: bool

Use all planning time to optimize trajectory (default: true)

__hash__ class-attribute instance-attribute

Python
__hash__: None = None

planners property writable

Python
planners: list[OMPLPlannerConfigurator]

Planner configurators, one parallel planner each. The list is copied on access; its configurators are shared with the config, so editing one edits the config. Assign a new list (or use addPlanner/clearPlanners) to change which planners it holds.

__init__

Python
__init__() -> None

addPlanner

Python
addPlanner(planner: OMPLPlannerConfigurator) -> None

Add a planner configurator (each runs in parallel)

clearPlanners

Python
clearPlanners() -> None

Clear all planners

__eq__

Python
__eq__(arg: OMPLSolverConfig) -> bool

__ne__

Python
__ne__(arg: OMPLSolverConfig) -> bool

OMPLPlannerType

Bases: Enum

SBL class-attribute instance-attribute

Python
SBL = 0

EST class-attribute instance-attribute

Python
EST = 1

LBKPIECE1 class-attribute instance-attribute

Python
LBKPIECE1 = 2

BKPIECE1 class-attribute instance-attribute

Python
BKPIECE1 = 3

KPIECE1 class-attribute instance-attribute

Python
KPIECE1 = 4

BiTRRT class-attribute instance-attribute

Python
BiTRRT = 5

RRT class-attribute instance-attribute

Python
RRT = 6

RRTConnect class-attribute instance-attribute

Python
RRTConnect = 7

RRTstar class-attribute instance-attribute

Python
RRTstar = 8

TRRT class-attribute instance-attribute

Python
TRRT = 9

PRM class-attribute instance-attribute

Python
PRM = 10

PRMstar class-attribute instance-attribute

Python
PRMstar = 11

LazyPRMstar class-attribute instance-attribute

Python
LazyPRMstar = 12

SPARS class-attribute instance-attribute

Python
SPARS = 13

OMPLPlannerConfigurator

getType

Python
getType() -> OMPLPlannerType

SBLConfigurator

Bases: OMPLPlannerConfigurator

range property writable

Python
range: float

__init__

Python
__init__() -> None

ESTConfigurator

Bases: OMPLPlannerConfigurator

range property writable

Python
range: float

goal_bias property writable

Python
goal_bias: float

__init__

Python
__init__() -> None

LBKPIECE1Configurator

Bases: OMPLPlannerConfigurator

range property writable

Python
range: float

border_fraction property writable

Python
border_fraction: float

min_valid_path_fraction property writable

Python
min_valid_path_fraction: float

__init__

Python
__init__() -> None

BKPIECE1Configurator

Bases: OMPLPlannerConfigurator

range property writable

Python
range: float

border_fraction property writable

Python
border_fraction: float

failed_expansion_score_factor property writable

Python
failed_expansion_score_factor: float

min_valid_path_fraction property writable

Python
min_valid_path_fraction: float

__init__

Python
__init__() -> None

KPIECE1Configurator

Bases: OMPLPlannerConfigurator

range property writable

Python
range: float

goal_bias property writable

Python
goal_bias: float

border_fraction property writable

Python
border_fraction: float

failed_expansion_score_factor property writable

Python
failed_expansion_score_factor: float

min_valid_path_fraction property writable

Python
min_valid_path_fraction: float

__init__

Python
__init__() -> None

BiTRRTConfigurator

Bases: OMPLPlannerConfigurator

range property writable

Python
range: float

temp_change_factor property writable

Python
temp_change_factor: float

cost_threshold property writable

Python
cost_threshold: float

init_temperature property writable

Python
init_temperature: float

frontier_threshold property writable

Python
frontier_threshold: float

frontier_node_ratio property writable

Python
frontier_node_ratio: float

__init__

Python
__init__() -> None

RRTConfigurator

Bases: OMPLPlannerConfigurator

range property writable

Python
range: float

goal_bias property writable

Python
goal_bias: float

__init__

Python
__init__() -> None

RRTConnectConfigurator

Bases: OMPLPlannerConfigurator

range property writable

Python
range: float

__init__

Python
__init__() -> None

RRTstarConfigurator

Bases: OMPLPlannerConfigurator

range property writable

Python
range: float

goal_bias property writable

Python
goal_bias: float

delay_collision_checking property writable

Python
delay_collision_checking: bool

__init__

Python
__init__() -> None

TRRTConfigurator

Bases: OMPLPlannerConfigurator

range property writable

Python
range: float

goal_bias property writable

Python
goal_bias: float

temp_change_factor property writable

Python
temp_change_factor: float

init_temperature property writable

Python
init_temperature: float

frontier_threshold property writable

Python
frontier_threshold: float

frontier_node_ratio property writable

Python
frontier_node_ratio: float

__init__

Python
__init__() -> None

PRMConfigurator

Bases: OMPLPlannerConfigurator

max_nearest_neighbors property writable

Python
max_nearest_neighbors: int

__init__

Python
__init__() -> None

PRMstarConfigurator

Bases: OMPLPlannerConfigurator

__init__

Python
__init__() -> None

LazyPRMstarConfigurator

Bases: OMPLPlannerConfigurator

__init__

Python
__init__() -> None

SPARSConfigurator

Bases: OMPLPlannerConfigurator

max_failures property writable

Python
max_failures: int

dense_delta_fraction property writable

Python
dense_delta_fraction: float

sparse_delta_fraction property writable

Python
sparse_delta_fraction: float

stretch_factor property writable

Python
stretch_factor: float

__init__

Python
__init__() -> None

OMPLMoveProfile

Bases: Profile

getKey

Python
getKey() -> int

createKey staticmethod

Python
createKey() -> int

createSolverConfig

Python
createSolverConfig() -> OMPLSolverConfig

The solver config the planner uses for this profile

OMPLRealVectorMoveProfile

Bases: OMPLMoveProfile

solver_config property writable

Python
solver_config: OMPLSolverConfig

The OMPL parallel planner solver config

contact_manager_config property writable

Python
contact_manager_config: ContactManagerConfig

The contact manager configuration (collision margins)

collision_check_config property writable

Python
collision_check_config: CollisionCheckConfig

The collision check configuration

__hash__ class-attribute instance-attribute

Python
__hash__: None = None

__init__

Python
__init__() -> None

__eq__

Python
__eq__(arg: OMPLRealVectorMoveProfile) -> bool

__ne__

Python
__ne__(arg: OMPLRealVectorMoveProfile) -> bool

from_yaml staticmethod

Python
from_yaml(config: str) -> OMPLRealVectorMoveProfile

Construct the profile from its YAML config text; malformed YAML raises ValueError.

Nested sub-configs are replaced, not merged: a key naming one rebuilds it from that struct's own defaults, so fields left out lose the profile's values. This is per struct; here solver_config: starts with no planners (OMPLSolverConfig() holds none).

OMPLMotionPlanner

Bases: MotionPlanner

__init__

Python
__init__(name: str) -> None

OMPLMoveProfile_as_ProfileConstPtr

Python
OMPLMoveProfile_as_ProfileConstPtr(profile: OMPLMoveProfile) -> tesseract_robotics.tesseract_command_language._tesseract_command_language.Profile

Convert OMPLMoveProfile to Profile::ConstPtr for use with ProfileDictionary.addProfile

OMPLPlanProfile_as_ProfileConstPtr

Python
OMPLPlanProfile_as_ProfileConstPtr(profile: OMPLMoveProfile) -> tesseract_robotics.tesseract_command_language._tesseract_command_language.Profile

Convert OMPLPlanProfile to Profile::ConstPtr (legacy alias)

ProfileDictionary_addOMPLMoveProfile

Python
ProfileDictionary_addOMPLMoveProfile(dict: ProfileDictionary, ns: str, profile_name: str, profile: OMPLMoveProfile) -> None

Add OMPL move profile to ProfileDictionary

ProfileDictionary_addOMPLProfile

Python
ProfileDictionary_addOMPLProfile(dict: ProfileDictionary, ns: str, profile_name: str, profile: OMPLMoveProfile) -> None

Add OMPL plan profile to ProfileDictionary (legacy alias)

RNG_setSeed

Python
RNG_setSeed(seed: int) -> None

Seed OMPL's global RNG seed generator for reproducible planning.

Samplers created after this call draw deterministic seeds, so repeated solve() calls produce identical paths. Re-seeding after planning has started logs an OMPL error (harmless: only pre-existing RNG instances stay nondeterministic). A seed of 0 is rejected once generation has started.

RNG_getSeed

Python
RNG_getSeed() -> int

Get the first seed used by OMPL's RNG seed generator.

Log this value to make a stochastic planning failure reproducible by passing it to RNG_setSeed in a subsequent run.