Override destroy_node to clean up threads
(self)
| 578 | self.get_logger().info("Keyboard input thread exiting") |
| 579 | |
| 580 | def destroy_node(self): |
| 581 | """Override destroy_node to clean up threads""" |
| 582 | self.get_logger().info("Shutting down MotionDAR node...") |
| 583 | |
| 584 | # Signal thread to shutdown |
| 585 | if self._shutdown_event: |
| 586 | self._shutdown_event.set() |
| 587 | |
| 588 | # Wait for thread to finish (with timeout) |
| 589 | if self._keyboard_thread and self._keyboard_thread.is_alive(): |
| 590 | self._keyboard_thread.join(timeout=1.0) |
| 591 | if self._keyboard_thread.is_alive(): |
| 592 | print( |
| 593 | "Warning: Keyboard input thread did not shutdown gracefully" |
| 594 | ) |
| 595 | |
| 596 | super().destroy_node() |
| 597 | |
| 598 | |
| 599 |