Skip to content

Commit

Permalink
Reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
haiwei-luo committed Jul 24, 2024
1 parent dbab829 commit 4c78a9c
Show file tree
Hide file tree
Showing 4 changed files with 162 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,11 @@ def _check_finished(self) -> bool:
)
transcription = self._transcribe_speech_client.get_result().sequence

return "yes" in transcription.lower() or "arrived" in transcription.lower() or "arrive" in transcription.lower()
return (
"yes" in transcription.lower()
or "arrived" in transcription.lower()
or "arrive" in transcription.lower()
)
return True

def _get_pose_on_path(
Expand Down
18 changes: 13 additions & 5 deletions tasks/carry_my_luggage/src/carry_my_luggage/state_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,19 +193,27 @@ def wait_cb(ud, msg):

def start_pose_cb(ud):
try:
ud.start_pose = rospy.wait_for_message("/robot_pose", PoseWithCovarianceStamped, timeout=rospy.Duration(5.0)).pose.pose
ud.start_pose = rospy.wait_for_message(
"/robot_pose",
PoseWithCovarianceStamped,
timeout=rospy.Duration(5.0),
).pose.pose
except rospy.ROSException:
rospy.logerr("Failed to get robot pose")
ud.start_pose = Pose(position=Point(0., 0., 0.0), orientation=Quaternion(0., 0., 0., 1.))
ud.start_pose = Pose(
position=Point(0.0, 0.0, 0.0),
orientation=Quaternion(0.0, 0.0, 0.0, 1.0),
)
return "succeeded"

smach.StateMachine.add(
"GET_START_LOCATION",
smach.CBState(
start_pose_cb,
outcomes=["succeeded"],
output_keys=["start_pose"],
),
transitions={"succeeded": "SAY_STEP"}
transitions={"succeeded": "SAY_STEP"},
)

smach.StateMachine.add(
Expand Down Expand Up @@ -261,8 +269,8 @@ def start_pose_cb(ud):
)

smach.StateMachine.add(
"GO_TO_START", # todo: instead, get the start position within the state machine, and return to it at the end
"GO_TO_START", # todo: instead, get the start position within the state machine, and return to it at the end
GoToLocation(),
remapping={"location" : "start_pose"},
remapping={"location": "start_pose"},
transitions={"succeeded": "succeeded", "failed": "succeeded"},
)
123 changes: 120 additions & 3 deletions tasks/gpsr/src/gpsr/states/object_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,133 @@ class ObjectComparison(smach.StateMachine):

# TODO: fill this in

_smallest_list: List[str] = ["dishwasher_tab", "candle", "strawberry", "tictac", "plum", "lemon", "pear", "peach", "orange", "apple", "sponges", "fork", "knife", "spoon", "banana", "dubbelfris", "cola", "ice_tea", "fanta", "milk", "pea_soup", "sausages", "cup", "stroopwafel", "soap", "curry", "water", "crisps", "liquorice", "candy", "hagelslag", "pancake_mix", "mayonaise", "bowl", "plate", "washcloth", "pringles", "big_coke" ]
_smallest_list: List[str] = [
"dishwasher_tab",
"candle",
"strawberry",
"tictac",
"plum",
"lemon",
"pear",
"peach",
"orange",
"apple",
"sponges",
"fork",
"knife",
"spoon",
"banana",
"dubbelfris",
"cola",
"ice_tea",
"fanta",
"milk",
"pea_soup",
"sausages",
"cup",
"stroopwafel",
"soap",
"curry",
"water",
"crisps",
"liquorice",
"candy",
"hagelslag",
"pancake_mix",
"mayonaise",
"bowl",
"plate",
"washcloth",
"pringles",
"big_coke",
]
_biggest_list: List[str] = reversed(_smallest_list)

_largest_list: List[str] = _biggest_list

_heaviest_list: List[str] = ["big_coke", "pea_soup", "milk", "mayonaise", "cola", "ice_tea", "fanta", "dubbelfris", "water", "pancake_mix", "curry", "soap", "sausages", "apple", "orange", "peach", "pear", "lemon", "plum", "banana", "stroopwafel", "cup", "bowl", "plate", "washcloth", "sponges", "pringles", "crisps", "hagelslag", "liquorice", "candy", "knife", "fork", "spoon", "candle", "strawberry", "tictac", "dishwasher_tab"]
_heaviest_list: List[str] = [
"big_coke",
"pea_soup",
"milk",
"mayonaise",
"cola",
"ice_tea",
"fanta",
"dubbelfris",
"water",
"pancake_mix",
"curry",
"soap",
"sausages",
"apple",
"orange",
"peach",
"pear",
"lemon",
"plum",
"banana",
"stroopwafel",
"cup",
"bowl",
"plate",
"washcloth",
"sponges",
"pringles",
"crisps",
"hagelslag",
"liquorice",
"candy",
"knife",
"fork",
"spoon",
"candle",
"strawberry",
"tictac",
"dishwasher_tab",
]

_lightest_list: List[str] = reversed(_heaviest_list)

_thinnest_list: List[str] = ["knife", "fork", "spoon", "candle", "strawberry", "tictac", "dishwasher_tab", "liquorice", "candy", "crisps", "stroopwafel", "soap", "sponges", "washcloth", "plate", "bowl", "cup", "pancake_mix", "hagelslag", "curry", "mayonaise", "pea_soup", "sausages", "milk", "water", "dubbelfris", "cola", "ice_tea", "fanta", "big_coke", "apple", "orange", "peach", "pear", "lemon", "plum", "banana", "pringles"]
_thinnest_list: List[str] = [
"knife",
"fork",
"spoon",
"candle",
"strawberry",
"tictac",
"dishwasher_tab",
"liquorice",
"candy",
"crisps",
"stroopwafel",
"soap",
"sponges",
"washcloth",
"plate",
"bowl",
"cup",
"pancake_mix",
"hagelslag",
"curry",
"mayonaise",
"pea_soup",
"sausages",
"milk",
"water",
"dubbelfris",
"cola",
"ice_tea",
"fanta",
"big_coke",
"apple",
"orange",
"peach",
"pear",
"lemon",
"plum",
"banana",
"pringles",
]

_query: Literal[
"biggest", "largest", "smallest", "heaviest", "lightest", "thinnest"
Expand Down
36 changes: 24 additions & 12 deletions tasks/receptionist/src/receptionist/states/speech_recovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ def __init__(
last_resort: bool,
input_type: str = "",
):
"""Recover the correct name and / or drink by parsing the transcription.
"""Recover the correct name and / or drink by parsing the transcription.
Args:
guest_id (str): ID of the guest (identifying the guest)
last_resort (bool): Whether the program must recover a name or drink
input_type (str, optional): The type of information to try and extract useful information
(drink or name)
"""

smach.State.__init__(
self,
outcomes=["succeeded", "failed"],
Expand Down Expand Up @@ -186,8 +186,8 @@ def _handle_name(self, sentence_list: List[str], last_resort: bool) -> str:
return self._handle_closest_spelt(sentence_list, self._available_names)

def _handle_drink(self, sentence_list: List[str], last_resort: bool) -> str:
"""Attempt to recover the drink in the transcription. For phrases containing two words, try to infer the
second word in the phrase. If this fails, attempt to recover the drink via spelling, then pronounciation.
"""Attempt to recover the drink in the transcription. For phrases containing two words, try to infer the
second word in the phrase. If this fails, attempt to recover the drink via spelling, then pronounciation.
Enter last resort if necessary and recover the closest spelt drink.
Args:
Expand Down Expand Up @@ -233,9 +233,14 @@ def _handle_drink(self, sentence_list: List[str], last_resort: bool) -> str:
sentence_list.append(closest_spelt)
return self._infer_second_drink(sentence_list)

def _handle_similar_spelt(self, sentence_list: List[str], available_words: List[str], distance_threshold: int) -> str:
"""Recover any word by spelling that has a similarity lower than the specified threshold
when comparing each word in the sentence list to the list of available words.
def _handle_similar_spelt(
self,
sentence_list: List[str],
available_words: List[str],
distance_threshold: int,
) -> str:
"""Recover any word by spelling that has a similarity lower than the specified threshold
when comparing each word in the sentence list to the list of available words.
Args:
sentence_list (List[str]): Transcription split up as a list of strings.
Expand All @@ -254,9 +259,14 @@ def _handle_similar_spelt(self, sentence_list: List[str], available_words: List[
return available_word
return "unknown"

def _handle_similar_sound(self, sentence_list: List[str], available_words: List[str], distance_threshold: int) -> str:
"""Recover any word by pronounciation that has a similarity lower than the specified threshold
when comparing each word in the sentence list to the list of available words.
def _handle_similar_sound(
self,
sentence_list: List[str],
available_words: List[str],
distance_threshold: int,
) -> str:
"""Recover any word by pronounciation that has a similarity lower than the specified threshold
when comparing each word in the sentence list to the list of available words.
Args:
sentence_list (List[str]): Transcription split up as a list of strings.
Expand Down Expand Up @@ -292,8 +302,10 @@ def _infer_second_drink(self, sentence_list: List[str]) -> str:
return self._double_drinks_dict[input_word]
return "unknown"

def _handle_closest_spelt(self, sentence_list: List[str], choices: List[str]) -> str:
"""Get the closest spelt word from the list of choices (drinks or names)
def _handle_closest_spelt(
self, sentence_list: List[str], choices: List[str]
) -> str:
"""Get the closest spelt word from the list of choices (drinks or names)
in the sentence list (transcription).
Args:
Expand Down

0 comments on commit 4c78a9c

Please sign in to comment.