From fcd39396274df164e926b906cae8dc929d16608f Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Sun, 11 Dec 2022 19:39:01 +0100 Subject: [PATCH] fix threading shutdown --- .../src/camera_calibration/camera_calibrator.py | 7 +++---- .../src/camera_calibration/nodes/cameracalibrator.py | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/camera_calibration/src/camera_calibration/camera_calibrator.py b/camera_calibration/src/camera_calibration/camera_calibrator.py index d1b0bdfbb..a858accae 100755 --- a/camera_calibration/src/camera_calibration/camera_calibrator.py +++ b/camera_calibration/src/camera_calibration/camera_calibrator.py @@ -86,7 +86,7 @@ def __init__(self, queue, function): self.function = function def run(self): - while True: + while rclpy.ok(): m = self.queue.get() self.function(m) @@ -259,10 +259,9 @@ def __init__(self, *args, **kwargs): def spin(self): sth = SpinThread(self) - sth.setDaemon(True) sth.start() - while True: + while rclpy.ok(): if self.queue_display.qsize() > 0: self.image = self.queue_display.get() cv2.imshow("display", self.image) @@ -270,7 +269,7 @@ def spin(self): time.sleep(0.1) k = cv2.waitKey(6) & 0xFF if k in [27, ord('q')]: - rclpy.shutdown() + return elif k == ord('s') and self.image is not None: self.screendump(self.image) diff --git a/camera_calibration/src/camera_calibration/nodes/cameracalibrator.py b/camera_calibration/src/camera_calibration/nodes/cameracalibrator.py index 4dde075d4..df08e2706 100755 --- a/camera_calibration/src/camera_calibration/nodes/cameracalibrator.py +++ b/camera_calibration/src/camera_calibration/nodes/cameracalibrator.py @@ -224,6 +224,7 @@ def main(): checkerboard_flags=checkerboard_flags, max_chessboard_speed=options.max_chessboard_speed, queue_size=options.queue_size) node.spin() + rclpy.shutdown() if __name__ == "__main__": try: