1 #ifndef __GENERIC_TEST_SERVER__
2 #define __GENERIC_TEST_SERVER__
4 #include <actionlib/server/simple_action_server.h>
12 template <
class ActionClass,
class ActionGoalConstPtr,
class ActionFeedback,
16 TestServer(std::string node_name, std::string actionlib_name);
18 void executeCB(
const ActionGoalConstPtr &goal);
26 virtual bool parseGoal(
const ActionGoalConstPtr &goal) = 0;
36 template <
class ActionClass,
class ActionGoalConstPtr,
class ActionFeedback,
38 TestServer<ActionClass, ActionGoalConstPtr, ActionFeedback,
40 std::string actionlib_name)
41 : action_server_(nh_, actionlib_name,
42 boost::bind(&
TestServer::executeCB, this, _1), false),
43 action_name_(actionlib_name) {
46 ROS_INFO(
"Started test server %s!", actionlib_name.c_str());
49 template <
class ActionClass,
class ActionGoalConstPtr,
class ActionFeedback,
51 void TestServer<ActionClass, ActionGoalConstPtr, ActionFeedback,
52 ActionResult>::executeCB(
const ActionGoalConstPtr &goal) {
53 ROS_INFO(
"BT Test server %s has been called!", action_name_.c_str());
54 if (!parseGoal(goal)) {
55 action_server_.setPreempted();
59 ROS_INFO(
"Press 'p' for preempting this action, 'a' to abort, anything else "
63 getline(std::cin, input);
65 if (input.length() == 1) {
73 ROS_WARN(
"Preempting!");
74 action_server_.setPreempted();
77 ROS_ERROR(
"Aborting!");
78 action_server_.setAborted();
81 ROS_INFO(
"Succeeding!");
82 action_server_.setSucceeded();
actionlib::SimpleActionServer< ActionClass > action_server_
TestServer(std::string node_name, std::string actionlib_name)
void executeCB(const ActionGoalConstPtr &goal)
virtual bool parseGoal(const ActionGoalConstPtr &goal)=0