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

Allow passing object sampling tsr to place function #98

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions src/herbpy/action/grasping.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,15 @@ def Lift(robot, obj, distance=0.05, manip=None, render=True, **kw_args):
**kw_args)

@ActionMethod
def Place(robot, obj, on_obj, manip=None, render=True, **kw_args):
def Place(robot, obj, on_obj, obj_top_tsr = None, manip=None, render=True, **kw_args):
"""
Place an object onto another object
This assumes the 'point_on' tsr is defined for the on_obj and
the 'place' tsr is defined for obj
@param robot The robot performing the push grasp
@param obj The object to place
@param on_obj The object to place obj on
@param obj_top_tsr TSR describes that can sample the poses
Copy link
Member

Choose a reason for hiding this comment

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

Fix grammar in this comment.

@param manip The manipulator to perform the grasp with
(if None active manipulator is used)
@param render Render tsr samples and push direction vectors during planning
Expand All @@ -207,17 +208,19 @@ def Place(robot, obj, on_obj, manip=None, render=True, **kw_args):
manip = robot.GetActiveManipulator()

with robot.GetEnv():
# Get a tsr to sample places to put the glass
obj_extents = obj.ComputeAABB().extents()
obj_radius = max(obj_extents[0], obj_extents[1])
obj_top_tsr = robot.tsrlibrary(on_obj, 'point_on', padding=obj_radius, manip=manip)

# Now use this to get a tsr for sampling ee_poses
place_tsr = robot.tsrlibrary(obj, 'place', pose_tsr_chain=obj_top_tsr[0], manip=manip)
if obj_top_tsr is None:
# Get a tsr to sample places to put the glass
obj_extents = obj.ComputeAABB().extents()
obj_radius = max(obj_extents[0], obj_extents[1])
obj_top_tsr = robot.tsrlibrary(on_obj, 'point_on', padding=obj_radius, manip=manip)
# Now use this to get a tsr for sampling ee_poses
place_tsr = robot.tsrlibrary(obj, 'place', pose_tsr_chain=obj_top_tsr[0], manip=manip)
else:
place_tsr = robot.tsrlibrary(obj, 'place', pose_tsr_chain = obj_top_tsr, manip=manip)

# Plan to the grasp
with prpy.viz.RenderTSRList(place_tsr, robot.GetEnv(), render=render):
manip.PlanToTSR(place_tsr, execute=True)
manip.PlanToTSR(place_tsr, execute=True)

# Open the hand
manip.hand.OpenHand()
Expand Down
2 changes: 1 addition & 1 deletion src/herbpy/herbrobot.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def __init__(self, left_arm_sim, right_arm_sim, right_ft_sim,
TSRPlanner(delegate_planner=actual_planner),
self.cbirrt_planner),
# Special purpose meta-planner.
NamedPlanner(delegate_planner=actual_planner),
NamedPlanner(delegate_planner=Sequence(actual_planner, self.cbirrt_planner)),
Copy link
Member

Choose a reason for hiding this comment

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

What is the purpose of this change?

Copy link
Contributor

Choose a reason for hiding this comment

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

This allows calls to PlanToNamedConfiguration to use a randomized planner (in this case CBiRRT) when snap planner and optimizers have failed. We are seeing that when planning out of tight quarters near objects using CHOMP the resulting trajectory fails to get pushed out of collision. I think this change is important, especially if a user has only CHOMP installed and not trajopt, but we will pull it out and put it into a separate PR.

Copy link
Member

Choose a reason for hiding this comment

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

That is reasonable. I am fine with leaving it in this pull request.

)

from prpy.planning.retimer import HauserParabolicSmoother
Expand Down