root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 run lifecycle lifecycle_talker
^C[INFO] [1717052032.575390927] [rclcpp]: signal_handler(signum=2)
[ERROR] [1717052032.577706294] [lc_talker]: Unable to start transition 5 from current state shuttingdown: Could not publish transition: publisher's context is invalid, at /root/ros2_ws/colcon_ws/src/ros2/rcl/rcl/src/rcl/publisher.c:423, at /root/ros2_ws/colcon_ws/src/ros2/rcl/rcl_lifecycle/src/rcl_lifecycle.c:368
[WARN] [1717052032.577764887] [rclcpp_lifecycle]: Shutdown error in destruction of LifecycleNode: final state(unconfigured)
this is because the shutdown in the dtor is called but failed to publish the transition since the context is not valid.
i thought of a couple of things, but at this moment, i would like to label it with TODO.
add the context shutdown callback with weak_ptr lifecyclenode. so that even with graceful shutdown, context shutdown callback will be calling the lifecyclenode::shutdown properly.
add shutdown without publishing the transition. lifecycnode itself needs to be shutdown to avoid leaving the device or sensor in unknown state. we can call this method when the context is invalid.
https://github.com/ros2/rclcpp/pull/2528 generates the following error when the context is gracefully shutdown. (e.g deferred signal handler of rclcpp.)
this is because the shutdown in the dtor is called but failed to publish the transition since the context is not valid.
i thought of a couple of things, but at this moment, i would like to label it with
TODO
.shutdown
without publishing the transition. lifecycnode itself needs to be shutdown to avoid leaving the device or sensor in unknown state. we can call this method when the context is invalid.This also addresses https://github.com/ros2/rclcpp/issues/2547 (Nav2 CI finds this behavior)