Skip to content

Commit 7df174d

Browse files
authored
Fix lifecycle teardown in tracking node (#107)
- Store message_filters subscribers as class members so they can be cleaned up correctly - Fix on_deactivate() to destroy the correct subscriptions and synchronizer - Prevent AttributeError during lifecycle transitions
1 parent 193c545 commit 7df174d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

yolo_ros/yolo_ros/tracking_node.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,15 @@ def on_activate(self, state: LifecycleState) -> TransitionCallbackReturn:
105105
)
106106

107107
# Subs
108-
image_sub = message_filters.Subscriber(
108+
self.image_sub = message_filters.Subscriber(
109109
self, Image, "image_raw", qos_profile=image_qos_profile
110110
)
111-
detections_sub = message_filters.Subscriber(
111+
self.detections_sub = message_filters.Subscriber(
112112
self, DetectionArray, "detections", qos_profile=10
113113
)
114114

115115
self._synchronizer = message_filters.ApproximateTimeSynchronizer(
116-
(image_sub, detections_sub), 10, 0.5
116+
(self.image_sub, self.detections_sub), 10, 0.5
117117
)
118118
self._synchronizer.registerCallback(self.detections_cb)
119119

0 commit comments

Comments
 (0)