File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -152,10 +152,9 @@ LifecycleNode::LifecycleNode(
152152
153153LifecycleNode::~LifecycleNode ()
154154{
155- // shutdown if necessary to avoid leaving the device in unknown state
156- if (LifecycleNode::get_current_state ().id () !=
157- lifecycle_msgs::msg::State::PRIMARY_STATE_FINALIZED)
158- {
155+ auto current_state = LifecycleNode::get_current_state ().id ();
156+ // shutdown if necessary to avoid leaving the device in any other primary state
157+ if (current_state < lifecycle_msgs::msg::State::PRIMARY_STATE_FINALIZED) {
159158 auto ret = rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn::ERROR;
160159 auto finalized = LifecycleNode::shutdown (ret);
161160 if (finalized.id () != lifecycle_msgs::msg::State::PRIMARY_STATE_FINALIZED ||
@@ -166,6 +165,11 @@ LifecycleNode::~LifecycleNode()
166165 " Shutdown error in destruction of LifecycleNode: final state(%s)" ,
167166 finalized.label ().c_str ());
168167 }
168+ } else if (current_state > lifecycle_msgs::msg::State::PRIMARY_STATE_FINALIZED) {
169+ RCLCPP_WARN (
170+ rclcpp::get_logger (" rclcpp_lifecycle" ),
171+ " Cannot shutdown the LifecycleNode in transition state(%u)" ,
172+ current_state);
169173 }
170174
171175 // release sub-interfaces in an order that allows them to consult with node_base during tear-down
You can’t perform that action at this time.
0 commit comments