Template Class ActionServer
- Defined in File action_server.hpp 
Class Documentation
- 
template<typename ActionT>
 class ActionServer
- An action server wrapper to make applications simpler using Actions. - Public Types - 
typedef std::function<void()> ExecuteCallback
 - 
typedef std::function<void()> CompletionCallback
 - Public Functions - 
template<typename NodeT>
 inline explicit ActionServer(NodeT node, const std::string &action_name, ExecuteCallback execute_callback, CompletionCallback completion_callback = nullptr, std::chrono::milliseconds server_timeout = std::chrono::milliseconds(500), bool spin_thread = false, const rcl_action_server_options_t &options = rcl_action_server_get_default_options())
- An constructor for ActionServer. - Parameters:
- node – Ptr to node to make actions 
- action_name – Name of the action to call 
- execute_callback – Execution callback function of Action 
- server_timeout – Timeout to to react to stop or preemption requests 
- spin_thread – Whether to spin with a dedicated thread internally 
- options – Options to pass to the underlying rcl_action_server_t 
 
 
 - An constructor for ActionServer. - Parameters:
- <node – interfaces> Abstract node interfaces to make actions 
- action_name – Name of the action to call 
- execute_callback – Execution callback function of Action 
- server_timeout – Timeout to to react to stop or preemption requests 
- spin_thread – Whether to spin with a dedicated thread internally 
- options – Options to pass to the underlying rcl_action_server_t 
 
 
 - handle the goal requested: accept or reject. This implementation always accepts. - Parameters:
- uuid – Goal ID 
- Goal – A shared pointer to the specific goal 
 
- Returns:
- GoalResponse response of the goal processed 
 
 - Accepts cancellation requests of action server. - Parameters:
- uuid – Goal ID 
- Goal – A server goal handle to cancel 
 
- Returns:
- CancelResponse response of the goal cancelled 
 
 - Handles accepted goals and adds to preempted queue to switch to. - Parameters:
- Goal – A server goal handle to cancel 
 
 - 
inline void work()
- Computed background work and processes stop requests. 
 - 
inline void activate()
- Active action server. 
 - 
inline void deactivate()
- Deactive action server. 
 - 
inline bool is_running()
- Whether the action server is munching on a goal. - Returns:
- bool If its running or not 
 
 - 
inline bool is_server_active()
- Whether the action server is active or not. - Returns:
- bool If its active or not 
 
 - 
inline bool is_preempt_requested() const
- Whether the action server has been asked to be preempted with a new goal. - Returns:
- bool If there’s a preemption request or not 
 
 - 
inline const std::shared_ptr<const typename ActionT::Goal> accept_pending_goal()
- Accept pending goals. - Returns:
- Goal Ptr to the goal that’s going to be accepted 
 
 - 
inline void terminate_pending_goal()
- Terminate pending goals. 
 - 
inline const std::shared_ptr<const typename ActionT::Goal> get_current_goal() const
- Get the current goal object. - Returns:
- Goal Ptr to the goal that’s being processed currently 
 
 - 
inline const std::shared_ptr<const typename ActionT::Goal> get_pending_goal() const
- Get the pending goal object. - Returns:
- Goal Ptr to the goal that’s pending 
 
 - 
inline bool is_cancel_requested() const
- Whether or not a cancel command has come in. - Returns:
- bool Whether a cancel command has been requested or not 
 
 - Terminate all pending and active actions. - Parameters:
- result – A result object to send to the terminated actions 
 
 - Terminate the active action. - Parameters:
- result – A result object to send to the terminated action 
 
 - Return success of the active action. - Parameters:
- result – A result object to send to the terminated actions 
 
 - Publish feedback to the action server clients. - Parameters:
- feedback – A feedback object to send to the clients 
 
 - Protected Functions - 
inline constexpr auto empty_result() const
- Generate an empty result object for an action type. 
 - Whether a given goal handle is currently active. - Parameters:
- handle – Goal handle to check 
- Returns:
- Whether this goal handle is active 
 
 - Terminate a particular action with a result. - Parameters:
- handle – goal handle to terminate 
- the – Results object to terminate the action with 
 
 
 - 
inline void info_msg(const std::string &msg) const
- Info logging. 
 - 
inline void debug_msg(const std::string &msg) const
- Debug logging. 
 - 
inline void error_msg(const std::string &msg) const
- Error logging. 
 - 
inline void warn_msg(const std::string &msg) const
- Warn logging. 
 - Protected Attributes - 
rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_base_interface_
 - 
rclcpp::node_interfaces::NodeClockInterface::SharedPtr node_clock_interface_
 - 
rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr node_logging_interface_
 - 
rclcpp::node_interfaces::NodeWaitablesInterface::SharedPtr node_waitables_interface_
 - 
std::string action_name_
 - 
ExecuteCallback execute_callback_
 - 
CompletionCallback completion_callback_
 - 
std::future<void> execution_future_
 - 
bool stop_execution_ = {false}
 - 
mutable std::recursive_mutex update_mutex_
 - 
bool server_active_ = {false}
 - 
bool preempt_requested_ = {false}
 - 
std::chrono::milliseconds server_timeout_
 - 
bool spin_thread_
 - 
rclcpp::CallbackGroup::SharedPtr callback_group_ = {nullptr}
 - 
rclcpp::executors::SingleThreadedExecutor::SharedPtr executor_
 - 
std::unique_ptr<utils::NodeThread> executor_thread_
 
- 
typedef std::function<void()> ExecuteCallback