30 #ifndef REALTIME_TOOLS__REALTIME_SERVER_GOAL_HANDLE_H 31 #define REALTIME_TOOLS__REALTIME_SERVER_GOAL_HANDLE_H 37 #include <boost/shared_ptr.hpp> 40 #include <actionlib/server/action_server.h> 45 template <
class Action>
73 preallocated_result_(preallocated_result),
74 preallocated_feedback_(preallocated_feedback)
76 if (!preallocated_result_)
77 preallocated_result_.reset(
new Result);
78 if (!preallocated_feedback_)
79 preallocated_feedback_.reset(
new Feedback);
82 void setAborted(ResultConstPtr result = ResultConstPtr((Result*)NULL))
84 if (!req_succeed_ && !req_abort_ && !req_cancel_)
91 void setCanceled(ResultConstPtr result = ResultConstPtr((Result*)NULL))
93 if (!req_succeed_ && !req_abort_ && !req_cancel_)
100 void setSucceeded(ResultConstPtr result = ResultConstPtr((Result*)NULL))
102 if (!req_succeed_ && !req_abort_ && !req_cancel_)
104 req_result_ = result;
109 void setFeedback(FeedbackConstPtr feedback = FeedbackConstPtr((Feedback*)NULL))
111 req_feedback_ = feedback;
116 return gh_.getGoal() != NULL;
121 using namespace actionlib_msgs;
124 actionlib_msgs::GoalStatus gs = gh_.getGoalStatus();
125 if (req_abort_ && (gs.status == GoalStatus::ACTIVE ||
126 gs.status == GoalStatus::PREEMPTING))
129 gh_.setAborted(*req_result_);
133 else if (req_cancel_ && gs.status == GoalStatus::PREEMPTING)
136 gh_.setCanceled(*req_result_);
140 else if (req_succeed_ && (gs.status == GoalStatus::ACTIVE ||
141 gs.status == GoalStatus::PREEMPTING))
144 gh_.setSucceeded(*req_result_);
148 if (req_feedback_ && gs.status == GoalStatus::ACTIVE)
150 gh_.publishFeedback(*req_feedback_);
158 #endif // header guard