rclcpp_action  master
C++ ROS Action Client Library
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
rclcpp_action::ServerGoalHandle< ActionT > Class Template Reference

Class to interact with goals on a server. More...

#include <server_goal_handle.hpp>

Inheritance diagram for rclcpp_action::ServerGoalHandle< ActionT >:
Inheritance graph
[legend]
Collaboration diagram for rclcpp_action::ServerGoalHandle< ActionT >:
Collaboration graph
[legend]

Public Member Functions

void publish_feedback (std::shared_ptr< typename ActionT::Feedback > feedback_msg)
 Send an update about the progress of a goal. More...
 
void abort (typename ActionT::Result::SharedPtr result_msg)
 Indicate that a goal could not be reached and has been aborted. More...
 
void succeed (typename ActionT::Result::SharedPtr result_msg)
 Indicate that a goal has succeeded. More...
 
void canceled (typename ActionT::Result::SharedPtr result_msg)
 Indicate that a goal has been canceled. More...
 
void execute ()
 Indicate that the server is starting to execute a goal. More...
 
const std::shared_ptr< const typename ActionT::Goal > get_goal () const
 Get the user provided message describing the goal. More...
 
const GoalUUIDget_goal_id () const
 Get the unique identifier of the goal. More...
 
virtual ~ServerGoalHandle ()
 
- Public Member Functions inherited from rclcpp_action::ServerGoalHandleBase
RCLCPP_ACTION_PUBLIC bool is_canceling () const
 
RCLCPP_ACTION_PUBLIC bool is_active () const
 
RCLCPP_ACTION_PUBLIC bool is_executing () const
 
virtual RCLCPP_ACTION_PUBLIC ~ServerGoalHandleBase ()
 

Protected Member Functions

 ServerGoalHandle (std::shared_ptr< rcl_action_goal_handle_t > rcl_handle, GoalUUID uuid, std::shared_ptr< const typename ActionT::Goal > goal, std::function< void(const GoalUUID &, std::shared_ptr< void >)> on_terminal_state, std::function< void(const GoalUUID &)> on_executing, std::function< void(std::shared_ptr< typename ActionT::Impl::FeedbackMessage >)> publish_feedback)
 
- Protected Member Functions inherited from rclcpp_action::ServerGoalHandleBase
RCLCPP_ACTION_PUBLIC ServerGoalHandleBase (std::shared_ptr< rcl_action_goal_handle_t > rcl_handle)
 
RCLCPP_ACTION_PUBLIC void _abort ()
 
RCLCPP_ACTION_PUBLIC void _succeed ()
 
RCLCPP_ACTION_PUBLIC void _cancel_goal ()
 
RCLCPP_ACTION_PUBLIC void _canceled ()
 
RCLCPP_ACTION_PUBLIC void _execute ()
 
RCLCPP_ACTION_PUBLIC bool try_canceling () noexcept
 

Protected Attributes

const std::shared_ptr< const typename ActionT::Goal > goal_
 The user provided message describing the goal. More...
 
const GoalUUID uuid_
 A unique id for the goal request. More...
 
friend Server< ActionT >
 
std::function< void(const GoalUUID &, std::shared_ptr< void >)> on_terminal_state_
 
std::function< void(const GoalUUID &)> on_executing_
 
std::function< void(std::shared_ptr< typename ActionT::Impl::FeedbackMessage >)> publish_feedback_
 

Detailed Description

template<typename ActionT>
class rclcpp_action::ServerGoalHandle< ActionT >

Class to interact with goals on a server.

Use this class to check the status of a goal as well as set the result.

This class is not meant to be created by a user, instead it is created when a goal has been accepted. A Server will create an instance and give it to the user in their handle_accepted callback.

Internally, this class is responsible for coverting between the C++ action type and generic types for rclcpp_action::ServerGoalHandleBase.

Constructor & Destructor Documentation

◆ ~ServerGoalHandle()

template<typename ActionT >
virtual rclcpp_action::ServerGoalHandle< ActionT >::~ServerGoalHandle ( )
inlinevirtual

◆ ServerGoalHandle()

template<typename ActionT >
rclcpp_action::ServerGoalHandle< ActionT >::ServerGoalHandle ( std::shared_ptr< rcl_action_goal_handle_t rcl_handle,
GoalUUID  uuid,
std::shared_ptr< const typename ActionT::Goal >  goal,
std::function< void(const GoalUUID &, std::shared_ptr< void >)>  on_terminal_state,
std::function< void(const GoalUUID &)>  on_executing,
std::function< void(std::shared_ptr< typename ActionT::Impl::FeedbackMessage >)>  publish_feedback 
)
inlineprotected

Member Function Documentation

◆ publish_feedback()

template<typename ActionT >
void rclcpp_action::ServerGoalHandle< ActionT >::publish_feedback ( std::shared_ptr< typename ActionT::Feedback >  feedback_msg)
inline

Send an update about the progress of a goal.

This must only be called when the goal is executing. If execution of a goal is deferred then ServerGoalHandle::set_executing() must be called first.

Exceptions
std::runtime_errorIf the goal is in any state besides executing.
Parameters
[in]feedback_msgthe message to publish to clients.

◆ abort()

template<typename ActionT >
void rclcpp_action::ServerGoalHandle< ActionT >::abort ( typename ActionT::Result::SharedPtr  result_msg)
inline

Indicate that a goal could not be reached and has been aborted.

Only call this if the goal was executing but cannot be completed. This is a terminal state, no more methods should be called on a goal handle after this is called.

Exceptions
rclcpp::exceptions::RCLErrorIf the goal is in any state besides executing.
Parameters
[in]result_msgthe final result to send to clients.

◆ succeed()

template<typename ActionT >
void rclcpp_action::ServerGoalHandle< ActionT >::succeed ( typename ActionT::Result::SharedPtr  result_msg)
inline

Indicate that a goal has succeeded.

Only call this if the goal is executing and has reached the desired final state. This is a terminal state, no more methods should be called on a goal handle after this is called.

Exceptions
rclcpp::exceptions::RCLErrorIf the goal is in any state besides executing.
Parameters
[in]result_msgthe final result to send to clients.

◆ canceled()

template<typename ActionT >
void rclcpp_action::ServerGoalHandle< ActionT >::canceled ( typename ActionT::Result::SharedPtr  result_msg)
inline

Indicate that a goal has been canceled.

Only call this if the goal is executing or pending, but has been canceled. This is a terminal state, no more methods should be called on a goal handle after this is called.

Exceptions
rclcpp::exceptions::RCLErrorIf the goal is in any state besides executing.
Parameters
[in]result_msgthe final result to send to clients.

◆ execute()

template<typename ActionT >
void rclcpp_action::ServerGoalHandle< ActionT >::execute ( )
inline

Indicate that the server is starting to execute a goal.

Only call this if the goal is pending.

Exceptions
rclcpp::exceptions::RCLErrorIf the goal is in any state besides executing.

◆ get_goal()

template<typename ActionT >
const std::shared_ptr<const typename ActionT::Goal> rclcpp_action::ServerGoalHandle< ActionT >::get_goal ( ) const
inline

Get the user provided message describing the goal.

◆ get_goal_id()

template<typename ActionT >
const GoalUUID& rclcpp_action::ServerGoalHandle< ActionT >::get_goal_id ( ) const
inline

Get the unique identifier of the goal.

Member Data Documentation

◆ goal_

template<typename ActionT >
const std::shared_ptr<const typename ActionT::Goal> rclcpp_action::ServerGoalHandle< ActionT >::goal_
protected

The user provided message describing the goal.

◆ uuid_

template<typename ActionT >
const GoalUUID rclcpp_action::ServerGoalHandle< ActionT >::uuid_
protected

A unique id for the goal request.

◆ Server< ActionT >

template<typename ActionT >
friend rclcpp_action::ServerGoalHandle< ActionT >::Server< ActionT >
protected

◆ on_terminal_state_

template<typename ActionT >
std::function<void(const GoalUUID &, std::shared_ptr<void>)> rclcpp_action::ServerGoalHandle< ActionT >::on_terminal_state_
protected

◆ on_executing_

template<typename ActionT >
std::function<void(const GoalUUID &)> rclcpp_action::ServerGoalHandle< ActionT >::on_executing_
protected

◆ publish_feedback_

template<typename ActionT >
std::function<void(std::shared_ptr<typename ActionT::Impl::FeedbackMessage>)> rclcpp_action::ServerGoalHandle< ActionT >::publish_feedback_
protected

The documentation for this class was generated from the following file: