Skip to content

Commit

Permalink
Merge pull request #1061 from tue-robotics/update_robot_interface
Browse files Browse the repository at this point in the history
Update robot interface
  • Loading branch information
PetervDooren authored Feb 13, 2021
2 parents 0e21abe + e64ee2b commit 73b9ad1
Show file tree
Hide file tree
Showing 21 changed files with 233 additions and 165 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def place_pose(ud):

@cb_interface(outcomes=['done'])
def open_gripper(ud):
arm.resolve().send_gripper_goal("open", timeout=0)
arm.resolve().gripper.send_goal("open", timeout=0)
rospy.sleep(3.0)
robot.speech.speak("This is where I usually place my cup")
return 'done'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def __init__(self, robot, dishwasher_id):

@cb_interface(outcomes=['done'])
def _pre_grab_handle(ud):
robot.rightArm.send_gripper_goal("open", timeout=0)
robot.rightArm.gripper.send_goal("open", timeout=0)
robot.rightArm._send_joint_trajectory([[0, 0.2519052373022729913, 0.7746500794619434, 1.3944848321343395,
-1.829999276180074, 0.6947045024700284, 0.1889253710114966]],
timeout=rospy.Duration(0))
Expand All @@ -118,7 +118,7 @@ def _grab_handle(ud):
robot.speech.speak('I hope this goes right!', block=False)
fs = frame_stamped("dishwasher", 0.42, 0, 0.8, roll=math.pi / 2, pitch=0, yaw=math.pi)
robot.rightArm.send_goal(fs.projectToFrame(robot.robot_name + "/base_link", robot.tf_listener))
robot.rightArm.send_gripper_goal("close")
robot.rightArm.gripper.send_goal("close")
return 'done'

@cb_interface(outcomes=['done'])
Expand Down
10 changes: 5 additions & 5 deletions challenge_dishwasher/src/challenge_dishwasher/simple_grab.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ def execute(self, ud):
self.robot.speech.speak('I am sorry but I cannot move my arm to the object position', block=False)
rospy.logerr('Grasp failed')
arm.reset()
arm.send_gripper_goal('close', timeout=0.0)
arm.gripper.send_goal('close', timeout=0.0)
return 'failed'

# Close gripper
arm.send_gripper_goal('close')
arm.gripper.send_goal('close')

arm.occupied_by = None # TODO: what to do if we don't have an entity
arm.gripper.occupied_by = None # TODO: what to do if we don't have an entity

# Lift
rospy.loginfo('Start lifting')
Expand Down Expand Up @@ -142,7 +142,7 @@ def __init__(self, robot, arm):
@cb_interface(outcomes=['succeeded'])
def prepare_grasp(ud):
# Open gripper (non-blocking)
arm.resolve().send_gripper_goal('open', timeout=0)
arm.resolve().gripper.send_goal('open', timeout=0)

# Torso up (non-blocking)
robot.torso.high()
Expand All @@ -151,7 +151,7 @@ def prepare_grasp(ud):
arm.resolve().send_joint_trajectory('prepare_grasp', timeout=0)

# Open gripper
arm.resolve().send_gripper_goal('open', timeout=0.0)
arm.resolve().gripper.send_goal('open', timeout=0.0)
return 'succeeded'

with self:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def send_joint_goal(position_array, wait_for_motion_done=True):
arm.wait_for_motion_done()

def send_gripper_goal(open_close_string, max_torque=1.0):
arm.send_gripper_goal(open_close_string, max_torque=max_torque)
arm.gripper.send_goal(open_close_string, max_torque=max_torque)
rospy.sleep(1.0) # Does not work with motion_done apparently

def show_image(package_name, path_to_image_in_package):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ def execute(self, userdata=None):
if self.right_arm is not None:
function_list.append(partial(self.right_arm.send_joint_trajectory, "show_gripper"))
if self.left_arm is not None:
function_list.append(partial(self.left_arm.send_gripper_goal, "open"))
function_list.append(partial(self.left_arm.send_gripper_goal, "close"))
function_list.append(partial(self.left_arm.gripper.send_goal, "open"))
function_list.append(partial(self.left_arm.gripper.send_goal, "close"))
if self.right_arm is not None:
function_list.append(partial(self.right_arm.send_gripper_goal, "open"))
function_list.append(partial(self.right_arm.send_gripper_goal, "close"))
function_list.append(partial(self.right_arm.gripper.send_goal, "open"))
function_list.append(partial(self.right_arm.gripper.send_goal, "close"))
if self.left_arm is not None:
function_list.append(partial(self.left_arm.reset))
if self.right_arm is not None:
Expand Down Expand Up @@ -165,9 +165,9 @@ def execute(self, userdata=None):
if self.right_arm is not None:
self.right_arm.reset()
if self.left_arm is not None:
self.left_arm.send_gripper_goal("close")
self.left_arm.gripper.send_goal("close")
if self.right_arm is not None:
self.right_arm.send_gripper_goal("close")
self.right_arm.gripper.send_goal("close")
self.robot.torso.reset()
self.robot.head.reset()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ def execute(self, userdata=None):
function_list.append(partial(self.robot.speech.speak, self.trans.GRIPPER, language=self.language,
voice=self.voice, block=False))
function_list.append(partial(self.arm.send_joint_goal, "show_gripper"))
function_list.append(partial(self.arm.send_gripper_goal, "open"))
function_list.append(partial(self.arm.send_gripper_goal, "close"))
function_list.append(partial(self.arm.gripper.send_goal, "open"))
function_list.append(partial(self.arm.gripper.send_goal, "close"))
function_list.append(partial(self.robot.speech.speak, self.trans.GRIPPER_CAMERA, language=self.language,
voice=self.voice, block=True))
function_list.append(partial(self.arm.reset))
Expand Down Expand Up @@ -179,7 +179,7 @@ def execute(self, userdata=None):
if self.preempt_requested():
self.robot.speech.speak("Sorry, but I have to stop my introduction")
self.arm.reset()
self.arm.send_gripper_goal("close")
self.arm.gripper.send_goal("close")
self.robot.torso.reset()
self.robot.head.reset()
self.arm.wait_for_motion_done()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def __init__(self, robot, place_designator):

def execute(self, userdata=None):
# Try to place the object
item = ds.EdEntityDesignator(robot=self._robot, id=arm.occupied_by.id)
item = ds.EdEntityDesignator(robot=self._robot, id=arm.gripper.occupied_by.id)
arm_designator = ds.OccupiedArmDesignator(self._robot,
arm_properties={
"required_trajectories": ["prepare_place"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ def send_joint_goal(position_array, wait_for_motion_done=True):
arm.wait_for_motion_done()

def send_gripper_goal(open_close_string):
arm.send_gripper_goal(open_close_string)
arm.gripper.send_goal(open_close_string)
rospy.sleep(1.0) # Does not work with motion_done apparently

@cb_interface(outcomes=['done'])
def _pre_grab_handle(_):
arm.send_gripper_goal("open", timeout=0)
arm.gripper.send_goal("open", timeout=0)
send_joint_goal([0, -0, 0, -1.57, 1.57])
return 'done'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ def send_joint_goal(position_array, wait_for_motion_done=True):
arm.wait_for_motion_done()

def send_gripper_goal(open_close_string):
arm.send_gripper_goal(open_close_string)
arm.gripper.send_goal(open_close_string)
rospy.sleep(1.0) # Does not work with motion_done apparently

@cb_interface(outcomes=['done'])
def _pre_grab_handle(_):
arm.send_gripper_goal("open", timeout=0)
arm.gripper.send_goal("open", timeout=0)
send_joint_goal([0, -0, 0, -1.57, 1.57])
return 'done'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def send_joint_goal(position_array, wait_for_motion_done=True):
arm.wait_for_motion_done()

def send_gripper_goal(open_close_string, max_torque=0.1):
arm.send_gripper_goal(open_close_string, max_torque=max_torque)
arm.gripper.send_goal(open_close_string, max_torque=max_torque)
rospy.sleep(1.0) # Does not work with motion_done apparently

def show_image(package_name, path_to_image_in_package):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def send_joint_trajectory(goal_array, wait_for_motion_done=True):
arm.wait_for_motion_done()

def send_gripper_goal(open_close_string):
arm.send_gripper_goal(open_close_string)
arm.gripper.send_goal(open_close_string)
rospy.sleep(1.0) # Does not work with motion_done apparently

@cb_interface(outcomes=['done'], input_keys=["item_picked"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def __init__(self, robot, place_designator):

def execute(self, userdata=None):
# Try to place the object
item = ds.EdEntityDesignator(robot=self._robot, id=arm.occupied_by.id)
item = ds.EdEntityDesignator(robot=self._robot, id=arm.gripper.occupied_by.id)
arm_designator = ds.OccupiedArmDesignator(self._robot, {"required_goals": ["reset", "handover_to_human"],
"required_gripper_types": [arms.GripperTypes.GRASPING]})
resolved_arm = arm_designator.resolve()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ def execute(self, userdata=None):
# Arm to position in a safe way
arm.send_joint_goal('handover')
arm.wait_for_motion_done()
arm.send_gripper_goal('open')
arm.gripper.send_goal('open')
arm.wait_for_motion_done()
arm._arm._send_joint_trajectory(
[[0.4, -1.0, 0.0, -1.0, 0.0],[0.4, -1.0, 0.0, -1.57, 0.0], [0.4, -1.0, 0.0, -1.0, 0.0],
[0.4, -1.0, 0.0, -1.57, 0.0]])
arm.wait_for_motion_done()
arm.send_joint_goal('reset')
arm.wait_for_motion_done()
# arm.send_gripper_goal('close')
# arm.gripper.send_goal('close')
# arm.wait_for_motion_done()
return "succeeded"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,16 @@ def execute(self, userdata=None):
# This opening and closing is to make sure that the gripper is empty and closed before measuring the forces
# It is necessary to close the gripper since the gripper is also closed at the final measurement

# arm.send_gripper_goal('open')
# arm.gripper.send_goal('open')
# arm.wait_for_motion_done()
# arm.send_gripper_goal('close', max_torque=1.0)
# arm.gripper.send_goal('close', max_torque=1.0)
# arm.wait_for_motion_done()

arm_weight = measure_force.get_force()
rospy.loginfo("Empty weight %s", arm_weight)

# Open gripper
arm.send_gripper_goal('open')
arm.gripper.send_goal('open')
arm.wait_for_motion_done()

# Go down and grab
Expand All @@ -154,7 +154,7 @@ def execute(self, userdata=None):
# self._robot.torso.send_goal("grab_trash_down")
# self._robot.torso.wait_for_motion_done()
# rospy.sleep(3)
arm.send_gripper_goal('close', max_torque=1.0)
arm.gripper.send_goal('close', max_torque=1.0)
arm.wait_for_motion_done()

# Go up and back to pre grasp position
Expand Down Expand Up @@ -182,7 +182,7 @@ def execute(self, userdata=None):

self._robot.speech.speak("Look at this I can pick up the trash!")
handed_entity = EntityInfo(id="trash")
arm.occupied_by = handed_entity
arm.gripper.occupied_by = handed_entity

return "succeeded"

Expand Down
1 change: 1 addition & 0 deletions robot_skills/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<exec_depend>python-mock</exec_depend>

<test_depend>test_tools</test_depend>
<test_depend>python-six</test_depend>

<doc_depend>python-sphinx</doc_depend>
<doc_depend>python-sphinx-autoapi-pip</doc_depend>
Expand Down
Loading

0 comments on commit 73b9ad1

Please sign in to comment.