Skip to content

Commit

Permalink
move header setup to right before publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
josephvanpeltkw committed Oct 16, 2024
1 parent 45df6c9 commit f948c24
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -642,8 +642,12 @@ def rt_loop(self):
act_msg = self._process_window(window)
# log.info(f"activity message: {act_msg}")
self._collect_results(act_msg)
# overwriting this time to make sure the msg time is post inference
# set the header right before publishing so that the time is post image processing
act_msg.header.frame_id = "Activity Classification"
act_msg.header.stamp = self.get_clock().now().to_msg()
act_msg.source_stamp_start_frame = window.frames[0][0]
act_msg.source_stamp_end_frame = window.frames[-1][0]
act_msg.label_vec = self._model.classes
self._activity_publisher.publish(act_msg)
except NoActivityClassification:
# No ramifications, but don't publish activity message.
Expand Down Expand Up @@ -794,13 +798,8 @@ def _process_window(self, window: InputWindow) -> ActivityDetection:

# Prepare output message
activity_msg = ActivityDetection()
activity_msg.header.frame_id = "Activity Classification"
activity_msg.header.stamp = (
self.get_clock().now().to_msg()
) # note: this will be overwritten later (post inference)
activity_msg.source_stamp_start_frame = window.frames[0][0]
activity_msg.source_stamp_end_frame = window.frames[-1][0]
activity_msg.label_vec = self._model.classes

# save the activity probabilities
activity_msg.conf_vec = proba.tolist()

if self._enable_trace_logging:
Expand Down

0 comments on commit f948c24

Please sign in to comment.