Above talks about shutting down nodes in rospy how do I do proper clean up in rclpy.
I tried:
def shutdown_nodes(self):
self.get_logger().info("Shutting down the node and ROS.")
shutdown_message = Bool(data=True)
self.shutdown_publisher.publish(shutdown_message)
rclpy.shutdown()
def main():
rclpy.init()
learning_ddpg = LearningDDPG()
rclpy.spin(learning_ddpg)
learning_ddpg.destroy_node()
rclpy.shutdown()
But i got error:
rclpy.spin(learning_ddpg)
File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/__init__.py", line 218, in spin
executor = get_global_executor() if executor is None else executor
File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/__init__.py", line 102, in get_global_executor
__executor = SingleThreadedExecutor()
File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 721, in __init__
super().__init__(context=context)
File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 172, in __init__
self._guard = GuardCondition(
File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/guard_condition.py", line 23, in __init__
with self._context.handle:
AttributeError: __enter__
Exception ignored in: <function Executor.__del__ at 0x78d0a3ce17e0>
Traceback (most recent call last):
File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 243, in __del__
if self._sigint_gc is not None:
AttributeError: 'SingleThreadedExecutor' object has no attribute '_sigint_gc'
[ros2run]: Process exited with failure 1