Skip to content

Commit

Permalink
feat: HandoverObject skill, and update dunder init.
Browse files Browse the repository at this point in the history
  • Loading branch information
jws-1 committed Mar 8, 2024
1 parent bbdffdc commit a934e9d
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 1 deletion.
2 changes: 2 additions & 0 deletions skills/src/lasr_skills/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@
from .go_to_location import GoToLocation
from .go_to_semantic_location import GoToSemanticLocation
from .listen_wake_word import ListenWakeWord
from .handover_object import HandoverObject
from .receive_object import ReceiveObject
69 changes: 69 additions & 0 deletions skills/src/lasr_skills/handover_object.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import smach
from smach_ros import SimpleActionState

from play_motion_msgs.msg import PlayMotionAction, PlayMotionGoal
from pal_interaction_msgs.msg import TtsGoal, TtsAction, TtsText

from lasr_skills import ListenWakeWord


class HandoverObject(smach.StateMachine):

def __init__(self):
smach.StateMachine.__init__(
self, outcomes=["succeeded", "failed"], input_keys=["object_name"]
)

with self:
# TODO: clear octomap and look around
smach.StateMachine.add(
"HANDOVER_OBJECT",
SimpleActionState(
"play_motion",
PlayMotionAction,
goal=PlayMotionGoal(
motion_name="handover_object", skip_planning=False
),
),
transitions={"succeeded": "succeeded", "aborted": "failed"},
)
smach.StateMachine.add(
"SAY",
SimpleActionState(
"tts",
TtsAction,
goal_cb=lambda ud, _: TtsGoal(
rawtext=TtsText(
text=f"Please grab the {ud.object_name} in my hand, and say 'done' when you are ready for me to release it.",
lang_id="en_GB",
)
),
input_keys=["object_name"],
),
)
smach.StateMachine.add(
"WAIT_FOR_SPEECH",
ListenWakeWord("done"),
transitions={"succeeded": "OPEN_GRIPPER", "failed": "failed"},
)

smach.StateMachine.add(
"OPEN_GRIPPER",
SimpleActionState(
"play_motion",
PlayMotionAction,
goal=PlayMotionGoal(
motion_name="open_gripper", skip_planning=False
),
),
transitions={"succeeded": "succeeded", "aborted": "failed"},
)
smach.StateMachine.add(
"FOLD_ARM",
SimpleActionState(
"play_motion",
PlayMotionAction,
goal=PlayMotionGoal(motion_name="fold_arm", skip_planning=False),
),
transitions={"succeeded": "succeeded", "aborted": "failed"},
)
2 changes: 1 addition & 1 deletion skills/src/lasr_skills/receive_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(self):
smach.StateMachine.add(
"WAIT_FOR_SPEECH",
ListenWakeWord("done"),
transitions={"succeeded": "CLOSE_GRIPPER", "failed": "WAIT_FOR_SPEECH"},
transitions={"succeeded": "CLOSE_GRIPPER", "failed": "failed"},
)

smach.StateMachine.add(
Expand Down

0 comments on commit a934e9d

Please sign in to comment.