ActionClientBehaviorBase Class Template
A base class for behaviors which need to send a goal to a ROS action client and wait for a result. If the behavior is halted before the action result is received, the action goal will be canceled. More...
Declaration
class moveit_pro::behaviors::ActionClientBehaviorBase<ActionT> { ... }
Included Headers
Base class
| class | AsyncBehaviorBase |
|
A base class for behaviors which need to asynchronously run a function that might take a long time to complete. More... | |
Public Member Typedefs Index
template <typename ActionT> | |
| using | ClientGoalHandle = rclcpp_action::ClientGoalHandle< ActionT > |
Public Constructors Index
template <typename ActionT> | |
| ActionClientBehaviorBase (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< BehaviorContext > &shared_resources) | |
|
Constructs ActionClientBehaviorBase using the RclcppClientInterface. More... | |
template <typename ActionT> | |
| ActionClientBehaviorBase (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< BehaviorContext > &shared_resources, std::unique_ptr< ClientInterfaceBase > client_interface) | |
|
Constructs ActionClientBehaviorBase using a user-provided implementation of ClientInterfaceBase. More... | |
Public Destructor Index
template <typename ActionT> | |
| ~ActionClientBehaviorBase ()=default | |
Public Member Functions Index
template <typename ActionT> | |
| auto | getActionName ()=0 -> tl::expected< std::string, std::string > |
|
User-provided function to get the name of the action when initializing the action client. More... | |
template <typename ActionT> | |
| auto | getResultTimeout () -> tl::expected< std::chrono::duration< double >, std::string > |
|
Optional user-provided function to set the timeout used when waiting for the action result. More... | |
template <typename ActionT> | |
| auto | createGoal ()=0 -> tl::expected< typename ActionT::Goal, std::string > |
|
User-provided function to create the action goal before sending the action goal request. More... | |
template <typename ActionT> | |
| auto | processResult (const std::shared_ptr< typename ActionT::Result >) -> tl::expected< bool, std::string > |
|
Optional user-provided function to process the action result after the action has finished. More... | |
template <typename ActionT> | |
| void | processFeedback (const std::shared_ptr< const typename ActionT::Feedback >) |
|
Optional user-provided function to process feedback sent by the action server. More... | |
template <typename ActionT> | |
| std::string | getTimeoutMessage () const |
|
Optional user-provided function to retrieve and surface an error message when a timeout occurs before the goal result is returned. More... | |
template <typename ActionT> | |
| std::string | getServerUnavailableMessage (const std::string &action_name) const |
|
Optional user-provided function to retrieve and surface an error message when the action server is not available after waiting for the server timeout duration. More... | |
template <typename ActionT> | |
| std::string | getAbortedMessage (const std::shared_ptr< const typename ActionT::Result >) const |
|
Optional user-provided function to retrieve and surface an error message from an aborted action server result. More... | |
Private Member Functions Index
template <typename ActionT> | |
| auto | doWork () override -> tl::expected< bool, std::string > |
|
Handles executing the action. More... | |
template <typename ActionT> | |
| auto | doHalt () override -> tl::expected< void, std::string > |
|
Handles halting logic which is specific to the action client behavior implementation. More... | |
Private Member Attributes Index
template <typename ActionT> | |
| std::unique_ptr< ClientInterfaceBase > | client_interface_ |
|
Interface to the action client. More... | |
Description
A base class for behaviors which need to send a goal to a ROS action client and wait for a result. If the behavior is halted before the action result is received, the action goal will be canceled.
Important: If a halt is requested before the action goal request is sent to the action server or before the action goal response has been received from the action server, the behavior will wait to halt until the action goal response has been received then request that the action goal be canceled, and will finally wait until the in-progress action goal has finished.
- Template Parameters
-
ActionT ROS action message type used to specialize this class for a specific action
Definition at line 27 of file action_client_behavior_base.hpp.
Public Member Typedefs
ClientGoalHandle
|
Definition at line 30 of file action_client_behavior_base.hpp.
Public Constructors
ActionClientBehaviorBase()
|
Constructs ActionClientBehaviorBase using the RclcppClientInterface.
Declaration at line 171 of file action_client_behavior_base.hpp, definition at line 204 of file action_client_behavior_base_impl.hpp.
ActionClientBehaviorBase()
|
Constructs ActionClientBehaviorBase using a user-provided implementation of ClientInterfaceBase.
Declaration at line 175 of file action_client_behavior_base.hpp, definition at line 213 of file action_client_behavior_base_impl.hpp.
Public Destructor
~ActionClientBehaviorBase()
| virtual default |
Definition at line 179 of file action_client_behavior_base.hpp.
Public Member Functions
createGoal()
|
User-provided function to create the action goal before sending the action goal request.
- Returns
Returns an action goal message. If not successful, returns an error message. Note that the criteria for success or failure is defined by the user's implementation of this function.
Definition at line 205 of file action_client_behavior_base.hpp.
getAbortedMessage()
| inline virtual |
Optional user-provided function to retrieve and surface an error message from an aborted action server result.
If no user-defined implementation is provided, then this method will simply return "Action goal was aborted."
- Parameters
-
result Action result message to process.
Definition at line 259 of file action_client_behavior_base.hpp.
getActionName()
|
User-provided function to get the name of the action when initializing the action client.
- Returns
Returns the name of the action. If not successful, returns an error message. Note that the criteria for success or failure is defined by the user's implementation of this function.
Definition at line 186 of file action_client_behavior_base.hpp.
getResultTimeout()
| inline virtual |
Optional user-provided function to set the timeout used when waiting for the action result.
If no user-defined implementation is provided, the default implementation returns a negative duration, which will cause the action client to wait for the result without timing out.
- Returns
Returns the action result timeout duration. If not successful, returns an error message. Note that the criteria for success or failure is defined by the user's implementation of this function.
Definition at line 195 of file action_client_behavior_base.hpp.
getServerUnavailableMessage()
| inline virtual |
Optional user-provided function to retrieve and surface an error message when the action server is not available after waiting for the server timeout duration.
Override this in derived classes to provide context-specific guidance when the action server cannot be found. If no user-defined implementation is provided, then this method will return a generic error message.
Definition at line 249 of file action_client_behavior_base.hpp.
getTimeoutMessage()
| inline virtual |
Optional user-provided function to retrieve and surface an error message when a timeout occurs before the goal result is returned.
If no user-defined implementation is provided, then this method will simply return "Timed out waiting for action result. Action canceled."
Definition at line 238 of file action_client_behavior_base.hpp.
processFeedback()
| inline virtual |
Optional user-provided function to process feedback sent by the action server.
If no user-defined implementation is provided, then no additional processing will be performed on action feedback and this function will always return void.
- Parameters
-
feedback Action feedback message to process.
Definition at line 227 of file action_client_behavior_base.hpp.
processResult()
| inline virtual |
Optional user-provided function to process the action result after the action has finished.
If no user-defined implementation is provided, then no additional processing will be performed on succeeding action results and this function will always return true.
- Parameters
-
result Action result message to process.
- Returns
By default, always returns true. If a user-defined implementation of this function is provided, returns true or false if the result was processed successfully, or an error message if the result could not be processed. Note that the criteria for success or failure in this case is defined by the user's implementation of this function.
Definition at line 216 of file action_client_behavior_base.hpp.
Private Member Functions
doHalt()
| virtual |
Handles halting logic which is specific to the action client behavior implementation.
This cancels the in-progress action goal when the behavior is halted.
- Returns
Always return void, since there isn't anything special to do if the cancel request is rejected other than wait for doWork() to time out or finish on its own.
Declaration at line 284 of file action_client_behavior_base.hpp, definition at line 222 of file action_client_behavior_base_impl.hpp.
doWork()
| virtual |
Handles executing the action.
This function is called within an async process in a separate thread by AsyncBehaviorBase. It calls the user-defined getActionName, createGoal, and processResult functions to initialize the action server, create and send an action goal, and then handle the action result.
- Returns
-
A tl::expected which contains:
- True if the action finished and succeeded or was cancelled.
- False if the action finished and did not succeed.
- An error message if the action goal could not be created or send to the action server, or if the action result was not received from the action server.
Declaration at line 276 of file action_client_behavior_base.hpp, definition at line 230 of file action_client_behavior_base_impl.hpp.
Private Member Attributes
client_interface_
|
Interface to the action client.
Definition at line 287 of file action_client_behavior_base.hpp.
The documentation for this class was generated from the following files:
Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.9.8.