15 #ifndef RCLCPP_ACTION__CLIENT_GOAL_HANDLE_IMPL_HPP_
16 #define RCLCPP_ACTION__CLIENT_GOAL_HANDLE_IMPL_HPP_
18 #include <rcl_action/types.h>
29 template<
typename ActionT>
30 ClientGoalHandle<ActionT>::ClientGoalHandle(
31 const GoalInfo & info, FeedbackCallback feedback_callback, ResultCallback result_callback)
33 result_future_(result_promise_.get_future()),
34 feedback_callback_(feedback_callback),
35 result_callback_(result_callback)
39 template<
typename ActionT>
44 template<
typename ActionT>
48 return info_.goal_id.uuid;
51 template<
typename ActionT>
58 template<
typename ActionT>
63 if (!is_result_aware_) {
66 return result_future_;
69 template<
typename ActionT>
71 ClientGoalHandle<ActionT>::set_result(
const WrappedResult & wrapped_result)
74 status_ =
static_cast<int8_t
>(wrapped_result.code);
75 result_promise_.set_value(wrapped_result);
76 if (result_callback_) {
77 result_callback_(wrapped_result);
81 template<
typename ActionT>
83 ClientGoalHandle<ActionT>::set_feedback_callback(FeedbackCallback callback)
86 feedback_callback_ = callback;
89 template<
typename ActionT>
91 ClientGoalHandle<ActionT>::set_result_callback(ResultCallback callback)
94 result_callback_ = callback;
97 template<
typename ActionT>
105 template<
typename ActionT>
113 template<
typename ActionT>
118 return feedback_callback_ !=
nullptr;
121 template<
typename ActionT>
126 return is_result_aware_;
129 template<
typename ActionT>
134 bool previous = is_result_aware_;
135 is_result_aware_ = awareness;
139 template<
typename ActionT>
141 ClientGoalHandle<ActionT>::invalidate(
const exceptions::UnawareGoalHandleError & ex)
145 if (is_invalidated()) {
148 is_result_aware_ =
false;
150 status_ = GoalStatus::STATUS_UNKNOWN;
151 result_promise_.set_exception(invalidate_exception_);
154 template<
typename ActionT>
156 ClientGoalHandle<ActionT>::is_invalidated()
const
158 return invalidate_exception_ !=
nullptr;
161 template<
typename ActionT>
163 ClientGoalHandle<ActionT>::call_feedback_callback(
164 typename ClientGoalHandle<ActionT>::SharedPtr shared_this,
167 if (shared_this.get() !=
this) {
172 if (
nullptr == feedback_callback_) {
177 feedback_callback_(shared_this, feedback_message);
182 #endif // RCLCPP_ACTION__CLIENT_GOAL_HANDLE_IMPL_HPP_