Running ros service
How to run a ros service (not a personnal one, I have already read the tutorial about create personnal service and use them) ? I saw on this question http://answers.ros.org/question/20161... that create a serviceClient was enough. But in my case a simple
client = n.serviceClient<std_srvs::Empty>("/reset_positions");
ros::service::waitForService("/reset_positions");
return
[ INFO] [1495007235.234008766]: waitForService: Service [/reset_positions] has not been advertised, waiting...
I deduce the node isn't running. But I thougth /reset_positions
was a ros service and would run in background when starting roscore.
After a roscore
, when I run rosservice list
, it returns :
/dynamic_map
/gmapping/get_loggers
/gmapping/set_logger_level
/rosout/get_loggers
/rosout/set_logger_level
So obviously, there is no /reset_positions
service running.
I'm a bit lost, what I'm supposed to do to use the reset_position
service ?
Are you running the ServiceServer on the same topic? The server advertises the service. roscore does not automatically start services, custom or otherwise. It only starts the default logger service servers
Okay for roscore. I don't see what I have to advertise. I can do :
and do the process into a foo function. But it's just a personnal service called with the same name as a ros service. How can I advertise a ros service ?
I do not understand the term "personal service" You can setup your Server with: ros::ServiceServer service = n.advertiseService("/reset_positions", foo); bool foo(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res){ /* process stuff */}
As I understand ros, there are services implemented by ros (which I would like to call) and services users can code by their own. By "personnal service", I mean a service implemented by me (user).
I thought
reset_positions
could reset the position of my turtlebot without I had to implement the foo function.On [ https://github.com/ros-simulation/sta... ] it's write :
Added reset_positions service to stage (adds dependency on std_srvs).
I don't understand the purpose of adding a service if I have to recode it.In this case you should start the node of this package that runs the ServiceServer
Okay it's working, thanks