Ask Your Question
0

How to use services ?

asked 2017-05-17 02:51:52 -0600

Milow gravatar image

updated 2017-05-17 02:53:48 -0600

According to this tutorial [ http://wiki.ros.org/ROS/Tutorials/Wri... ], I thought we could use a service like :

    client = n.serviceClient<std_srvs::Empty>("/reset_positions");
    ros::service::waitForService("/reset_positions");
    std_srvs::Empty reset_srv;
    client.call(reset_srv);

But execution is blocked on the waitForService instruction and return :

[ INFO] [1495007235.234008766]: waitForService: Service [/reset_positions] has not been advertised, waiting...

Is there something I missed to run this service ?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-05-17 03:00:08 -0600

NEngelhard gravatar image

It looks like you have only a client, but no node that is actually providing the service. What is the outout of 'rosservice list' before running your client?

edit flag offensive delete link more

Comments

There is only this two lines :
/rosout/get_loggers
/rosout/set_logger_level

How can I launch the node to provide the service ?

Milow gravatar image Milow  ( 2017-05-17 03:06:58 -0600 )edit

Just do the tutorial you linked...

NEngelhard gravatar image NEngelhard  ( 2017-05-17 09:28:36 -0600 )edit

I did it, I created a ServiceServer who is running a personnal service. I can call this service (only displaying a "hello world" when called). But I don't see how to use the reset_positions service to reset the position of my turtlebot.

Milow gravatar image Milow  ( 2017-05-17 09:33:05 -0600 )edit

So to reword, I know how to create my own service, but it's not what I want to do. I would like to run an existing service called "reset_positions". I can create a service called the same name and advertised it from a node and run that, that's the tutorial, but it would be useless to me. Any idea ?

Milow gravatar image Milow  ( 2017-05-18 02:47:33 -0600 )edit

Can anyone tell me how client.call function uses TCP protocol ?

shantanu543 gravatar image shantanu543  ( 2017-06-21 01:44:09 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-05-17 02:51:52 -0600

Seen: 744 times

Last updated: May 17 '17