Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

post-QA update fixes #434

Merged
merged 4 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,6 @@ def rt_loop(self):
self._window_criterion_coco_input_mode
)

log.info("keep looping starting...")
# log.info(f"_rt_keep_looping: {self._rt_keep_looping()}")
while self._rt_keep_looping():
# log.info(f"self._rt_awake_evt.wait_and_clear(self._rt_active_heartbeat): {self._rt_awake_evt.wait_and_clear(self._rt_active_heartbeat)}")
Expand Down
5 changes: 3 additions & 2 deletions ros/angel_system_nodes/angel_system_nodes/audio/asr.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def __init__(self):
self._feedback_topic = (
self.get_parameter(FEEDBACK_TOPIC).get_parameter_value().string_value
)

self.log.info(
f"Audio topic: "
f"({type(self._audio_topic).__name__}) "
Expand Down Expand Up @@ -226,7 +226,7 @@ def _publish_text(self, text: str):
published_msg.utterance_text = text
colored_utterance = colored(published_msg.utterance_text, "light_blue")
self.log.info("Publishing message: " + f'"{colored_utterance}"')

if (
"angela" in text.lower()
or "angel" in text.lower()
Expand All @@ -246,6 +246,7 @@ def publish_feedback_response(self):
publish_msg.response = "thinking"
self._feedback_publisher.publish(publish_msg)


main = make_default_main(ASR)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
IMAGE_TOPIC = "image_topic"
TASK_STATE_TOPIC = "task_state_topic"


class QuestionAnswerer(dialogue.AbstractDialogueNode):
def __init__(self):
super().__init__()
Expand Down Expand Up @@ -152,7 +153,7 @@ def process_image_callback(self, image: Image):
jpg_container = io.BytesIO()
img_rgb.save(jpg_container, format="JPEG")
self.image_msg = base64.b64encode(jpg_container.getvalue()).decode("utf-8")

def question_answer_callback(self, msg):
self.log.debug(f"Received message:\n\n{msg.utterance_text}")
if not self._apply_filter(msg):
Expand All @@ -169,7 +170,7 @@ def process_question_queue(self):
optional_fields = self._get_optional_fields_string(
self.current_step, self.completed_steps
)

response = self.get_response(msg, optional_fields)
self.publish_generated_response(msg, response)

Expand Down Expand Up @@ -207,7 +208,7 @@ def prompt_gpt(self, question, optional_fields: str, model: str = "gpt-4o"):
"model": model,
"messages": [
{
"role": "user",
"role": "user",
"content": [
{
"type": "text",
Expand All @@ -227,7 +228,6 @@ def prompt_gpt(self, question, optional_fields: str, model: str = "gpt-4o"):
"max_tokens": 128,
}


req = requests.post(
"https://api.openai.com/v1/chat/completions",
json=payload,
Expand Down Expand Up @@ -308,7 +308,7 @@ def _apply_filter(self, msg):
if (
"angela" in msg.utterance_text.lower()
or "angel" in msg.utterance_text.lower()
or "angela," in msg.utterance_text.lower()
or "angela," in msg.utterance_text.lower()
or "angel," in msg.utterance_text.lower()
):
return msg
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,14 @@
PARAM_GT_OUTPUT_DIR = "gt_output_dir" # output directory override.



VALID_STEP_MODES = {"broad", "granular"}


# Local value meaning "no input given" for a parameter that we want to be
# considered "optional".
NO_VALUE_GIVEN = "__NO_VALUE_GIVEN__"


class GlobalStepPredictorNode(Node):
"""
ROS node that runs the GlobalStepPredictor and publishes TaskUpdate
Expand All @@ -72,7 +76,7 @@ def __init__(self):
(PARAM_ACTIVITY_CONFIG_FILE,),
(PARAM_TASK_STATE_TOPIC,),
(PARAM_TASK_ERROR_TOPIC,),
(PARAM_SYSTEM_TEXT_TOPIC,),
(PARAM_SYSTEM_TEXT_TOPIC, NO_VALUE_GIVEN),
(PARAM_SYS_CMD_TOPIC,),
(PARAM_QUERY_TASK_GRAPH_TOPIC,),
(PARAM_DET_TOPIC,),
Expand Down Expand Up @@ -171,9 +175,6 @@ def __init__(self):
self._task_error_publisher = self.create_publisher(
AruiUserNotification, self._task_error_topic, 1
)
self._sytem_text_publisher = self.create_publisher(
SystemTextResponse, self._system_text_topic, 1
)
self._task_graph_service = self.create_service(
QueryTaskGraph, self._query_task_graph_topic, self.query_task_graph_callback
)
Expand All @@ -183,6 +184,22 @@ def __init__(self):
self._sys_cmd_subscription = self.create_subscription(
SystemCommands, self._sys_cmd_topic, self.sys_cmd_callback, 1
)

# Optionally enable the system text publisher if an input topic is
# provided. This is currently only used with the Question and Answer
# demo to provide a textual representation of the system notice to the
# user wearing a headset.
self._system_text_publisher = None
if self._system_text_topic != NO_VALUE_GIVEN:
self._system_text_publisher = self.create_publisher(
SystemTextResponse, self._system_text_topic, 1
)
else:
log.warn(
"System text response not enabled. Provide a topic name "
"to enable it."
)

log.info("ROS services initialized.")

self.gt_video_dset: Optional[kwcoco.CocoDataset] = None
Expand Down Expand Up @@ -399,13 +416,14 @@ def publish_task_error_message(self, skipped_step: str):

self._task_error_publisher.publish(message)

# Publish a voice message to user
publish_msg = SystemTextResponse()
publish_msg.header.frame_id = "Skip detected"
publish_msg.header.stamp = self.get_clock().now().to_msg()
publish_msg.utterance_text = ""
publish_msg.response = "We detected you skipped a step. Please confirm the dialog if you want to go back."
self._sytem_text_publisher.publish(publish_msg)
# Publish a voice message to user if enabled.
if self._system_text_publisher is not None:
publish_msg = SystemTextResponse()
publish_msg.header.frame_id = "Skip detected"
publish_msg.header.stamp = self.get_clock().now().to_msg()
publish_msg.utterance_text = ""
publish_msg.response = "We detected you skipped a step. Please confirm the dialog if you want to go back."
self._system_text_publisher.publish(publish_msg)

def publish_task_state_message(
self,
Expand Down
6 changes: 4 additions & 2 deletions tmux/demos/medical/Kitware-M2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ windows:
-p config_file:=${CONFIG_DIR}/tasks/medical/multi-task-config-medical-m2.yaml
-p activity_config_file:=${CONFIG_DIR}/activity_labels/medical/m2.yaml
-p task_state_topic:=TaskUpdates
-p task_error_topic:=TaskErrors
-p task_error_topic:=ARUISystemNotifications
-p system_command_topic:=SystemCommands
-p det_topic:=activity_topic
-p model_file:=${MODEL_DIR}/task_monitor/m2_test_activity_preds.mscoco.json
Expand Down Expand Up @@ -156,7 +156,7 @@ windows:
--query_task_graph_topic=query_task_graph
--task_updates_topic=TaskUpdates
--activity_detections_topic=activity_topic
--task_errors_topic=TaskErrors
--task_errors_topic=ARUISystemNotifications

- feedback_generator: ros2 run angel_system_nodes feedback_generator --ros-args
-r __ns:=${ROS_NAMESPACE}
Expand All @@ -165,3 +165,5 @@ windows:
-p task_monitor_topic:=TaskUpdates
-p arui_update_topic:=AruiUpdates
-p interp_user_intent_topic:=UserIntentPredicted
-p system_text_response_topic:=SystemTextResponse
-p system_notification_topic:=ARUISystemNotifications
6 changes: 4 additions & 2 deletions tmux/demos/medical/Kitware-M3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ windows:
-p config_file:=${CONFIG_DIR}/tasks/medical/multi-task-config-medical-m3.yaml
-p activity_config_file:=${CONFIG_DIR}/activity_labels/medical/m3.yaml
-p task_state_topic:=TaskUpdates
-p task_error_topic:=TaskErrors
-p task_error_topic:=ARUISystemNotifications
-p system_command_topic:=SystemCommands
-p det_topic:=activity_topic
-p model_file:=${MODEL_DIR}/task_monitor/m3_test_activity_preds.mscoco.json
Expand Down Expand Up @@ -156,7 +156,7 @@ windows:
--query_task_graph_topic=query_task_graph
--task_updates_topic=TaskUpdates
--activity_detections_topic=activity_topic
--task_errors_topic=TaskErrors
--task_errors_topic=ARUISystemNotifications

- feedback_generator: ros2 run angel_system_nodes feedback_generator --ros-args
-r __ns:=${ROS_NAMESPACE}
Expand All @@ -165,3 +165,5 @@ windows:
-p task_monitor_topic:=TaskUpdates
-p arui_update_topic:=AruiUpdates
-p interp_user_intent_topic:=UserIntentPredicted
-p system_text_response_topic:=SystemTextResponse
-p system_notification_topic:=ARUISystemNotifications
6 changes: 4 additions & 2 deletions tmux/demos/medical/Kitware-M5.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ windows:
-p config_file:=${CONFIG_DIR}/tasks/medical/multi-task-config-medical-m5.yaml
-p activity_config_file:=${CONFIG_DIR}/activity_labels/medical/m5.yaml
-p task_state_topic:=TaskUpdates
-p task_error_topic:=TaskErrors
-p task_error_topic:=ARUISystemNotifications
-p system_command_topic:=SystemCommands
-p det_topic:=activity_topic
-p model_file:=${MODEL_DIR}/task_monitor/m5_test_activity_preds.mscoco.json
Expand Down Expand Up @@ -156,7 +156,7 @@ windows:
--query_task_graph_topic=query_task_graph
--task_updates_topic=TaskUpdates
--activity_detections_topic=activity_topic
--task_errors_topic=TaskErrors
--task_errors_topic=ARUISystemNotifications

- feedback_generator: ros2 run angel_system_nodes feedback_generator --ros-args
-r __ns:=${ROS_NAMESPACE}
Expand All @@ -165,3 +165,5 @@ windows:
-p task_monitor_topic:=TaskUpdates
-p arui_update_topic:=AruiUpdates
-p interp_user_intent_topic:=UserIntentPredicted
-p system_text_response_topic:=SystemTextResponse
-p system_notification_topic:=ARUISystemNotifications
10 changes: 5 additions & 5 deletions tmux/demos/medical/Kitware-R18-qa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ windows:
-p asr_req_segment_duration:=1
-p is_sentence_tokenize:=False
-p debug_mode:=True

- emotion_detection:
layout: even-vertical
panes:
Expand All @@ -108,7 +108,7 @@ windows:
-r __ns:=${ROS_NAMESPACE}
-p in_emotion_topic:=utterances_topic
-p out_emotion_topic:=gpt_emotion_output_topic

- intent_detection:
layout: even-vertical
panes:
Expand All @@ -120,7 +120,7 @@ windows:
-r __ns:=${ROS_NAMESPACE}
-p in_intent_topic:=base_emotion_output_topic
-p out_intent_topic:=gpt_intent_output_topic

- question_answering:
layout: even-vertical
panes:
Expand All @@ -132,7 +132,7 @@ windows:
-p task_state_topic:=TaskUpdates
-p image_topic:=PVFramesBGR
-p few_shot_prompt_file:=${CONFIG_DIR}/llm_prompts/r18_steps_prompt

- pose_estimation: ros2 run angel_system_nodes pose_estimator --ros-args
-r __ns:=${ROS_NAMESPACE}
-p image_topic:=PVFramesBGR
Expand Down Expand Up @@ -203,7 +203,7 @@ windows:
--query_task_graph_topic=query_task_graph
--task_updates_topic=TaskUpdates
--activity_detections_topic=activity_topic
--task_errors_topic=TaskErrors
--task_errors_topic=ARUISystemNotifications

- feedback_generator: ros2 run angel_system_nodes feedback_generator --ros-args
-r __ns:=${ROS_NAMESPACE}
Expand Down
6 changes: 4 additions & 2 deletions tmux/demos/medical/Kitware-R18.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ windows:
-p config_file:=${CONFIG_DIR}/tasks/medical/multi-task-config-medical-r18.yaml
-p activity_config_file:=${CONFIG_DIR}/activity_labels/medical/r18.yaml
-p task_state_topic:=TaskUpdates
-p task_error_topic:=TaskErrors
-p task_error_topic:=ARUISystemNotifications
-p system_command_topic:=SystemCommands
-p det_topic:=activity_topic
-p model_file:=${MODEL_DIR}/task_monitor/global_step_predictor_act_avgs_R18.npy
Expand Down Expand Up @@ -158,7 +158,7 @@ windows:
--query_task_graph_topic=query_task_graph
--task_updates_topic=TaskUpdates
--activity_detections_topic=activity_topic
--task_errors_topic=TaskErrors
--task_errors_topic=ARUISystemNotifications

- feedback_generator: ros2 run angel_system_nodes feedback_generator --ros-args
-r __ns:=${ROS_NAMESPACE}
Expand All @@ -167,3 +167,5 @@ windows:
-p task_monitor_topic:=TaskUpdates
-p arui_update_topic:=AruiUpdates
-p interp_user_intent_topic:=UserIntentPredicted
-p system_text_response_topic:=SystemTextResponse
-p system_notification_topic:=ARUISystemNotifications
Loading