37 #ifndef ACTIONLIB__SERVER__SIMPLE_ACTION_SERVER_IMP_H_ 38 #define ACTIONLIB__SERVER__SIMPLE_ACTION_SERVER_IMP_H_ 46 template<
class ActionSpec>
50 : new_goal_(false), preempt_request_(false), new_goal_preempt_request_(false), execute_callback_(
51 execute_callback), execute_thread_(NULL), need_to_terminate_(false)
64 template<
class ActionSpec>
80 template<
class ActionSpec>
98 template<
class ActionSpec>
116 template<
class ActionSpec>
133 template<
class ActionSpec>
150 template<
class ActionSpec>
158 template<
class ActionSpec>
176 template<
class ActionSpec>
180 boost::recursive_mutex::scoped_lock lock(
lock_);
184 "Attempting to accept the next goal when a new goal is not available");
195 "This goal was canceled because another goal was recieved by the simple action server");
214 template<
class ActionSpec>
221 template<
class ActionSpec>
227 template<
class ActionSpec>
234 return status == actionlib_msgs::GoalStatus::ACTIVE ||
235 status == actionlib_msgs::GoalStatus::PREEMPTING;
238 template<
class ActionSpec>
241 boost::recursive_mutex::scoped_lock lock(
lock_);
246 template<
class ActionSpec>
249 boost::recursive_mutex::scoped_lock lock(
lock_);
254 template<
class ActionSpec>
257 boost::recursive_mutex::scoped_lock lock(
lock_);
262 template<
class ActionSpec>
268 "Cannot call SimpleActionServer::registerGoalCallback() because an executeCallback exists. Not going to register it.");
274 template<
class ActionSpec>
280 template<
class ActionSpec>
286 template<
class ActionSpec>
292 template<
class ActionSpec>
295 boost::recursive_mutex::scoped_lock lock(
lock_);
296 ROS_DEBUG_NAMED(
"actionlib",
"A new goal has been recieved by the single goal action server");
306 "This goal was canceled because another goal was recieved by the simple action server");
333 "This goal was canceled because another goal was recieved by the simple action server");
337 template<
class ActionSpec>
340 boost::recursive_mutex::scoped_lock lock(
lock_);
341 ROS_DEBUG_NAMED(
"actionlib",
"A preempt has been received by the SimpleActionServer");
346 "Setting preempt_request bit for the current goal to TRUE and invoking callback");
355 ROS_DEBUG_NAMED(
"actionlib",
"Setting preempt request bit for the next goal to TRUE");
360 template<
class ActionSpec>
373 boost::recursive_mutex::scoped_lock lock(
lock_);
375 ROS_ERROR_NAMED(
"actionlib",
"Should never reach this code with an active goal");
380 "execute_callback_ must exist. This is a bug in SimpleActionServer");
384 boost::reverse_lock<boost::recursive_mutex::scoped_lock> unlocker(lock);
389 ROS_WARN_NAMED(
"actionlib",
"Your executeCallback did not set the goal to a terminal status.\n" 390 "This is a bug in your ActionServer implementation. Fix your code!\n" 391 "For now, the ActionServer will set this goal to aborted");
394 "This goal was aborted by the simple action server. The user should have set a terminal status on this goal and did not");
398 boost::posix_time::milliseconds(static_cast<int64_t>(loop_duration.
toSec() * 1000.0f)));
403 template<
class ActionSpec>
411 #endif // ACTIONLIB__SERVER__SIMPLE_ACTION_SERVER_IMP_H_
void publishFeedback(const Feedback &feedback)
Send feedback to any clients of the goal associated with this ServerGoalHandle.
boost::shared_ptr< const Goal > acceptNewGoal()
Accepts a new goal when one is available. The status of this goal is set to active upon acceptance...
void publishFeedback(const FeedbackConstPtr &feedback)
Publishes feedback for a given goal.
boost::condition execute_condition_
boost::function< void()> goal_callback_
void preemptCallback(GoalHandle preempt)
Callback for when the ActionServer receives a new preempt and passes it on.
#define ROS_WARN_NAMED(name,...)
actionlib_msgs::GoalID getGoalID() const
Accessor for the goal id associated with the ServerGoalHandle.
void goalCallback(GoalHandle goal)
Callback for when the ActionServer receives a new goal and passes it on.
void executeLoop()
Called from a separate thread to call blocking execute calls.
SimpleActionServer(std::string name, ExecuteCallback execute_callback, bool auto_start)
Constructor for a SimpleActionServer.
boost::shared_ptr< const Goal > getGoal() const
Accessor for the goal associated with the ServerGoalHandle.
boost::mutex terminate_mutex_
boost::thread * execute_thread_
#define ROS_FATAL_COND(cond,...)
bool isActive()
Allows polling implementations to query about the status of the current goal.
void setSucceeded(const Result &result=Result(), const std::string &text=std::string(""))
Sets the status of the active goal to succeeded.
void setCanceled(const Result &result=Result(), const std::string &text=std::string(""))
Set the status of the goal associated with the ServerGoalHandle to RECALLED or PREEMPTED depending on...
void shutdown()
Explicitly shutdown the action server.
boost::function< void(const GoalConstPtr &)> ExecuteCallback
void start()
Explicitly start the action server, used it auto_start is set to false.
void setAccepted(const std::string &text=std::string(""))
Accept the goal referenced by the goal handle. This will transition to the ACTIVE state or the PREEMP...
#define ROS_DEBUG_NAMED(name,...)
void setPreempted(const Result &result=Result(), const std::string &text=std::string(""))
Sets the status of the active goal to preempted.
void setSucceeded(const Result &result=Result(), const std::string &text=std::string(""))
Set the status of the goal associated with the ServerGoalHandle to succeeded.
boost::function< void()> preempt_callback_
Duration & fromSec(double t)
void registerPreemptCallback(boost::function< void()> cb)
Allows users to register a callback to be invoked when a new preempt request is available.
bool new_goal_preempt_request_
bool isPreemptRequested()
Allows polling implementations to query about preempt requests.
Encapsulates a state machine for a given goal that the user can trigger transitions on...
ExecuteCallback execute_callback_
void setAborted(const Result &result=Result(), const std::string &text=std::string(""))
Set the status of the goal associated with the ServerGoalHandle to aborted.
void setAborted(const Result &result=Result(), const std::string &text=std::string(""))
Sets the status of the active goal to aborted.
#define ROS_ERROR_NAMED(name,...)
The ActionServer is a helpful tool for managing goal requests to a node. It allows the user to specif...
boost::shared_ptr< ActionServer< ActionSpec > > as_
void registerGoalCallback(boost::function< void()> cb)
Allows users to register a callback to be invoked when a new goal is available.
boost::recursive_mutex lock_
actionlib_msgs::GoalStatus getGoalStatus() const
Accessor for the status associated with the ServerGoalHandle.
bool isNewGoalAvailable()
Allows polling implementations to query about the availability of a new goal.