simple_action_server.h
Go to the documentation of this file.
1 /*********************************************************************
2 *
3 * Software License Agreement (BSD License)
4 *
5 * Copyright (c) 2008, Willow Garage, Inc.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer in the documentation and/or other materials provided
17 * with the distribution.
18 * * Neither the name of Willow Garage, Inc. nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 *
35 * Author: Eitan Marder-Eppstein
36 *********************************************************************/
37 #ifndef ACTIONLIB__SERVER__SIMPLE_ACTION_SERVER_H_
38 #define ACTIONLIB__SERVER__SIMPLE_ACTION_SERVER_H_
39 
40 #include <boost/thread/condition.hpp>
41 #include <ros/ros.h>
44 
45 #include <string>
46 
47 namespace actionlib
48 {
59 template<class ActionSpec>
60 class SimpleActionServer
61 {
62 public:
63  // generates typedefs that we'll use to make our lives easier
64  ACTION_DEFINITION(ActionSpec)
65 
67  typedef boost::function<void (const GoalConstPtr &)> ExecuteCallback;
68 
77  SimpleActionServer(std::string name, ExecuteCallback execute_callback, bool auto_start);
78 
84  SimpleActionServer(std::string name, bool auto_start);
85 
93  ROS_DEPRECATED SimpleActionServer(std::string name, ExecuteCallback execute_callback = NULL);
94 
104  SimpleActionServer(ros::NodeHandle n, std::string name, ExecuteCallback execute_callback,
105  bool auto_start);
106 
113  SimpleActionServer(ros::NodeHandle n, std::string name, bool auto_start);
114 
124  ExecuteCallback execute_callback = NULL);
125 
127 
140 
145  bool isNewGoalAvailable();
146 
147 
152  bool isPreemptRequested();
153 
158  bool isActive();
159 
165  void setSucceeded(const Result & result = Result(), const std::string & text = std::string(""));
166 
172  void setAborted(const Result & result = Result(), const std::string & text = std::string(""));
173 
174 
179  void publishFeedback(const FeedbackConstPtr & feedback);
180 
185  void publishFeedback(const Feedback & feedback);
186 
192  void setPreempted(const Result & result = Result(), const std::string & text = std::string(""));
193 
198  void registerGoalCallback(boost::function<void()> cb);
199 
204  void registerPreemptCallback(boost::function<void()> cb);
205 
209  void start();
210 
214  void shutdown();
215 
216 private:
220  void goalCallback(GoalHandle goal);
221 
225  void preemptCallback(GoalHandle preempt);
226 
230  void executeLoop();
231 
233 
235 
237 
239 
240  boost::recursive_mutex lock_;
241 
242  boost::function<void()> goal_callback_;
243  boost::function<void()> preempt_callback_;
245 
246  boost::condition execute_condition_;
247  boost::thread * execute_thread_;
248 
249  boost::mutex terminate_mutex_;
250  bool need_to_terminate_;
251 };
252 
253 } // namespace actionlib
254 
255 // include the implementation here
257 #endif // ACTIONLIB__SERVER__SIMPLE_ACTION_SERVER_H_
actionlib::SimpleActionServer::execute_callback_
ExecuteCallback execute_callback_
Definition: simple_action_server.h:279
actionlib::SimpleActionServer::current_goal_
GoalHandle current_goal_
Definition: simple_action_server.h:271
actionlib::SimpleActionServer::n_
ros::NodeHandle n_
Definition: simple_action_server.h:267
actionlib::SimpleActionServer::publishFeedback
void publishFeedback(const FeedbackConstPtr &feedback)
Publishes feedback for a given goal.
Definition: simple_action_server_imp.h:316
actionlib::SimpleActionServer::~SimpleActionServer
~SimpleActionServer()
Definition: simple_action_server_imp.h:186
actionlib::SimpleActionServer::preempt_callback_
boost::function< void()> preempt_callback_
Definition: simple_action_server.h:278
boost::shared_ptr
ACTION_DEFINITION
#define ACTION_DEFINITION(ActionSpec)
Definition: action_definition.h:77
actionlib::SimpleActionServer::start
void start()
Explicitly start the action server, used it auto_start is set to false.
Definition: simple_action_server_imp.h:439
actionlib::SimpleActionServer::GoalHandle
ActionServer< ActionSpec >::GoalHandle GoalHandle
Definition: simple_action_server.h:101
actionlib::SimpleActionServer::execute_thread_
boost::thread * execute_thread_
Definition: simple_action_server.h:282
ros.h
actionlib::SimpleActionServer::need_to_terminate_
bool need_to_terminate_
Definition: simple_action_server.h:285
actionlib::SimpleActionServer::goal_callback_
boost::function< void()> goal_callback_
Definition: simple_action_server.h:277
actionlib::SimpleActionServer::shutdown
void shutdown()
Explicitly shutdown the action server.
Definition: simple_action_server_imp.h:194
actionlib::SimpleActionServer::isPreemptRequested
bool isPreemptRequested()
Allows polling implementations to query about preempt requests.
Definition: simple_action_server_imp.h:257
ROS_DEPRECATED
#define ROS_DEPRECATED
actionlib::SimpleActionServer::ExecuteCallback
boost::function< void(const GoalConstPtr &)> ExecuteCallback
Definition: simple_action_server.h:102
actionlib::SimpleActionServer::isNewGoalAvailable
bool isNewGoalAvailable()
Allows polling implementations to query about the availability of a new goal.
Definition: simple_action_server_imp.h:250
actionlib::SimpleActionServer::setSucceeded
void setSucceeded(const Result &result=Result(), const std::string &text=std::string(""))
Sets the status of the active goal to succeeded.
Definition: simple_action_server_imp.h:274
actionlib::SimpleActionServer::goalCallback
void goalCallback(GoalHandle goal)
Callback for when the ActionServer receives a new goal and passes it on.
Definition: simple_action_server_imp.h:328
actionlib::SimpleActionServer::next_goal_
GoalHandle next_goal_
Definition: simple_action_server.h:271
actionlib::SimpleActionServer::executeLoop
void executeLoop()
Called from a separate thread to call blocking execute calls.
Definition: simple_action_server_imp.h:396
actionlib::SimpleActionServer::isActive
bool isActive()
Allows polling implementations to query about the status of the current goal.
Definition: simple_action_server_imp.h:263
action_server.h
actionlib::SimpleActionServer::as_
boost::shared_ptr< ActionServer< ActionSpec > > as_
Definition: simple_action_server.h:269
action_definition.h
actionlib::SimpleActionServer::registerPreemptCallback
void registerPreemptCallback(boost::function< void()> cb)
Allows users to register a callback to be invoked when a new preempt request is available.
Definition: simple_action_server_imp.h:310
actionlib::SimpleActionServer::execute_condition_
boost::condition execute_condition_
Definition: simple_action_server.h:281
simple_action_server_imp.h
actionlib::SimpleActionServer::setPreempted
void setPreempted(const Result &result=Result(), const std::string &text=std::string(""))
Sets the status of the active goal to preempted.
Definition: simple_action_server_imp.h:290
actionlib::ActionServer::GoalHandle
ServerGoalHandle< ActionSpec > GoalHandle
Definition: action_server.h:111
actionlib::SimpleActionServer::registerGoalCallback
void registerGoalCallback(boost::function< void()> cb)
Allows users to register a callback to be invoked when a new goal is available.
Definition: simple_action_server_imp.h:298
actionlib::SimpleActionServer::new_goal_
bool new_goal_
Definition: simple_action_server.h:273
actionlib::SimpleActionServer::setAborted
void setAborted(const Result &result=Result(), const std::string &text=std::string(""))
Sets the status of the active goal to aborted.
Definition: simple_action_server_imp.h:282
actionlib::SimpleActionServer::new_goal_preempt_request_
bool new_goal_preempt_request_
Definition: simple_action_server.h:273
actionlib::SimpleActionServer::acceptNewGoal
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,...
Definition: simple_action_server_imp.h:213
actionlib
Definition: action_definition.h:40
actionlib::SimpleActionServer::terminate_mutex_
boost::mutex terminate_mutex_
Definition: simple_action_server.h:284
actionlib::SimpleActionServer::preemptCallback
void preemptCallback(GoalHandle preempt)
Callback for when the ActionServer receives a new preempt and passes it on.
Definition: simple_action_server_imp.h:373
actionlib::SimpleActionServer::preempt_request_
bool preempt_request_
Definition: simple_action_server.h:273
actionlib::SimpleActionServer::SimpleActionServer
SimpleActionServer(std::string name, ExecuteCallback execute_callback, bool auto_start)
Constructor for a SimpleActionServer.
Definition: simple_action_server_imp.h:82
ros::NodeHandle
actionlib::SimpleActionServer::lock_
boost::recursive_mutex lock_
Definition: simple_action_server.h:275


actionlib
Author(s): Eitan Marder-Eppstein, Vijay Pradeep, Mikael Arguedas
autogenerated on Fri Oct 22 2021 02:37:22