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

Use handover detector to detect failed handover #1327

Merged
merged 6 commits into from
Aug 8, 2023
Merged
Changes from 5 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
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
from robot_skills import get_robot
# ROS
from pykdl_ros import VectorStamped
from robot_smach_states.human_interaction import Say
from robot_smach_states.manipulation.active_grasp_detector import ActiveGraspDetector
from robot_smach_states.navigation import NavigateToSymbolic
from robot_smach_states.util.designators import EdEntityDesignator
from robot_smach_states.util.designators import EdEntityDesignator, ArmDesignator
from smach import StateMachine, cb_interface, CBState

item_img_dict = {
Expand All @@ -30,6 +32,7 @@ def __init__(self, robot):
# noinspection PyProtectedMember
arm = robot.get_arm()._arm
picked_items = []
armdes = ArmDesignator(robot, {"required_gripper_types": [GripperTypes.GRASPING]})

def send_joint_goal(position_array, wait_for_motion_done=True):
# noinspection PyProtectedMember
Expand Down Expand Up @@ -76,8 +79,6 @@ def _ask_user(user_data):

item_name = leftover_items[0]

picked_items.append(item_name)

robot.speech.speak("Please put the {} in my gripper, like this".format(item_name), block=False)
show_image("challenge_serve_breakfast", item_img_dict[item_name])

Expand All @@ -96,12 +97,27 @@ def _carrying_pose(user_data):
robot.speech.speak("Thanks for that!", block=False)
return "done"

@cb_interface(outcomes=["done"], input_keys=["item_picked"])
def _remember_item(user_data):
picked_items.append(user_data["item_picked"])
return "done"

with self:
self.add("ROTATE", CBState(_rotate), transitions={"done": "HANDOVER_POSE"})
self.add("HANDOVER_POSE", CBState(_handover_pose), transitions={"done": "ASK_USER"})
self.add("ASK_USER", CBState(_ask_user),
transitions={"succeeded": "CARRYING_POSE", "failed": "failed"})

transitions={"succeeded": "CHECK_PICK_SUCCESSFUL", "failed": "failed"})
self.add("CHECK_PICK_SUCCESSFUL",
ActiveGraspDetector(robot, armdes),
transitions={'true': "ADD_ITEM_TO_LIST",
'false': "SAY_SOMETHING_WENT_WRONG",
'failed': "failed",
'cannot_determine': "SAY_SOMETHING_WENT_WRONG"}
)
self.add("SAY_SOMETHING_WENT_WRONG", Say(robot, "Oops, it seems I missed it. Lets try again"),
transitions={"spoken": "ASK_USER2"})
self.add("ASK_USER2", CBState(_ask_user), transitions={"succeeded": "ADD_ITEM_TO_LIST", "failed": "failed"})
self.add("ADD_ITEM_TO_LIST", CBState(_remember_item), transitions={"done": "CARRYING_POSE"})
self.add("CARRYING_POSE", CBState(_carrying_pose), transitions={"done": "succeeded"})


Expand Down