[kinetic actionlib] define SimpleActionServer without parameters (like in tutorial) -> no matching function?

asked 2019-08-09 11:39:47 -0500

wlancholie gravatar image

updated 2019-08-10 21:24:29 -0500

jayess gravatar image

I tried to implement a simpleActionServer following the actionlib_tutorials. But unfortunately I can't seem to make the ActionServer work. In the tutorials, the ActionServer is defined beforehand without a constructor:

actionlib::SimpleActionServer<XYZ_generator::XYZAction> as;

and initialized later:

as(nh, "server_name", boost::bind(&ExecuteXYZ::executeCB, this, _1), false);
as.start();

But when I try this, I always get the error, that I have to use the existing constructors. How is this possible in the tutorials?

I always get this error:

error: no matching function for call to ‘actionlib::SimpleActionServer<XYZ_generator::XYZAction_<std::allocator<void> > >::SimpleActionServer()’
  , p_nh(private_nh)

/opt/ros/kinetic/include/actionlib/server/simple_action_server_imp.h:133:1: note:   candidate expects 3 arguments, 0 provided
/opt/ros/kinetic/include/actionlib/server/simple_action_server_imp.h:116:1: note: candidate: actionlib::SimpleActionServer<ActionSpec>::SimpleActionServer(ros::NodeHandle, std::__cxx11::string, bool) [with ActionSpec = XYZ_generator::XYZAction_<std::allocator<void> >; std::__cxx11::string = std::__cxx11::basic_string<char>]
 SimpleActionServer<ActionSpec>::SimpleActionServer(ros::NodeHandle n, std::string name,
 ^
/opt/ros/kinetic/include/actionlib/server/simple_action_server_imp.h:116:1: note:   candidate expects 3 arguments, 0 provided
/opt/ros/kinetic/include/actionlib/server/simple_action_server_imp.h:98:1: note: candidate: actionlib::SimpleActionServer<ActionSpec>::SimpleActionServer(ros::NodeHandle, std::__cxx11::string, actionlib::SimpleActionServer<ActionSpec>::ExecuteCallback, bool) [with ActionSpec = XYZ_generator::XYZAction_<std::allocator<void> >; std::__cxx11::string = std::__cxx11::basic_string<char>; actionlib::SimpleActionServer<ActionSpec>::ExecuteCallback = boost::function<void(const boost::shared_ptr<const XYZ_generator::XYZGoal_<std::allocator<void> > >&)>; typename ActionSpec::_action_goal_type::_goal_type = XYZ_generator::XYZGoal_<std::allocator<void> >]
 SimpleActionServer<ActionSpec>::SimpleActionServer(ros::NodeHandle n, std::string name,
 ^
/opt/ros/kinetic/include/actionlib/server/simple_action_server_imp.h:98:1: note:   candidate expects 4 arguments, 0 provided
/opt/ros/kinetic/include/actionlib/server/simple_action_server_imp.h:80:1: note: candidate: actionlib::SimpleActionServer<ActionSpec>::SimpleActionServer(std::__cxx11::string, actionlib::SimpleActionServer<ActionSpec>::ExecuteCallback) [with ActionSpec = XYZ_generator::XYZAction_<std::allocator<void> >; std::__cxx11::string = std::__cxx11::basic_string<char>; actionlib::SimpleActionServer<ActionSpec>::ExecuteCallback = boost::function<void(const boost::shared_ptr<const XYZ_generator::XYZGoal_<std::allocator<void> > >&)>; typename ActionSpec::_action_goal_type::_goal_type = XYZ_generator::XYZGoal_<std::allocator<void> >]
 SimpleActionServer<ActionSpec>::SimpleActionServer(std::string name,
 ^
/opt/ros/kinetic/include/actionlib/server/simple_action_server_imp.h:80:1: note:   candidate expects 2 arguments, 0 provided
/opt/ros/kinetic/include/actionlib/server/simple_action_server_imp.h:64:1: note: candidate: actionlib::SimpleActionServer<ActionSpec>::SimpleActionServer(std::__cxx11::string, bool) [with ActionSpec = XYZ_generator::XYZAction_<std::allocator<void> >; std::__cxx11::string = std::__cxx11::basic_string<char>]
 SimpleActionServer<ActionSpec>::SimpleActionServer(std::string name, bool auto_start)
 ^
/opt/ros/kinetic/include/actionlib/server/simple_action_server_imp.h:64:1: note:   candidate expects 2 arguments, 0 provided
/opt/ros/kinetic/include/actionlib/server/simple_action_server_imp.h:46:1: note: candidate: actionlib::SimpleActionServer<ActionSpec>::SimpleActionServer(std::__cxx11::string, actionlib::SimpleActionServer<ActionSpec>::ExecuteCallback, bool) [with ActionSpec = XYZ_generator::XYZAction_<std::allocator<void> >; std::__cxx11::string = std::__cxx11::basic_string<char>; actionlib::SimpleActionServer<ActionSpec>::ExecuteCallback = boost::function<void(const boost::shared_ptr<const XYZ_generator::XYZGoal_<std::allocator<void> > >&)>; typename ActionSpec::_action_goal_type::_goal_type = XYZ_generator::XYZGoal_<std::allocator<void> >]
 SimpleActionServer<ActionSpec>::SimpleActionServer(std::string name,

my code: generate_XYZ.cpp

#include <generate_XYZ/generate_XYZ.h>

namespace generate_XYZ{

    ExecuteXYZ::ExecuteXYZ(ros::NodeHandle &nh, ros::NodeHandle &private_nh)
        : nh(nh)
        , p_nh(private_nh)


{
    as(nh, "server_name", boost::bind(&ExecuteXYZ::executeCB, this, _1), false);
    as.start();

}

void ExecuteXYZ::executeCB(const XYZ_generator::XYZGoalConstPtr &goal) {
    ROS_ERROR("executed.");
}

ExecuteXYZ::~ExecuteXYZ()
{}

} // end of namespace generate_XYZ

and generate_XYZ.h

#ifndef ...
(more)
edit retag flag offensive close merge delete