Skip to content

Commit 5f7b57b

Browse files
committed
improved grasp and place in simulation
1 parent 2c934dc commit 5f7b57b

File tree

4 files changed

+292
-156
lines changed

4 files changed

+292
-156
lines changed

instruct_to_policy/scripts/src/configs/base.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ env:
2323
manipulator_group_name: panda_manipulator
2424
debug: true
2525
planning_time: 15
26-
max_velocity: 0.2
27-
max_acceleration: 0.2
28-
goal_position_tolerance: 0.001
26+
max_velocity: 1.0
27+
max_acceleration: 1.0
28+
goal_position_tolerance: 0.01
2929
goal_orientation_tolerance: 0.02
30+
goal_joint_tolerance: 0.01
3031
refenrence_frame: world
3132
cartesian_path: true
3233
initial_joint_values: [0.0, -0.7854, 0.0, -2.3562, 0.0, 1.5708, 0.7854]

instruct_to_policy/scripts/src/env/env.py

Lines changed: 6 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from geometry_msgs.msg import Quaternion, Pose, Point
88
from grasp_detection.msg import Grasp
99
from src.grasp_detection.utils import select_grasp_by_preference
10-
from src.env.utils import calculate_place_position, is_collision, adjust_z
1110

1211
class Env:
1312
"""Wrapper for the environment grounding capabilities.
@@ -128,6 +127,12 @@ def parse_question(self, question, **kwargs):
128127
raise NotImplementedError("parse_question() not implemented")
129128

130129
################ parse pose tools ##############################
130+
def parse_place_pose(self, object_name, receptacle_name:str=None, **kwargs)->Pose:
131+
"""
132+
Parse place pose for the object.
133+
"""
134+
raise NotImplementedError("parse_place_pose() not implemented")
135+
131136
def parse_adaptive_shape_grasp_pose(self, object_name, **kwargs)->Pose:
132137
"""
133138
Parse grasp pose for the object. Use ground truth grounding and grasp detection model.
@@ -172,64 +177,6 @@ def parse_adaptive_shape_grasp_pose(self, object_name, **kwargs)->Pose:
172177

173178
return best_grasp_pose
174179

175-
def parse_place_pose(self, object_name, receptacle_name:str=None, **kwargs)->Pose:
176-
"""
177-
Parse place pose for the object. Use ground truth grounding and heuristic place position calculation.
178-
Args:
179-
object_name: str, name of the object
180-
receptacle_name: Optional(str), name of the receptacle
181-
position: Optional(np.array), position of the place pose
182-
description: Optional(str), description of the pose, "canonical pose" or "current pose"
183-
"""
184-
# get parameters from kwargs
185-
position = kwargs.get('position', None)
186-
if isinstance(position, Point):
187-
position = np.array([position.x, position.y, position.z])
188-
if isinstance(position, list):
189-
position = np.array(position)
190-
description: str= kwargs.get('description', "current pose")
191-
assert description in ["canonical pose", "current pose"] # only support canonical pose and current pose for now
192-
193-
# get the bounding box of the object and all other objectss
194-
object_bbox = self.get_3d_bbox(object_name)
195-
object_names = self.get_obj_name_list()
196-
obstacle_bbox_list = [
197-
self.get_3d_bbox(obstacle_name) for obstacle_name in object_names
198-
if obstacle_name not in [object_name]
199-
]
200-
201-
pose = Pose()
202-
203-
# If receptacle_name is given, get the receptacle position and bounding box
204-
if receptacle_name is not None:
205-
receptacle_bbox = self.get_3d_bbox(receptacle_name)
206-
# FIXME: for drawer, just hard code the receptacle position x to [max_x-0.2, max_x]
207-
if "drawer" in receptacle_name.lower():
208-
receptacle_bbox[0] = receptacle_bbox[3] - 0.2
209-
210-
# If position is given, use it directly, otherwise use grounding model to get the receptacle position
211-
if position is None:
212-
assert receptacle_name is not None, "parse_place_pose: position must be given if receptacle_name is not given"
213-
position = calculate_place_position(
214-
object_bbox, receptacle_bbox, obstacle_bbox_list, max_tries=100)
215-
else:
216-
# position already given, check if the position is valid, if not, adjust it until no collision found
217-
collision_mask = np.array([is_collision(object_bbox, obstacle_bbox) for obstacle_bbox in obstacle_bbox_list])
218-
# adjust the z position if there is collision
219-
if np.any(collision_mask):
220-
collided_bbox_list = np.array(obstacle_bbox_list)[collision_mask]
221-
position[2] = adjust_z(object_bbox, collided_bbox_list, extra_elevation=0.1)
222-
223-
pose.position = Point(*position)
224-
if description == "canonical pose":
225-
# use canonical orientation
226-
pose.orientation = Quaternion(-1.0,0.0,0.0,0.0)
227-
else:
228-
# remain current orientation
229-
pose.orientation = self.get_gripper_pose().orientation
230-
231-
return pose
232-
233180
def parse_central_lift_grasp_pose(self, object_name, description="top")->Pose:
234181
"""
235182
Parse central lift grasp pose for the object. Use ground truth grounding and heuristic place position calculation.

0 commit comments

Comments
 (0)