-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: get name and drink skill & prior data yaml
- Loading branch information
Showing
2 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
priors: | ||
names: | ||
- Adel | ||
- Angel | ||
- Axel | ||
- Charlie | ||
- Jane | ||
- Jules | ||
- Morgan | ||
- Paris | ||
- Robin | ||
- Simone | ||
drinks: | ||
- cola | ||
- iced tea | ||
- juice pack | ||
- milk | ||
- orange juice | ||
- red wine | ||
- tropical juice |
58 changes: 58 additions & 0 deletions
58
tasks/receptionist/src/receptionist/states/get_name_and_drink.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import rospy | ||
import smach | ||
from typing import List, Dict, Any | ||
|
||
|
||
class ParseNameAndDrink(smach.State): | ||
def __init__(self, param_key: str = "priors"): | ||
"""Parses the transcription of the guests' name and favourite drink. | ||
Args: | ||
param_key (str, optional): Name of the parameter that contains the list of | ||
possible . Defaults to "priors". | ||
""" | ||
|
||
prior_data: Dict[str, List[str]] = rospy.get_param(param_key) | ||
self._possible_names = prior_data["names"] | ||
self._possible_drinks = prior_data["drinks"] | ||
|
||
def execute(self, userdata: Dict[str, Any]) -> str: | ||
"""Parses the transcription of the guests' name and favourite drink. | ||
Args: | ||
userdata (Dict[str, Any]): State machine userdata assumed to contain a key | ||
called "guest transcription" with the transcription of the guest's name and | ||
favourite drink. | ||
Returns: | ||
str: state outcome. Updates the userdata with the parsed name and drink, under | ||
the parameter "guest data". | ||
""" | ||
|
||
outcome = "succeeded" | ||
guest_id = userdata["guest id"] | ||
name_found = False | ||
drink_found = False | ||
|
||
for name in self._possible_names: | ||
if name in userdata["guest transcription"]: | ||
userdata["guest data"][guest_id]["name"] = name | ||
rospy.loginfo(f"Guest Name identified as: {name}") | ||
name_found = True | ||
break | ||
|
||
for drink in self._possible_drinks: | ||
if drink in userdata["guest transcription"]: | ||
userdata["guest data"][guest_id]["drink"] = drink | ||
rospy.loginfo(f"Guest Drink identified as: {drink}") | ||
drink_found = True | ||
break | ||
|
||
if not name_found: | ||
rospy.loginfo("Name not found in transcription") | ||
outcome = "failed" | ||
if not drink_found: | ||
rospy.loginfo("Drink not found in transcription") | ||
outcome = "failed" | ||
|
||
return outcome |