Skip to content

Commit

Permalink
[Receptionist] Yes/No function implemented, plan to switch from Subsc…
Browse files Browse the repository at this point in the history
…ribers to one Service from NLP.
  • Loading branch information
Celina1272001 committed Mar 20, 2024
1 parent 3817438 commit a48531b
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 19 deletions.
25 changes: 16 additions & 9 deletions demos/pycram_receptionist_demo/Ms3_receptionist_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
with real_robot:

#wait for doorbell
bell_subscriber = rospy.Subscriber("doorbell", Bool, doorbell_cb)
while not doorbell:
# TODO: spin or sleep better?
rospy.spin()
#bell_subscriber = rospy.Subscriber("doorbell", Bool, doorbell_cb)
#while not doorbell:
# # TODO: spin or sleep better?
# rospy.spin()

# subscriber not needed anymore
bell_subscriber.unregister()
#bell_subscriber.unregister()

# question: is the hsr standing in front of the door already??
# giskardpy.opendoor()
Expand All @@ -59,14 +59,21 @@
# failure handling
rospy.Subscriber("nlp_feedback", Bool, talk_error)

while not understood:
while guest1.name == "guest1":
rospy.sleep(1)
print(guest1.name)
print(understood)

TalkingMotion("it is so noisy here, please confirm if i got your name right").resolve().perform()
rospy.sleep(1)
TalkingMotion("is your name " + guest1.name + "?").resolve().perform()
pub_nlp.publish("start")

rospy.Subscriber("name_confirm", Bool, name_cb)
rospy.Subscriber("nlp_confirmation", Bool, name_cb)

while not guest1.understood:
rospy.sleep(1)
print(str(guest1.understood))


# stop looking
Expand All @@ -83,8 +90,8 @@
# lead human to living room
# TODO: check if rospy.sleep is needed and how long
rospy.sleep(2)
NavigateAction([pose_kitchen_to_couch]).resolve().perform()
NavigateAction([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
40 changes: 30 additions & 10 deletions demos/pycram_receptionist_demo/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
pub_nlp = rospy.Publisher('/startListener', String, queue_size=10)
understood = False
doorbell = False
name = False

# Declare variables for humans
host = HumanDescription("Yannis", fav_drink="ice tea")
Expand Down Expand Up @@ -44,16 +45,26 @@ def talk_request_nlp(data: String):
function that takes the data from nlp (name and drink) and lets the robot talk
:param data: String "name, drink"
"""
global understood
data_list = data.data.split(",")
name, drink = data_list
toyas_text = f"Hey {name}, your favorite drink is {drink}"
print(guest1.name)
if guest1.name == "guest1":
data_list = data.data.split(",")
name, drink = data_list
toyas_text = f"Hey {name}, your favorite drink is {drink}"

TalkingMotion(toyas_text).resolve().perform()
rospy.sleep(2)

guest1.set_name(name)
guest1.set_drink(drink)
else:
data_list = data.data.split(",")
name, drink = data_list
toyas_text = f"is your name {name} ?"
TalkingMotion(toyas_text).resolve().perform()
pub_nlp.publish("start")


TalkingMotion(toyas_text).resolve().perform()
rospy.sleep(2)
TalkingMotion("Nice to meet you").resolve().perform()

understood = True


def talk_error(data):
Expand Down Expand Up @@ -85,13 +96,22 @@ def doorbell_cb(data):
global doorbell
doorbell = True


def name_cb(data):
"""
callback function for a subscriber to NLP script.
is called when name was correctly understood
"""
global name
name = data
print("name cb:" + str(data))
if data.data:
TalkingMotion("perfect, nice to meet you").resolve().perform()
guest1.set_understood(True)
else:
TalkingMotion("i am sorry, please repeat your name loud and clear").resolve().perform()
rospy.sleep(1)
# TODO: only hear for Name
pub_nlp.publish("start listening")




0 comments on commit a48531b

Please sign in to comment.