37 #ifndef ACTIONLIB__SERVER__ACTION_SERVER_IMP_H_ 38 #define ACTIONLIB__SERVER__ACTION_SERVER_IMP_H_ 46 template<
class ActionSpec>
58 "You've passed in true for auto_start for the C++ action server at [%s]. You should always pass in false to avoid race conditions.",
63 template<
class ActionSpec>
72 "You've passed in true for auto_start for the C++ action server at [%s]. You should always pass in false to avoid race conditions.",
79 template<
class ActionSpec>
90 "You've passed in true for auto_start for the C++ action server at [%s]. You should always pass in false to avoid race conditions.",
97 template<
class ActionSpec>
107 "You've passed in true for auto_start for the C++ action server at [%s]. You should always pass in false to avoid race conditions.",
114 template<
class ActionSpec>
124 "You've passed in true for auto_start for the C++ action server at [%s]. You should always pass in false to avoid race conditions.",
131 template<
class ActionSpec>
136 template<
class ActionSpec>
143 node_.
param(
"actionlib_server_pub_queue_size", pub_queue_size, 50);
144 node_.
param(
"actionlib_server_sub_queue_size", sub_queue_size, 50);
145 if (pub_queue_size < 0) {pub_queue_size = 50;}
146 if (sub_queue_size < 0) {sub_queue_size = 50;}
150 node_.
advertise<ActionFeedback>(
"feedback",
static_cast<uint32_t
>(pub_queue_size));
153 static_cast<uint32_t
>(pub_queue_size),
true);
157 double status_frequency, status_list_timeout;
159 std::string status_frequency_param_name;
160 if (!
node_.
searchParam(
"actionlib_status_frequency", status_frequency_param_name)) {
161 status_frequency = 5.0;
163 node_.
param(status_frequency_param_name, status_frequency, 5.0);
167 "You're using the deprecated status_frequency parameter, please switch to actionlib_status_frequency.");
169 node_.
param(
"status_list_timeout", status_list_timeout, 5.0);
173 if (status_frequency > 0) {
182 node_.
subscribe<actionlib_msgs::GoalID>(
"cancel",
static_cast<uint32_t
>(sub_queue_size),
186 template<
class ActionSpec>
188 const Result & result)
190 boost::recursive_mutex::scoped_lock lock(this->
lock_);
196 ROS_DEBUG_NAMED(
"actionlib",
"Publishing result for goal with id: %s and stamp: %.2f",
197 status.goal_id.id.c_str(), status.goal_id.stamp.toSec());
202 template<
class ActionSpec>
204 const Feedback & feedback)
206 boost::recursive_mutex::scoped_lock lock(this->
lock_);
211 af->feedback = feedback;
212 ROS_DEBUG_NAMED(
"actionlib",
"Publishing feedback for goal with id: %s and stamp: %.2f",
213 status.goal_id.id.c_str(), status.goal_id.stamp.toSec());
217 template<
class ActionSpec>
220 boost::recursive_mutex::scoped_lock lock(this->
lock_);
229 template<
class ActionSpec>
232 boost::recursive_mutex::scoped_lock lock(this->
lock_);
234 actionlib_msgs::GoalStatusArray status_array;
238 status_array.status_list.resize(this->
status_list_.size());
244 status_array.status_list[i] = (*it).status_;
247 if ((*it).handle_destruction_time_ !=
ros::Time() &&
261 #endif // ACTIONLIB__SERVER__ACTION_SERVER_IMP_H_ ActionServer(ros::NodeHandle n, std::string name, boost::function< void(GoalHandle)> goal_cb, boost::function< void(GoalHandle)> cancel_cb, bool auto_start)
Constructor for an ActionServer.
virtual ~ActionServer()
Destructor for the ActionServer.
ros::Subscriber goal_sub_
void publish(const boost::shared_ptr< M > &message) const
#define ROS_WARN_NAMED(name,...)
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
ros::Publisher status_pub_
virtual void initialize()
Initialize all ROS connections and setup timers.
boost::recursive_mutex lock_
#define ROS_DEBUG_NAMED(name,...)
ros::Duration status_list_timeout_
A class for storing the status of each goal the action server is currently working on...
ros::Publisher feedback_pub_
bool searchParam(const std::string &key, std::string &result) const
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
std::list< StatusTracker< ActionSpec > > status_list_
Timer createTimer(Rate r, Handler h, Obj o, bool oneshot=false, bool autostart=true) const
const std::string & getNamespace() const
The ActionServerBase implements the logic for an ActionServer.
virtual void publishResult(const actionlib_msgs::GoalStatus &status, const Result &result)
Publishes a result for a given goal.
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
Encapsulates a state machine for a given goal that the user can trigger transitions on...
virtual void publishStatus()
Explicitly publish status.
bool getParam(const std::string &key, std::string &s) const
ros::Subscriber cancel_sub_
ros::Publisher result_pub_
virtual void publishFeedback(const actionlib_msgs::GoalStatus &status, const Feedback &feedback)
Publishes feedback for a given goal.