Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Primary state error transitions #1064

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,14 @@ class LifecycleNode : public node_interfaces::LifecycleNodeInterface,
const State &
deactivate(LifecycleNodeInterface::CallbackReturn & cb_return_code);

RCLCPP_LIFECYCLE_PUBLIC
const State &
raise_error();

RCLCPP_LIFECYCLE_PUBLIC
const State &
raise_error(LifecycleNodeInterface::CallbackReturn & cb_return_code);

RCLCPP_LIFECYCLE_PUBLIC
const State &
shutdown();
Expand Down
22 changes: 22 additions & 0 deletions rclcpp_lifecycle/src/lifecycle_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,28 @@ LifecycleNode::deactivate(LifecycleNodeInterface::CallbackReturn & cb_return_cod
lifecycle_msgs::msg::Transition::TRANSITION_DEACTIVATE, cb_return_code);
}

const State &
LifecycleNode::raise_error()
{
if(get_current_state().id() == lifecycle_msgs::msg::State::PRIMARY_STATE_ACTIVE)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think this needs to be checked here. it will check the current state and get the reference to rcl_lifecycle_transition_t in rcl state_machine.

return impl_->trigger_transition(
lifecycle_msgs::msg::Transition::TRANSITION_ACTIVE_ERROR);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
lifecycle_msgs::msg::Transition::TRANSITION_ACTIVE_ERROR);
rcl_lifecycle_error_label);

else
return impl_->trigger_transition(
lifecycle_msgs::msg::Transition::TRANSITION_INACTIVE_ERROR);
}

const State &
LifecycleNode::raise_error(LifecycleNodeInterface::CallbackReturn & cb_return_code)
{
if(get_current_state().id() == lifecycle_msgs::msg::State::PRIMARY_STATE_ACTIVE)
return impl_->trigger_transition(
lifecycle_msgs::msg::Transition::TRANSITION_ACTIVE_ERROR, cb_return_code);
else
return impl_->trigger_transition(
lifecycle_msgs::msg::Transition::TRANSITION_INACTIVE_ERROR, cb_return_code);
}

const State &
LifecycleNode::shutdown()
{
Expand Down