Skip to content

Commit

Permalink
[Receptionist] worked a little bit on code
Browse files Browse the repository at this point in the history
  • Loading branch information
Julislz committed Apr 5, 2024
1 parent 6b2b812 commit 9fecc1a
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 7 deletions.
12 changes: 9 additions & 3 deletions demos/pycram_receptionist_demo/Ms3_receptionist_demo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pycram.designators.action_designator import DetectAction
from pycram.designators.action_designator import DetectAction, NavigateAction
from demos.pycram_receptionist_demo.utils.new_misc import *
from pycram.process_module import real_robot
import pycram.external_interfaces.giskard as giskardpy
Expand Down Expand Up @@ -37,6 +37,7 @@ def data_cb(data):
global callback

response = data.data.split(",")
response.append("None")
callback = True


Expand All @@ -58,8 +59,11 @@ def data_cb(data):
# look for human
human_desig = DetectAction(technique='attributes', state='start').resolve().perform()
rospy.loginfo("human detected")

# TODO: check what perception returns exactly
attr_list = human_desig.attribute
print(attr_list)
guest1.set_attributes(human_desig.attribute)

# look at guest and introduce
giskardpy.move_head_to_human()
Expand All @@ -74,6 +78,7 @@ def data_cb(data):
callback = False

if response[0] == "<GUEST>":
# success a name and intent was understood
if response[1] != "<None>":
TalkingMotion("it is so noisy here, please confirm if i got your name right").resolve().perform()
guest1.set_drink(response[2])
Expand Down Expand Up @@ -123,8 +128,8 @@ def data_cb(data):
# lead human to living room
# TODO: check if rospy.sleep is needed and how long
rospy.sleep(2)
# NavigateAction([misc.pose_kitchen_to_couch]).resolve().perform()
# NavigateAction([misc.pose_couch]).resolve().perform()
NavigateAction([pose_kitchen_to_couch]).resolve().perform()
NavigateAction([pose_couch]).resolve().perform()
TalkingMotion("Welcome to the living room").resolve().perform()
rospy.sleep(1)

Expand Down Expand Up @@ -168,3 +173,4 @@ def data_cb(data):

# introduce humans and look at them
introduce(host, guest1)

7 changes: 4 additions & 3 deletions demos/pycram_receptionist_demo/tests/MS3_testable.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def data_cb(data):
global callback

response = data.data.split(",")
response.append("None")
callback = True

def demo_tst():
Expand All @@ -47,15 +48,16 @@ def demo_tst():
with real_robot:
global callback
global response
test_all = False
test_all = True

rospy.Subscriber("nlp_out", String, data_cb)
# DetectAction(technique='human', state='start').resolve().perform()
DetectAction(technique='human', state='start').resolve().perform()
rospy.loginfo("human detected")

giskardpy.move_head_to_human()
TalkingMotion("Hello, i am Toya and my favorite drink is oil. What about you, talk to me?").resolve().perform()
rospy.sleep(0.9)

# signal to start listening
pub_nlp.publish("start listening")

Expand Down Expand Up @@ -136,7 +138,6 @@ def demo_tst():
# introduce humans and look at them
giskardpy.move_head_to_human()

TalkingMotion("Introducing now").resolve().perform()
rospy.sleep(1)
introduce(host, guest1)

Expand Down
26 changes: 26 additions & 0 deletions demos/pycram_receptionist_demo/utils/new_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,29 @@ def introduce(human1: HumanDescription, human2: HumanDescription):
TalkingMotion(f" This is {human1.name} and their favorite drink is {human1.fav_drink}").resolve().perform()

rospy.sleep(3)

def describe(human: HumanDescription):
"""
HRI-function for describing a human more detailed.
the following will be stated: gender, headgear, clothing, brightness of clothes
:param human: human to be described
"""

TalkingMotion(f"I will describe {human.name} further now").resolve().perform()
rospy.sleep(1)

# gender
TalkingMotion(f"i think your gender is {human.attributes[0]}").resolve().perform()
rospy.sleep(1)

# headgear or not
TalkingMotion(f"you are wearing {human.attributes[1]}").resolve().perform()
rospy.sleep(1)

# kind of clothes
TalkingMotion(f"you are wearing {human.attributes[2]}").resolve().perform()
rospy.sleep(1)

# brightness of clothes
TalkingMotion(f"your clothes are {human.attributes[3]}").resolve().perform()
rospy.sleep(1)
13 changes: 12 additions & 1 deletion src/pycram/designators/object_designator.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,12 @@ class HumanDescription:
"""
Class that represents humans. this class does not spawn a human in a simulation.
"""
def __init__(self, name: String, fav_drink: Optional = None, pose: Optional = None):
def __init__(self, name: String, fav_drink: Optional = None,
pose: Optional = None, attributes: Optional = None):
"""
:param name: name of human
:param fav_drink: favorite drink of human
:param pose: last known pose of human
"""

# TODO: coordinate with Perception on what is easy to implement
Expand All @@ -199,6 +201,8 @@ def __init__(self, name: String, fav_drink: Optional = None, pose: Optional = N
self.name = name
self.fav_drink = fav_drink
self.pose = pose
self.attributes = attributes


# self.human_pose_sub = rospy.Subscriber("/human_pose", PoseStamped, self.human_pose_cb)

Expand Down Expand Up @@ -234,3 +238,10 @@ def set_pose(self, new_pose):
"""
print("in set pose")
self.pose = new_pose

def set_attributes(self, attribute_list):
"""
function for setting attributes
:param attribute_list: list with attributes: gender, headgear, kind of clothes, bright/dark clothes
"""
self.attributes = attribute_list

0 comments on commit 9fecc1a

Please sign in to comment.