From 6dcfd9e164f4d9a2560efbe3bfae1187fe22e039 Mon Sep 17 00:00:00 2001 From: Paul Tunison Date: Wed, 22 May 2024 16:28:50 -0400 Subject: [PATCH] Add logic to activate processing at the appropriate time Added conditional activation of the runtime loop awake event depending on the setting of the `self._window_lead_with_objects` attribute. --- .../activity_classifier_tcn.py | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/ros/angel_system_nodes/angel_system_nodes/activity_classification/activity_classifier_tcn.py b/ros/angel_system_nodes/angel_system_nodes/activity_classification/activity_classifier_tcn.py index 1672ea8c4..0ca3c56b9 100644 --- a/ros/angel_system_nodes/angel_system_nodes/activity_classification/activity_classifier_tcn.py +++ b/ros/angel_system_nodes/angel_system_nodes/activity_classification/activity_classifier_tcn.py @@ -452,16 +452,17 @@ def img_ts_callback(self, msg: Time) -> None: Capture a detection source image timestamp message. """ log = self.get_logger() - # log.info("image call back") - # log.info(f"self.rt_alive(): {self.rt_alive()}") - # log.info(f"self._buffer.queue_image(None, msg): {self._buffer.queue_image(None, msg)}") self._current_frame_number += 1 if self.rt_alive() and self._buffer.queue_image(None, msg, self._current_frame_number): if self._enable_trace_logging: log.info(f"Queueing image TS {msg} frame {self._current_frame_number}") - # Let the runtime know we've queued something. - # Only triggering here as a new image frame (TS) is the - # self._rt_awake_evt.set() + + # If we are configured to prefer the latest image received as the + # latest image in the processing window, indicate the runtime upon + # receiving new images that it should try to process a window now. + if not self._window_lead_with_objects: + # Let the runtime know we've queued something. + self._rt_awake_evt.set() def det_callback(self, msg: ObjectDetection2dSet) -> None: """ @@ -469,17 +470,19 @@ def det_callback(self, msg: ObjectDetection2dSet) -> None: creates an `ActivityDetection` message from the results the classifier, and publish the `ActivityDetection` message. """ - if self.rt_alive() and self._buffer.queue_object_detections(msg): if self._enable_trace_logging: self.get_logger().info( f"Queueing object detections (ts={msg.header.stamp}, source_stamp_time={msg.source_stamp})" ) - # self.get_logger().info(f"message contents: {msg}") - # self.get_logger().info(f"buffer contents: {self._buffer.obj_dets}") - # Let the runtime know we've queued something. - self._rt_awake_evt.set() + # If we are configured to prefer the most recent image with object + # detections associated with it as the latest image in the + # processing window, indicate the runtime upon receiving new object + # detections received that it should try to process a window now. + if self._window_lead_with_objects: + # Let the runtime know we've queued something. + self._rt_awake_evt.set() def pose_callback(self, msg: HandJointPosesUpdate) -> None: """ @@ -492,7 +495,7 @@ def pose_callback(self, msg: HandJointPosesUpdate) -> None: self.get_logger().info( f"Queueing pose estimations (ts={msg.header.stamp}, source_stamp_time={msg.source_stamp})" ) - # self.get_logger().info(f"message contents: {msg}") + # Let the runtime know we've queued something. # self._rt_awake_evt.set()