pass additional arguments into advertiseService
Hi,
is there a way to pass additional arguments into advertiseService ?
When i use a Subscriber i can use boost::bind
to pass arguments to the callback function. Like this:
ros::Subscriber sub = nh.subscribe<cob_people_detection::Commands> ("/tuw_acin_eva/voice_commands", 1, boost::bind(commandCallback, _1, &sensor_message_gateway_open_client));
Can i adapt this approach to make it work with advertiseService ? I tried it with this
ros::ServiceServer service = nh.advertiseService<tuw_acin_eva::VoiceCommands> ("process_voice_commands", boost::bind(processVoiceCommands, _1, &sensor_message_gateway_open_client));
but it does not work.
Edit: 1
Sorry for not including the complete error message. Here it is now.
[ rosmake ] Last 40 linesw_acin_eva: 4.6 sec ] [ 1 Active 50/51 Complete ]
{-------------------------------------------------------------------------------
[ 57%] [ 57%] Built target rospack_gensrv_all
Built target rosbuild_precompile
make[3]: Entering directory `/home/bajo/workspace/tuw_acin_eva/build'
make[3]: Entering directory `/home/bajo/workspace/tuw_acin_eva/build'
make[3]: Entering directory `/home/bajo/workspace/tuw_acin_eva/build'
make[3]: Leaving directory `/home/bajo/workspace/tuw_acin_eva/build'
make[3]: Leaving directory `/home/bajo/workspace/tuw_acin_eva/build'
[ 85%] [ 85%] Built target tuw_acin_eva_main
Built target tuw_acin_eva_facefollower
Scanning dependencies of target tuw_acin_eva_cob_control
make[3]: Leaving directory `/home/bajo/workspace/tuw_acin_eva/build'
make[3]: Entering directory `/home/bajo/workspace/tuw_acin_eva/build'
[100%] Building CXX object CMakeFiles/tuw_acin_eva_cob_control.dir/nodes/tuw_acin_eva_people/src/tuw_acin_eva_cob_control.o
In file included from /opt/ros/fuerte/include/ros/ros.h:45:0,
from /home/bajo/workspace/tuw_acin_eva/nodes/tuw_acin_eva_people/src/tuw_acin_eva_cob_control.cpp:13:
/opt/ros/fuerte/include/ros/node_handle.h: In member function ‘ros::ServiceServer ros::NodeHandle::advertiseService(const string&, const boost::function<bool(S&)>&, const VoidConstPtr&) [with S = tuw_acin_eva::VoiceCommands, std::string = std::basic_string<char>, ros::VoidConstPtr = boost::shared_ptr<const void>]’:
/home/bajo/workspace/tuw_acin_eva/nodes/tuw_acin_eva_people/src/tuw_acin_eva_cob_control.cpp:288:181: instantiated from here
/opt/ros/fuerte/include/ros/node_handle.h:1087:5: error: no matching function for call to ‘ros::AdvertiseServiceOptions::initBySpecType(const string&, const boost::function<bool(tuw_acin_eva::VoiceCommands&)>&)’
/opt/ros/fuerte/include/ros/node_handle.h:1087:5: note: candidate is:
/opt/ros/fuerte/include/ros/advertise_service_options.h:104:8: note: template<class Spec> void ros::AdvertiseServiceOptions::initBySpecType(const string&, const typename Spec::CallbackType&)
In file included from /usr/include/boost/bind.hpp:22:0,
from /opt/ros/fuerte/include/ros/publisher.h:35,
from /opt/ros/fuerte/include/ros/node_handle.h:32,
from /opt/ros/fuerte/include/ros/ros.h:45,
from /home/bajo/workspace/tuw_acin_eva/nodes/tuw_acin_eva_people/src/tuw_acin_eva_cob_control.cpp:13:
/usr/include/boost/bind/bind.hpp: In member function ‘R boost::_bi::list2<A1, A2>::operator()(boost::_bi::type<R>, F&, A&, long int) [with R = bool, F = bool (*)(tuw_acin_eva::VoiceCommandsRequest_<std::allocator<void> >&, tuw_acin_eva::VoiceCommandsResponse_<std::allocator<void> >&), A = boost::_bi::list1<tuw_acin_eva::VoiceCommands&>, A1 = boost::arg<1>, A2 = boost::_bi::value<ros::ServiceClient*>]’:
/usr/include/boost/bind/bind_template.hpp:32:59: instantiated from ‘boost::_bi::bind_t<R, F, L>::result_type boost::_bi::bind_t<R, F, L>::operator()(A1&) [with A1 = tuw_acin_eva::VoiceCommands, R = bool, F = bool (*)(tuw_acin_eva::VoiceCommandsRequest_<std::allocator<void> >&, tuw_acin_eva::VoiceCommandsResponse_<std::allocator<void> >&), L = boost::_bi::list2<boost::arg<1>, boost::_bi::value<ros::ServiceClient*> >, boost ...
It should work. Please be more specific. Can you show us the complete error message? Make sure you have a look at http://ros.org/wiki/Support
Thank you for your comment. I posted the complete error down below.