-
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
Conversation
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.
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 RobotStateSaver
s 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) |
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:
- 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 LinkTransformation
s and a KinBodyStateSaver
for each mimic body that preserves its LinkTransformation
s. I don't see an option in RobotStateSaver
to 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) |
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.
This should be wrapped in a RobotStateSaver
that saves robot
's LinkTransformation
s.
|
||
# 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 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 LinkTransformation
s.
self.setup = True | ||
|
||
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 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 LinkTransformation
s.
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): |
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.
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) | |||
""" |
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.
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): |
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.
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') |
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.
You should wrap RetimeActiveTrajectory
in a RobotStateSaver
that preserves the robot's LinkTransformation
s, 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, '') |
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.
You should wrap RetimeActiveTrajectory
in a RobotStateSaver
that preserves the robot's LinkTransformation
s, since the retimer may modify the robot's active DOF values.
contextlib.nested(*mimicbody_savers): | ||
response = problem.SendCommand(args_str, True) | ||
|
||
robot.SetDOFLimits(upper, lower) |
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.
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 |
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.
The setup
flag is no longer used anywhere.
|
||
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 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))) |
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.
I believe RaveCreatePlanner
returns None
instead of raising an exception.
env = robot.GetEnv() | ||
|
||
try: | ||
planner = openravepy.RaveCreatePlanner(env, algorithm) |
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.
algorithm
is not defined - this should be self.algorithm
.
Your changes look good! I added a few minor comments above. In addition, We also need to give the same treatment to |
Thanks @gilwoolee! These changes look great. I expect that planning will be quite a bit faster with these changes in place. |
This PR changes
ClonedPlanningMethod
toLockedPlanningMethod
in SnapPlanner, GreedyIKPlanner, CBiRRT, IKPlanner, NamedPlanner, OMPLPlanner, OpenRavePlanner, VectorField, TSRPlanner.Now each
PlanTo..
method usesrobot.env()
instead ofself.env()
.robot.CreateRobotStateSaver(...)
has been added to necessary blocks.