15 #ifndef RCLCPP_ACTION__SERVER_HPP_ 16 #define RCLCPP_ACTION__SERVER_HPP_ 19 #include <rosidl_generator_c/action_type_support_struct.h> 20 #include <rosidl_typesupport_cpp/action_type_support.hpp> 30 #include <unordered_map> 83 get_number_of_ready_subscriptions()
override;
89 get_number_of_ready_timers()
override;
95 get_number_of_ready_clients()
override;
101 get_number_of_ready_services()
override;
107 get_number_of_ready_guard_conditions()
override;
133 rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_base,
134 rclcpp::node_interfaces::NodeClockInterface::SharedPtr node_clock,
135 rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr node_logging,
137 const rosidl_action_type_support_t * type_support,
158 call_handle_cancel_callback(
const GoalUUID & uuid) = 0;
165 get_goal_id_from_goal_request(
void * message) = 0;
172 create_goal_request() = 0;
179 call_goal_accepted_callback(
188 get_goal_id_from_result_request(
void * message) = 0;
195 create_result_request() = 0;
202 create_result_response(decltype(action_msgs::msg::GoalStatus::status) status) = 0;
212 notify_goal_terminal_state();
232 execute_goal_request_received();
238 execute_cancel_request_received();
244 execute_result_request_received();
250 execute_check_expired_goals();
267 template<
typename ActionT>
308 rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_base,
309 rclcpp::node_interfaces::NodeClockInterface::SharedPtr node_clock,
310 rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr node_logging,
322 rosidl_typesupport_cpp::get_action_type_support_handle<ActionT>(),
324 handle_goal_(handle_goal),
325 handle_cancel_(handle_cancel),
326 handle_accepted_(handle_accepted)
330 virtual ~
Server() =
default;
341 typename ActionT::Impl::SendGoalService::Request>(message);
345 auto ros_response = std::make_shared<typename ActionT::Impl::SendGoalService::Response>();
357 auto element = goal_handles_.find(uuid);
358 if (element != goal_handles_.end()) {
361 resp = handle_cancel_(goal_handle);
363 goal_handle->_cancel_goal();
387 shared_this->publish_result(uuid, result_message);
389 shared_this->publish_status();
391 shared_this->notify_goal_terminal_state();
394 shared_this->goal_handles_.erase(uuid);
406 shared_this->publish_status();
416 shared_this->publish_feedback(std::static_pointer_cast<void>(feedback_msg));
420 const typename ActionT::Impl::SendGoalService::Request>(goal_request_message);
424 rcl_goal_handle, uuid, goal, on_terminal_state, on_executing, publish_feedback));
427 goal_handles_[uuid] = goal_handle;
429 handle_accepted_(goal_handle);
437 static_cast<typename ActionT::Impl::SendGoalService::Request *
>(message)->goal_id.uuid;
452 static_cast<typename ActionT::Impl::GetResultService::Request *
>(message)->goal_id.uuid;
466 auto result = std::make_shared<typename ActionT::Impl::GetResultService::Response>();
467 result->status = status;
486 #endif // RCLCPP_ACTION__SERVER_HPP_ GoalUUID get_goal_id_from_goal_request(void *message) override
Definition: server.hpp:434
CancelResponse call_handle_cancel_callback(const GoalUUID &uuid) override
Definition: server.hpp:353
std::pair< GoalResponse, std::shared_ptr< void > > call_handle_goal_callback(GoalUUID &uuid, std::shared_ptr< void > message) override
Definition: server.hpp:338
GoalResponse
A response returned by an action server callback when a goal is requested.
Definition: server.hpp:43
std::shared_ptr< void > create_result_response(decltype(action_msgs::msg::GoalStatus::status) status) override
Definition: server.hpp:464
GoalUUID get_goal_id_from_result_request(void *message) override
Definition: server.hpp:449
void call_goal_accepted_callback(std::shared_ptr< rcl_action_goal_handle_t > rcl_goal_handle, GoalUUID uuid, std::shared_ptr< void > goal_request_message) override
Definition: server.hpp:372
CancelResponse
A response returned by an action server callback when a goal has been asked to be canceled...
Definition: server.hpp:54
Action Server.
Definition: server.hpp:268
The server has agreed to try to cancel the goal.
Class to interact with goals on a server.
Definition: server_goal_handle.hpp:135
Definition: server.hpp:70
The goal is rejected and will not be executed.
std::shared_ptr< void > create_goal_request() override
Definition: server.hpp:442
T static_pointer_cast(T... args)
Server(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_base, rclcpp::node_interfaces::NodeClockInterface::SharedPtr node_clock, rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr node_logging, const std::string &name, const rcl_action_server_options_t &options, GoalCallback handle_goal, CancelCallback handle_cancel, AcceptedCallback handle_accepted)
Construct an action server.
Definition: server.hpp:307
#define RCLCPP_ACTION_PUBLIC
Definition: visibility_control.hpp:50
#define RCLCPP_SMART_PTR_DEFINITIONS_NOT_COPYABLE(...)
std::shared_ptr< void > create_result_request() override
Definition: server.hpp:457
The server accepts the goal, and is going to execute it later.
Definition: client.hpp:44
The server accepts the goal, and is going to begin execution immediately.