Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Service Server refuses to advertise my service/function?

Hello I'm writing a server whose job is to offer a 6DOF pose estimation, but I'm having problems advertising it as it seems that I'm giving it a function with too manny argument, even tough I'm following the tutorial very closely.

This is the relevant part from the node's main:

 ros::init(argc, argv, "epsilon");
 ros::NodeHandle nh("~");
 PoseServer server;
 ros::ServiceServer service = nh.advertiseService("/epsilon/get_pose", server.compute_Pose);
 ROS_INFO("Ready to estimate pose.");
 ros::spin();
 return 0;

And this is how I implemented compute_Pose within the PoseServer class:

bool PoseServer::compute_Pose(epsilon::Pose::Request &req,
                          epsilon::Pose::Response &res)
 {
   //Here I calculate the pose and store it as a string for now
   res.pozitie = pose_string;
 }

And this is the Pose.srv as I've named my .srv file and the package's working name is epsilon, it's not really supposed to work with string but I wanted to start with something simple and try to advertise it first:

string A
---
string pozitie

The error I got is:

no matching function for call to ‘ros::NodeHandle::advertiseService(const char [18], <unresolved overloaded function type>)’
note: candidates are:
/opt/ros/electric/stacks/ros_comm/clients/cpp/roscpp/include/ros/node_handle.h:821:17: note: template<class T, class MReq, class MRes> ros::ServiceServer ros::NodeHandle::advertiseService(const string&, bool (T::*)(MReq&, MRes&), T*)
//And a whole list of other candidate templates
/ros/node_handle.h:1111:17: note:   candidate expects 1 argument, 2 provided

I think it's telling that I have to add something more than req and res or maybe to declare them in another fashion but I don't see exactly how.

Service Server refuses to advertise my service/function?

Hello I'm writing a server whose job is to offer a 6DOF pose estimation, but I'm having problems advertising it as it seems that I'm giving it a function with too manny argument, even tough I'm following the tutorial very closely.

This is the relevant part from the node's main:

 ros::init(argc, argv, "epsilon");
 ros::NodeHandle nh("~");
 PoseServer server;
 ros::ServiceServer service = nh.advertiseService("/epsilon/get_pose", server.compute_Pose);
 ROS_INFO("Ready to estimate pose.");
 ros::spin();
 return 0;

And this is how I implemented compute_Pose within the PoseServer class:

bool PoseServer::compute_Pose(epsilon::Pose::Request &req,
                          epsilon::Pose::Response &res)
 {
   //Here I calculate the pose and store it as a string for now
   res.pozitie = pose_string;
 }

And this is the Pose.srv as I've named my .srv file and the package's working name is epsilon, it's not really supposed to work with string but I wanted to start with something simple and try to advertise it first:

string A
---
string pozitie

The error I got is:

no matching function for call to ‘ros::NodeHandle::advertiseService(const char [18], <unresolved overloaded function type>)’
note: candidates are:
/opt/ros/electric/stacks/ros_comm/clients/cpp/roscpp/include/ros/node_handle.h:821:17: note: template<class T, class MReq, class MRes> ros::ServiceServer ros::NodeHandle::advertiseService(const string&, bool (T::*)(MReq&, MRes&), T*)
//And a whole list of other candidate templates
/ros/node_handle.h:1111:17: note:   candidate expects 1 argument, 2 provided

I think it's telling that I have to add something more than req and res or less but I don't think that's allowed or maybe to declare them in another fashion but I don't see exactly how.

click to hide/show revision 3
Updated with CMakelist.txt

Service Server refuses to advertise my service/function?

Hello I'm writing a server whose job is to offer a 6DOF pose estimation, but I'm having problems advertising it as it seems that I'm giving it a function with too manny argument, even tough I'm following the tutorial very closely.

This is the relevant part from the node's main:

 ros::init(argc, argv, "epsilon");
 ros::NodeHandle nh("~");
 PoseServer server;
 ros::ServiceServer service = nh.advertiseService("/epsilon/get_pose", server.compute_Pose);
 ROS_INFO("Ready to estimate pose.");
 ros::spin();
 return 0;

And this is how I implemented compute_Pose within the PoseServer class:

bool PoseServer::compute_Pose(epsilon::Pose::Request &req,
                          epsilon::Pose::Response &res)
 {
   //Here I calculate the pose and store it as a string for now
   res.pozitie = pose_string;
 }

And this is the Pose.srv as I've named my .srv file and the package's working name is epsilon, it's not really supposed to work with string but I wanted to start with something simple and try to advertise it first:

string A
---
string pozitie

The error I got is:

no matching function for call to ‘ros::NodeHandle::advertiseService(const char [18], <unresolved overloaded function type>)’
note: candidates are:
/opt/ros/electric/stacks/ros_comm/clients/cpp/roscpp/include/ros/node_handle.h:821:17: note: template<class T, class MReq, class MRes> ros::ServiceServer ros::NodeHandle::advertiseService(const string&, bool (T::*)(MReq&, MRes&), T*)
//And a whole list of other candidate templates
/ros/node_handle.h:1111:17: note:   candidate expects 1 argument, 2 provided

I think it's telling that I have to add something more than req and res or less but I don't think that's allowed or maybe to declare them in another fashion but I don't see exactly how.

Edited to add my cmakelist.txt

cmake_minimum_required(VERSION 2.4.6)
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)

# Set the build type.  Options are:
#  Coverage       : w/ debug symbols, w/o optimization, w/ code-coverage
#  Debug          : w/ debug symbols, w/o optimization
#  Release        : w/o debug symbols, w/ optimization
#  RelWithDebInfo : w/ debug symbols, w/ optimization
#  MinSizeRel     : w/o debug symbols, w/ optimization, stripped binaries
#set(ROS_BUILD_TYPE RelWithDebInfo)


rosbuild_init()

rosbuild_add_boost_directories()

#set the default path for built executables to the "bin" directory
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
#set the default path for built libraries to the "lib" directory
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)

#uncomment if you have defined messages
rosbuild_genmsg()
#uncomment if you have defined services
rosbuild_gensrv()

rosbuild_add_executable(epsilon_node_1 src/epsilon_node_1.cpp)


#this is where I try to fix the boost bind problem the way you showed me
rosbuild_link_boost(epsilon_node_1 bind)
#How I solved it in the past
target_link_libraries(epsilon_node_1 ${Boost_FILESYSTEM_LIBRARY}    ${Boost_SYSTEM_LIBRARY} )

Maybe I'm reading the boost site wrong but I think bind should be in the bind library correct?

click to hide/show revision 4
Added the two correct ways to advertise the service

Service Server refuses to advertise my service/function?

Hello I'm writing a server whose job is to offer a 6DOF pose estimation, but I'm having problems advertising it as it seems that I'm giving it a function with too manny argument, even tough I'm following the tutorial very closely.

This is the relevant part from the node's main:

 ros::init(argc, argv, "epsilon");
 ros::NodeHandle nh("~");
 PoseServer server;
 ros::ServiceServer service = nh.advertiseService("/epsilon/get_pose", server.compute_Pose);
 ROS_INFO("Ready to estimate pose.");
 ros::spin();
 return 0;

And this is how I implemented compute_Pose within the PoseServer class:

bool PoseServer::compute_Pose(epsilon::Pose::Request &req,
                          epsilon::Pose::Response &res)
 {
   //Here I calculate the pose and store it as a string for now
   res.pozitie = pose_string;
 }

And this is the Pose.srv as I've named my .srv file and the package's working name is epsilon, it's not really supposed to work with string but I wanted to start with something simple and try to advertise it first:

string A
---
string pozitie

The error I got is:

no matching function for call to ‘ros::NodeHandle::advertiseService(const char [18], <unresolved overloaded function type>)’
note: candidates are:
/opt/ros/electric/stacks/ros_comm/clients/cpp/roscpp/include/ros/node_handle.h:821:17: note: template<class T, class MReq, class MRes> ros::ServiceServer ros::NodeHandle::advertiseService(const string&, bool (T::*)(MReq&, MRes&), T*)
//And a whole list of other candidate templates
/ros/node_handle.h:1111:17: note:   candidate expects 1 argument, 2 provided

I think it's telling that I have to add something more than req and res or less but I don't think that's allowed or maybe to declare them in another fashion but I don't see exactly how.

Edited to add my cmakelist.txt

cmake_minimum_required(VERSION 2.4.6)
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)

# Set the build type.  Options are:
#  Coverage       : w/ debug symbols, w/o optimization, w/ code-coverage
#  Debug          : w/ debug symbols, w/o optimization
#  Release        : w/o debug symbols, w/ optimization
#  RelWithDebInfo : w/ debug symbols, w/ optimization
#  MinSizeRel     : w/o debug symbols, w/ optimization, stripped binaries
#set(ROS_BUILD_TYPE RelWithDebInfo)


rosbuild_init()

rosbuild_add_boost_directories()

#set the default path for built executables to the "bin" directory
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
#set the default path for built libraries to the "lib" directory
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)

#uncomment if you have defined messages
rosbuild_genmsg()
#uncomment if you have defined services
rosbuild_gensrv()

rosbuild_add_executable(epsilon_node_1 src/epsilon_node_1.cpp)


#this is where I try to fix the boost bind problem the way you showed me
rosbuild_link_boost(epsilon_node_1 bind)
#How I solved it in the past
target_link_libraries(epsilon_node_1 ${Boost_FILESYSTEM_LIBRARY}    ${Boost_SYSTEM_LIBRARY} )

Maybe I'm reading the boost site wrong but I think bind should be in the bind library correct?

Edit: Now I'm not getting any more boost linking problems but it won't see the PoseServer constructor or computePose,even tough they're both clearly public, for either of the solutions this is how I advertise them in main:

//ros::ServiceServer service = nh.advertiseService("/epsilon/get_pose", &PoseServer::compute_Pose, &server);
ros::ServiceServer service = nh.advertiseService<epsilon::Pose::Request, epsilon::Pose::Response>("/epsilon/get_pose", boost::bind(&PoseServer::compute_Pose, server, _1, _2));

This is the type of error I'm getting, again not seeing the methods

undefined reference to `PoseServer::compute_Pose(epsilon::PoseRequest_<std::allocator<void> >&, epsilon::PoseResponse_<std::allocator<void> >&)'

Service Server refuses to advertise my service/function?

Hello I'm writing a server whose job is to offer a 6DOF pose estimation, but I'm having problems advertising it as it seems that I'm giving it a function with too manny argument, even tough I'm following the tutorial very closely.

This is the relevant part from the node's main:

 ros::init(argc, argv, "epsilon");
 ros::NodeHandle nh("~");
 PoseServer server;
 ros::ServiceServer service = nh.advertiseService("/epsilon/get_pose", server.compute_Pose);
 ROS_INFO("Ready to estimate pose.");
 ros::spin();
 return 0;

And this is how I implemented compute_Pose within the PoseServer class:

bool PoseServer::compute_Pose(epsilon::Pose::Request &req,
                          epsilon::Pose::Response &res)
 {
   //Here I calculate the pose and store it as a string for now
   res.pozitie = pose_string;
 }

And this is the Pose.srv as I've named my .srv file and the package's working name is epsilon, it's not really supposed to work with string but I wanted to start with something simple and try to advertise it first:

string A
---
string pozitie

The error I got is:

no matching function for call to ‘ros::NodeHandle::advertiseService(const char [18], <unresolved overloaded function type>)’
note: candidates are:
/opt/ros/electric/stacks/ros_comm/clients/cpp/roscpp/include/ros/node_handle.h:821:17: note: template<class T, class MReq, class MRes> ros::ServiceServer ros::NodeHandle::advertiseService(const string&, bool (T::*)(MReq&, MRes&), T*)
//And a whole list of other candidate templates
/ros/node_handle.h:1111:17: note:   candidate expects 1 argument, 2 provided

I think it's telling that I have to add something more than req and res or less but I don't think that's allowed or maybe to declare them in another fashion but I don't see exactly how.

Edited to add my cmakelist.txt

cmake_minimum_required(VERSION 2.4.6)
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)

# Set the build type.  Options are:
#  Coverage       : w/ debug symbols, w/o optimization, w/ code-coverage
#  Debug          : w/ debug symbols, w/o optimization
#  Release        : w/o debug symbols, w/ optimization
#  RelWithDebInfo : w/ debug symbols, w/ optimization
#  MinSizeRel     : w/o debug symbols, w/ optimization, stripped binaries
#set(ROS_BUILD_TYPE RelWithDebInfo)


rosbuild_init()

rosbuild_add_boost_directories()

#set the default path for built executables to the "bin" directory
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
#set the default path for built libraries to the "lib" directory
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)

#uncomment if you have defined messages
rosbuild_genmsg()
#uncomment if you have defined services
rosbuild_gensrv()

rosbuild_add_executable(epsilon_node_1 src/epsilon_node_1.cpp)


#this is where I try to fix the boost bind problem the way you showed me
rosbuild_link_boost(epsilon_node_1 bind)
#How I solved it in the past
target_link_libraries(epsilon_node_1 ${Boost_FILESYSTEM_LIBRARY}    ${Boost_SYSTEM_LIBRARY} )

Maybe I'm reading the boost site wrong but I think bind should be in the bind library correct?

Edit: Now I'm not getting any more boost linking problems but it won't see the PoseServer constructor or computePose,even tough they're both clearly public, for either of the solutions this is how I advertise them in main:

//ros::ServiceServer service = nh.advertiseService("/epsilon/get_pose", &PoseServer::compute_Pose, &server);
ros::ServiceServer service = nh.advertiseService<epsilon::Pose::Request, epsilon::Pose::Response>("/epsilon/get_pose", boost::bind(&PoseServer::compute_Pose, server, _1, _2));

This is the type of error I'm getting, again not seeing the methods

undefined reference to `PoseServer::compute_Pose(epsilon::PoseRequest_<std::allocator<void> >&, epsilon::PoseResponse_<std::allocator<void> >&)'

Service Server refuses to advertise my service/function?

Hello I'm writing a server whose job is to offer a 6DOF pose estimation, but I'm having problems advertising it as it seems that I'm giving it a function with too manny argument, even tough I'm following the tutorial very closely.

This is the relevant part from the node's main:

 ros::init(argc, argv, "epsilon");
 ros::NodeHandle nh("~");
 PoseServer server;
 ros::ServiceServer service = nh.advertiseService("/epsilon/get_pose", server.compute_Pose);
 ROS_INFO("Ready to estimate pose.");
 ros::spin();
 return 0;

And this is how I implemented compute_Pose within the PoseServer class:

bool PoseServer::compute_Pose(epsilon::Pose::Request &req,
                          epsilon::Pose::Response &res)
 {
   //Here I calculate the pose and store it as a string for now
   res.pozitie = pose_string;
 }

And this is the Pose.srv as I've named my .srv file and the package's working name is epsilon, it's not really supposed to work with string but I wanted to start with something simple and try to advertise it first:

string A
---
string pozitie

The error I got is:

no matching function for call to ‘ros::NodeHandle::advertiseService(const char [18], <unresolved overloaded function type>)’
note: candidates are:
/opt/ros/electric/stacks/ros_comm/clients/cpp/roscpp/include/ros/node_handle.h:821:17: note: template<class T, class MReq, class MRes> ros::ServiceServer ros::NodeHandle::advertiseService(const string&, bool (T::*)(MReq&, MRes&), T*)
//And a whole list of other candidate templates
/ros/node_handle.h:1111:17: note:   candidate expects 1 argument, 2 provided

I think it's telling that I have to add something more than req and res or less but I don't think that's allowed or maybe to declare them in another fashion but I don't see exactly how.

Edited to add my cmakelist.txt

cmake_minimum_required(VERSION 2.4.6)
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)

# Set the build type.  Options are:
#  Coverage       : w/ debug symbols, w/o optimization, w/ code-coverage
#  Debug          : w/ debug symbols, w/o optimization
#  Release        : w/o debug symbols, w/ optimization
#  RelWithDebInfo : w/ debug symbols, w/ optimization
#  MinSizeRel     : w/o debug symbols, w/ optimization, stripped binaries
#set(ROS_BUILD_TYPE RelWithDebInfo)


rosbuild_init()

rosbuild_add_boost_directories()

#set the default path for built executables to the "bin" directory
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
#set the default path for built libraries to the "lib" directory
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)

#uncomment if you have defined messages
rosbuild_genmsg()
#uncomment if you have defined services
rosbuild_gensrv()

rosbuild_add_executable(epsilon_node_1 src/epsilon_node_1.cpp)


#this is where I try to fix the boost bind problem the way you showed me
rosbuild_link_boost(epsilon_node_1 bind)
#How I solved it in the past
target_link_libraries(epsilon_node_1 ${Boost_FILESYSTEM_LIBRARY}    ${Boost_SYSTEM_LIBRARY} )

Maybe I'm reading the boost site wrong but I think bind should be in the bind library correct?

Edit: Now I'm not getting any more boost linking problems but it won't see the PoseServer constructor or computePose,even tough they're both clearly public, for either of the solutions this is how I advertise them in main:

//ros::ServiceServer service = nh.advertiseService("/epsilon/get_pose", &PoseServer::compute_Pose, &server);
ros::ServiceServer service = nh.advertiseService<epsilon::Pose::Request, epsilon::Pose::Response>("/epsilon/get_pose", boost::bind(&PoseServer::compute_Pose, server, _1, _2));

This is the type of error I'm getting, again not seeing the methods

undefined reference to `PoseServer::compute_Pose(epsilon::PoseRequest_<std::allocator<void> >&, epsilon::PoseResponse_<std::allocator<void> >&)'