From 98e5912c5b8131982142b2a6a2da756406950f89 Mon Sep 17 00:00:00 2001 From: Mehul Goel Date: Wed, 23 Oct 2024 21:14:27 -0400 Subject: [PATCH] added subscriber and fixed --- rb_ws/src/buggy/buggy/watchdog/watchdog_node.py | 15 ++++++++++++--- rb_ws/src/buggy/setup.py | 4 ++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/rb_ws/src/buggy/buggy/watchdog/watchdog_node.py b/rb_ws/src/buggy/buggy/watchdog/watchdog_node.py index 2e536cb..6f238da 100644 --- a/rb_ws/src/buggy/buggy/watchdog/watchdog_node.py +++ b/rb_ws/src/buggy/buggy/watchdog/watchdog_node.py @@ -25,18 +25,27 @@ def loop(self): msg.data = True self.heartbeat_publisher.publish(msg) + def heartbeat_listener(self, msg : Node): + """ + Subscriber Function that checks if Heartbeat is ever alse + It never actually is false, this is just a demonstration of a subscriber + If it ever actually is false, something cursed has happened + """ + if msg.data == False: + self.get_logger().error("Hearbeat Failed!") + def main(args=None): rclpy.init(args=args) - minimal_publisher = Watchdog() + watchdog = Watchdog() - rclpy.spin(minimal_publisher) + rclpy.spin(watchdog) # Destroy the node explicitly # (optional - otherwise it will be done automatically # when the garbage collector destroys the node object) - minimal_publisher.destroy_node() + watchdog.destroy_node() rclpy.shutdown() diff --git a/rb_ws/src/buggy/setup.py b/rb_ws/src/buggy/setup.py index 5ecef4e..0a9e40b 100644 --- a/rb_ws/src/buggy/setup.py +++ b/rb_ws/src/buggy/setup.py @@ -13,7 +13,7 @@ ('share/ament_index/resource_index/packages', ['resource/' + package_name]), ('share/' + package_name, ['package.xml']), - (os.path.join("share", package_name), glob("launch/*.xml")), + (os.path.join("share", package_name), glob("launch/*.xml")) ], install_requires=['setuptools'], zip_safe=True, @@ -28,4 +28,4 @@ 'watchdog = buggy.watchdog.watchdog_node:main' ], }, -) +) \ No newline at end of file