Skip to content

Commit

Permalink
Add logic to activate processing at the appropriate time
Browse files Browse the repository at this point in the history
Added conditional activation of the runtime loop awake event depending on the
setting of the `self._window_lead_with_objects` attribute.
  • Loading branch information
Purg committed May 22, 2024
1 parent 2524eb8 commit 6dcfd9e
Showing 1 changed file with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -452,34 +452,37 @@ 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:
"""
Callback function for `ObjectDetection2dSet` messages. Runs the classifier,
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:
"""
Expand All @@ -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()

Expand Down

0 comments on commit 6dcfd9e

Please sign in to comment.