Skip to content
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

Merged
merged 7 commits into from
Nov 2, 2016

Conversation

gilwoolee
Copy link
Contributor

This PR changes ClonedPlanningMethod to LockedPlanningMethod in SnapPlanner, GreedyIKPlanner, CBiRRT, IKPlanner, NamedPlanner, OMPLPlanner, OpenRavePlanner, VectorField, TSRPlanner.

Now each PlanTo.. method uses robot.env() instead of self.env(). robot.CreateRobotStateSaver(...) has been added to necessary blocks.

@gilwoolee gilwoolee assigned gilwoolee and mkoval and unassigned gilwoolee Sep 30, 2016
Copy link
Member

@mkoval mkoval left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a fantastic change! We saw that cloning the Environment in@ClonedPlanningMethod took a significant fraction of the total planning time in our ISER results, so switching to @LocedPlanningMethod should have significant performance benefits. Thank you @gilwoolee for taking the time to make this important, but unfortunately tedious, set of changes.

I would like to remove the RobotStateSaver from @LockedPlanningMethod because it provides a false sense of security: some planners (like CBiRRT) alter more than the robot's active DOFs. Once we remove that, we'll have to add a few extra RobotStateSavers to the individual planners.

I think I caught them all in my comments, but it would be great if someone could do another pass.

@@ -266,7 +266,7 @@ def Plan(self, robot, smoothingitrs=None, timelimit=None, allowlimadj=0,
collision_checker = self.robot_checker_factory(robot)
options = collision_checker.collision_options
with CollisionOptionsStateSaver(env.GetCollisionChecker(), options):
response = self.problem.SendCommand(args_str, True)
response = problem.SendCommand(args_str, True)
Copy link
Member

@mkoval mkoval Sep 30, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CBiRRT seems to modify:

  • the robot's active DOF values
  • the robot's DOF limits
  • the robot's transformation
  • the DOF values of any mimic bodies specified in a TSRChain.

This should be wrapped in a RobotStateSaver that preserves the robot's LinkTransformations and a KinBodyStateSaver for each mimic body that preserves its LinkTransformations. I don't see an option in RobotStateSaverto restore DOF position limits, so we will need to do that ourselves.

self.planner.InitPlan(robot, params)
status = self.planner.PlanPath(output_path, releasegil=True)
planner.InitPlan(robot, params)
status = planner.PlanPath(output_path, releasegil=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be wrapped in a RobotStateSaver that saves robot's LinkTransformations.


# 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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be wrapped in a RobotStateSaver that saves robot's LinkTransformations.

self.setup = True

status = self.planner.PlanPath(traj, releasegil=True)
status = planner.PlanPath(traj, releasegil=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be wrapped in a RobotStateSaver that saves robot's LinkTransformations.

with self.robot_checker_factory(robot) as robot_checker:
with self.robot_checker_factory(robot) as robot_checker, \
robot.CreateRobotStateSaver(Robot.SaveParameters.ActiveDOF |
Robot.SaveParameters.LinkTransformation):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need ActiveDOF here, since we're not changing robot's active DOF indices.

@@ -85,7 +86,7 @@ def PlanToIK(self, robot, goal_pose, **kw_args):
return self.PlanToTSR(robot, [tsr_chain], **kw_args)
"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not related to the pull request, but we really should delete this dead code.

with self.robot_checker_factory(robot) as robot_checker:
with self.robot_checker_factory(robot) as robot_checker, \
robot.CreateRobotStateSaver(Robot.SaveParameters.ActiveDOF |
Robot.SaveParameters.LinkTransformation):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need ActiveDOF here, since we do not alter the robot's active DOF indices.

manip = robot.GetActiveManipulator()
start_pose = manip.GetEndEffectorTransform()
traj = openravepy.RaveCreateTrajectory(self.env, '')
traj = openravepy.RaveCreateTrajectory(env, '')
spec = openravepy.IkParameterization.\
GetConfigurationSpecificationFromType(
openravepy.IkParameterizationType.Transform6D, 'linear')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should wrap RetimeActiveTrajectory in a RobotStateSaver that preserves the robot's LinkTransformations, since the retimer may modify the robot's active DOF values.

@@ -121,7 +124,7 @@ def PlanToEndEffectorOffset(self, robot, direction, distance,
with robot:
manip = robot.GetActiveManipulator()
start_pose = manip.GetEndEffectorTransform()
traj = openravepy.RaveCreateTrajectory(self.env, '')
traj = openravepy.RaveCreateTrajectory(env, '')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should wrap RetimeActiveTrajectory in a RobotStateSaver that preserves the robot's LinkTransformations, since the retimer may modify the robot's active DOF values.

@mkoval mkoval changed the title Swtiched from ClonedPlanningMethod To LockedPlanningMethod Switched from ClonedPlanningMethod To LockedPlanningMethod Oct 1, 2016
contextlib.nested(*mimicbody_savers):
response = problem.SendCommand(args_str, True)

robot.SetDOFLimits(upper, lower)
Copy link
Member

@mkoval mkoval Oct 11, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put this in a finally block so it will run even if something raises an exception. Or, even better, write a simple context manager that takes advantage of this. The contextlib.contextmanager decorator could be useful here.

It would also be helpful to add a comment that CBiRRT adjusts the joint limits to include the robot's start configuration if allowlimadj is set.

self.planner.InitPlan(robot, params)
self.setup = True
planner.InitPlan(robot, params)
setup = True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The setup flag is no longer used anywhere.


if planner is None:
raise UnsupportedPlanningError(
'Unable to create OMPL_Simplifier planner.')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Modify this message use planner_name so this message can't get out of sync with the code.

planner = openravepy.RaveCreatePlanner(env, algorithm)
except openravepy.openrave_exception:
raise UnsupportedPlanningError('Unable to create {:s} module.'
.format(str(self)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe RaveCreatePlanner returns None instead of raising an exception.

env = robot.GetEnv()

try:
planner = openravepy.RaveCreatePlanner(env, algorithm)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

algorithm is not defined - this should be self.algorithm.

@mkoval
Copy link
Member

mkoval commented Oct 11, 2016

Your changes look good! I added a few minor comments above. In addition, SnapPlanner.PlanToConfiguration still needs to be changed to a @LockedPlanningMethod.

We also need to give the same treatment to prpy.planning.retimer. This is where PrPy bindings for HauserParabolicSmoother live, so it's actually a pretty important file to change.

@mkoval
Copy link
Member

mkoval commented Nov 2, 2016

Thanks @gilwoolee! These changes look great. I expect that planning will be quite a bit faster with these changes in place.

@mkoval mkoval merged commit 630f31c into master Nov 2, 2016
@mkoval mkoval deleted the feature/remove_cloning branch November 2, 2016 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants