ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

Persistent Service reconnection

asked 2014-05-21 01:53:36 -0500

Boris_il_forte gravatar image

updated 2014-05-21 01:56:01 -0500

I'm using ros hydro.

I call a persistence service in this way:

connectToClassificationServer()
{
     classificationService = n.serviceClient<c_fuzzy::Classification>("classification", true);
}

then I use my service:

if (classificationService.isValid())
{

    classificationService.call(serviceCall);
}
else
{
    ROS_ERROR("Service down, waiting reconnection...");
    classificationService.waitForExistence();
    connectToClassificationServer(); //Why this??
}

the method isValid return always false if I don't re-create the service handler. And apparently there's no way to restart a persistent service (such as a 'reconnect' method).

it is correct to always recreate the ServiceClient? why I need to use the nodeHandler if I've already all the information needed inside the ServiceClient object?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-05-21 06:46:56 -0500

ahendrix gravatar image

A persistent service client refers specifically to keeping the TCP connection between the client and the server open; if the server shuts down and comes back, you have to re-establish the connection.

It may be worth filing a feature request against roscpp to make the API for this easier to use and more failure-tolerant.

edit flag offensive delete link more

Comments

+1 Persistent services that (optionally) try to re-establish the connection would be very valuable. Working your way around the existing API is possible, but can indeed be cumbersome. An added inconvenience is that currently it's not possible to query if a ServiceClient is persistent or not.

Adolfo Rodriguez T gravatar image Adolfo Rodriguez T  ( 2014-05-21 22:52:35 -0500 )edit
Adolfo Rodriguez T gravatar image Adolfo Rodriguez T  ( 2014-05-21 23:10:02 -0500 )edit

so, up to now, the "best" way is to recreate the ServiceClient from nodeHanlder?

Boris_il_forte gravatar image Boris_il_forte  ( 2014-05-22 04:01:30 -0500 )edit

I know of no other option.

Adolfo Rodriguez T gravatar image Adolfo Rodriguez T  ( 2014-05-22 04:56:44 -0500 )edit

This feature was implemented in Kinetic release. discussion Code Changes can be found here

mihir3445@gmail.com gravatar image mihir3445@gmail.com  ( 2020-06-10 12:55:16 -0500 )edit

Actually, it was not implemented. The PR died without getting added. The referenced source files, from kinetic to noetic, don't include that code.

JWCS gravatar image JWCS  ( 2021-02-02 00:40:45 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2014-05-21 01:53:36 -0500

Seen: 1,220 times

Last updated: May 21 '14