-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switched from ClonedPlanningMethod To LockedPlanningMethod #360
Changes from 1 commit
a806ab5
19a33ed
61aa833
7dafb8c
3c2c01b
f94e493
13680f6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ | |
PlannerStatus, | ||
RaveCreatePlanner, | ||
RaveCreateTrajectory, | ||
Robot | ||
) | ||
from ..collision import ( | ||
BakedRobotCollisionCheckerFactory, | ||
|
@@ -55,7 +56,7 @@ | |
) | ||
from .base import ( | ||
BasePlanner, | ||
ClonedPlanningMethod, | ||
LockedPlanningMethod, | ||
PlanningError, | ||
Tags, | ||
UnsupportedPlanningError, | ||
|
@@ -109,18 +110,10 @@ def __init__(self, algorithm='RRTConnect', robot_checker_factory=None, | |
'or_ompl only supports Simple and' | ||
' BakedRobotCollisionCheckerFactory.') | ||
|
||
planner_name = 'OMPL_{:s}'.format(algorithm) | ||
self.planner = RaveCreatePlanner(self.env, planner_name) | ||
|
||
if self.planner is None: | ||
raise UnsupportedPlanningError( | ||
'Unable to create "{:s}" planner. Is or_ompl installed?' | ||
.format(planner_name)) | ||
|
||
def __str__(self): | ||
return 'OMPL_{0:s}'.format(self.algorithm) | ||
|
||
@ClonedPlanningMethod | ||
@LockedPlanningMethod | ||
def PlanToConfiguration(self, robot, goal, **kw_args): | ||
""" | ||
Plan to a configuration using the robot's active DOFs. | ||
|
@@ -133,7 +126,7 @@ def PlanToConfiguration(self, robot, goal, **kw_args): | |
""" | ||
return self._Plan(robot, goal=goal, **kw_args) | ||
|
||
@ClonedPlanningMethod | ||
@LockedPlanningMethod | ||
def PlanToTSR(self, robot, tsrchains, **kw_args): | ||
""" | ||
Plan to one or more goal TSR chains using the robot's active DOFs. This | ||
|
@@ -166,6 +159,15 @@ def _Plan(self, robot, goal=None, tsrchains=None, timelimit=None, | |
|
||
extraParams += '<time_limit>{:f}</time_limit>'.format(timelimit) | ||
|
||
env = robot.GetEnv() | ||
planner_name = 'OMPL_{:s}'.format(self.algorithm) | ||
planner = RaveCreatePlanner(env, planner_name) | ||
|
||
if planner is None: | ||
raise UnsupportedPlanningError( | ||
'Unable to create "{:s}" planner. Is or_ompl installed?' | ||
.format(planner_name)) | ||
|
||
# Handle other parameters that get passed directly to OMPL. | ||
if ompl_args is None: | ||
ompl_args = dict() | ||
|
@@ -217,16 +219,16 @@ def _Plan(self, robot, goal=None, tsrchains=None, timelimit=None, | |
params.SetExtraParameters(extraParams) | ||
|
||
if (not continue_planner) or (not self.setup): | ||
self.planner.InitPlan(robot, params) | ||
self.setup = True | ||
planner.InitPlan(robot, params) | ||
setup = True | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
|
||
# Bypass the context manager since or_ompl does its own baking. | ||
env = robot.GetEnv() | ||
robot_checker = self.robot_checker_factory(robot) | ||
options = robot_checker.collision_options | ||
with CollisionOptionsStateSaver(env.GetCollisionChecker(), options): | ||
traj = RaveCreateTrajectory(env, 'GenericTrajectory') | ||
status = self.planner.PlanPath(traj, releasegil=True) | ||
status = planner.PlanPath(traj, releasegil=True) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be wrapped in a |
||
|
||
if status not in [PlannerStatus.HasSolution, | ||
PlannerStatus.InterruptedWithSolution]: | ||
|
@@ -327,7 +329,7 @@ def ComputeRange(self, robot): | |
# a small value to cope with numerical precision issues inside OMPL. | ||
return multiplier * conservative_resolution - epsilon | ||
|
||
@ClonedPlanningMethod | ||
@LockedPlanningMethod | ||
def PlanToConfiguration(self, robot, goal, ompl_args=None, **kw_args): | ||
if ompl_args is None: | ||
ompl_args = dict() | ||
|
@@ -336,7 +338,7 @@ def PlanToConfiguration(self, robot, goal, ompl_args=None, **kw_args): | |
|
||
return self._Plan(robot, goal=goal, ompl_args=ompl_args, **kw_args) | ||
|
||
@ClonedPlanningMethod | ||
@LockedPlanningMethod | ||
def PlanToTSR(self, robot, tsrchains, ompl_args=None, **kw_args): | ||
if ompl_args is None: | ||
ompl_args = dict() | ||
|
@@ -359,21 +361,23 @@ class OMPLSimplifier(BasePlanner): | |
def __init__(self): | ||
super(OMPLSimplifier, self).__init__() | ||
|
||
planner_name = 'OMPL_Simplifier' | ||
self.planner = openravepy.RaveCreatePlanner(self.env, planner_name) | ||
|
||
if self.planner is None: | ||
raise UnsupportedPlanningError( | ||
'Unable to create OMPL_Simplifier planner.') | ||
|
||
def __str__(self): | ||
return 'OMPL Simplifier' | ||
|
||
@ClonedPlanningMethod | ||
@LockedPlanningMethod | ||
def ShortcutPath(self, robot, path, timeout=1., **kwargs): | ||
# The planner operates in-place, so we need to copy the input path. We | ||
# also need to copy the trajectory into the planning environment. | ||
output_path = CopyTrajectory(path, env=self.env) | ||
|
||
planner_name = 'OMPL_Simplifier' | ||
env = robot.GetEnv() | ||
planner = openravepy.RaveCreatePlanner(env, planner_name) | ||
|
||
if planner is None: | ||
raise UnsupportedPlanningError( | ||
'Unable to create OMPL_Simplifier planner.') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Modify this message use |
||
|
||
output_path = CopyTrajectory(path, env=env) | ||
|
||
extraParams = '<time_limit>{:f}</time_limit>'.format(timeout) | ||
|
||
|
@@ -384,8 +388,8 @@ def ShortcutPath(self, robot, path, timeout=1., **kwargs): | |
# TODO: It would be nice to call planningutils.SmoothTrajectory here, | ||
# but we can't because it passes a NULL robot to InitPlan. This is an | ||
# issue that needs to be fixed in or_ompl. | ||
self.planner.InitPlan(robot, params) | ||
status = self.planner.PlanPath(output_path, releasegil=True) | ||
planner.InitPlan(robot, params) | ||
status = planner.PlanPath(output_path, releasegil=True) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be wrapped in a |
||
if status not in [PlannerStatus.HasSolution, | ||
PlannerStatus.InterruptedWithSolution]: | ||
raise PlanningError('Simplifier returned with status {0:s}.' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CBiRRT seems to modify:
TSRChain
.This should be wrapped in a
RobotStateSaver
that preserves therobot
'sLinkTransformation
s and aKinBodyStateSaver
for each mimic body that preserves itsLinkTransformation
s. I don't see an option inRobotStateSaver
to restore DOF position limits, so we will need to do that ourselves.