37 #ifndef QUEUED_ACTION_SERVER_IMP_H_ 38 #define QUEUED_ACTION_SERVER_IMP_H_ 46 template <
class ActionSpec>
50 preempt_request_(false),
51 new_goal_preempt_request_(false),
52 execute_callback(execute_callback),
54 need_to_terminate(false) {
56 as = std::make_shared<ActionServer<ActionSpec>>(
60 if (execute_callback != NULL) {
65 template <
class ActionSpec>
72 execute_callback(execute_callback),
76 as = std::make_shared<ActionServer<ActionSpec>>(
80 if (execute_callback != NULL) {
85 template <
class ActionSpec>
92 template <
class ActionSpec>
106 template <
class ActionSpec>
109 std::lock_guard<std::recursive_mutex> lk(
lock);
113 "Attempting to accept the next goal when a new goal is not available");
133 template <
class ActionSpec>
138 template <
class ActionSpec>
143 template <
class ActionSpec>
149 return status == actionlib_msgs::GoalStatus::ACTIVE ||
150 status == actionlib_msgs::GoalStatus::PREEMPTING;
153 template <
class ActionSpec>
155 std::lock_guard<std::recursive_mutex> lk(
lock);
160 template <
class ActionSpec>
162 std::lock_guard<std::recursive_mutex> lk(
lock);
167 template <
class ActionSpec>
169 std::lock_guard<std::recursive_mutex> lk(
lock);
174 template <
class ActionSpec>
176 std::lock_guard<std::recursive_mutex> lk(
lock);
177 ROS_DEBUG_NAMED(
"actionlib",
"A new goal has been recieved by the single goal action server");
187 "This goal was canceled because another goal was received" 188 "bumping this one out of the queue");
201 "This goal was rejected because another goal there are newer goals in the queue");
205 template <
class ActionSpec>
207 std::lock_guard<std::recursive_mutex> lk(
lock);
208 ROS_DEBUG_NAMED(
"actionlib",
"A preempt has been received by the QueuedActionServer");
215 "Setting preempt_request bit for the current goal to TRUE");
220 ROS_DEBUG_NAMED(
"actionlib",
"Setting preempt request bit for the next goal to TRUE");
225 template <
class ActionSpec>
234 std::unique_lock<std::recursive_mutex> lk(
lock);
239 ROS_ERROR_NAMED(
"actionlib",
"Should never reach this code with an active goal");
244 "execute_callback must exist. This is a bug in QueuedActionServer");
260 "Your executeCallback did not set the goal to a terminal status.\n" 261 "This is a bug in your ActionServer implementation. Fix your code!\n" 262 "For now, the ActionServer will set this goal to aborted");
264 "This goal was aborted by the simple action server. The user should " 265 "have set a terminal status on this goal and did not");
271 template <
class ActionSpec>
bool isPreemptRequested()
ExecuteCallback execute_callback
std::thread * execute_thread
#define ROS_WARN_NAMED(name,...)
actionlib_msgs::GoalID getGoalID() const
void setPreempted(const Result &result=Result(), const std::string &text=std::string(""))
std::condition_variable_any execute_condition
void setRejected(const Result &result=Result(), const std::string &text=std::string(""))
boost::shared_ptr< const Goal > getGoal() const
std::atomic< bool > need_to_terminate
void goalCallback(GoalHandle preempt)
std::shared_ptr< ActionServer< ActionSpec > > as
#define ROS_FATAL_COND(cond,...)
QueuedActionServer(std::string name, ExecuteCallback execute_callback)
void setSucceeded(const Result &result=Result(), const std::string &text=std::string(""))
void setCanceled(const Result &result=Result(), const std::string &text=std::string(""))
void setAccepted(const std::string &text=std::string(""))
#define ROS_DEBUG_NAMED(name,...)
bool isNewGoalAvailable()
void setSucceeded(const Result &result=Result(), const std::string &text=std::string(""))
Duration & fromSec(double t)
bool new_goal_preempt_request_
void setAborted(const Result &result=Result(), const std::string &text=std::string(""))
boost::shared_ptr< const Goal > acceptNewGoal()
void setAborted(const Result &result=Result(), const std::string &text=std::string(""))
#define ROS_ERROR_NAMED(name,...)
void preemptCallback(GoalHandle preempt)
std::recursive_mutex lock
boost::function< void(const GoalConstPtr &)> ExecuteCallback
actionlib_msgs::GoalStatus getGoalStatus() const