ROS2 Managed node: on_error
Hi,
writing the code to manage the "Error Processing" transition I can read the "previous" primary state, but I cannot know if the error has been generated during a transition state.
To be mode clear: if I am in "INACTIVE" state and I receive an "ACTIVATE" command I enter in the transition callback on_activate
.
If during the activation process an error happens I return TRANSITION_CALLBACK_ERROR
and I enter in the on_error
callback.
The parameter const rclcpp_lifecycle::State& previous_state
of the on_error
callback is set to PRIMARY_STATE_INACTIVE
and not to TRANSITION_STATE_ACTIVATING
.
In this particular case I cannot know if I've entered the on_error
callback from TRANSITION_STATE_ACTIVATING
, from TRANSITION_STATE_CLEANINGUP
or from PRIMARY_STATE_INACTIVE
.
Is there a "smart" way to know where I entered the ERROR PROCESSING
transition state?
I'm using a variable that keep tracks of the previous transition state, but it is not a stable way to understand who generated the error since I can enter the callback also from a primary state...
Thank you Walter
It looks like this is an oversight in the design of the API, I'd recommend opening an issue on ros2/rcl specifically about this. Thanks for the detailed description of the issue you're having. @Karsten FYI
The issue has been opened the last month, but in the ros2/rclcpp repository: https://github.com/ros2/rclcpp/issues...
I noticed that the
transition_event
topic is well done since it containsstart_state
andgoal_state
information. It is a good example of what is really useful