0
$\begingroup$

Rosanswers logo

I create a permanent service, and its client in my launch file. All subsequent service calls fail. I have discovered that if I kill the client and run it from the command line, then the service calls work. The service also works if I call it directly from the command line using 'rosservice'.

I have also discovered that making the service temporary solves the issue. I suspect that the launch file does something before the service is ready, but I don't know what.

I still want to use a permanent service for efficiency. What can I do to fix the problem ?


Originally posted by elpidiovaldez on ROS Answers with karma: 142 on 2021-07-06

Post score: 0


Original comments

Comment by gvdhoorn on 2021-07-07:
Is permanent actually persistent here?

Comment by elpidiovaldez on 2021-07-12:
Yes, I did mean 'persistent'. I don't even remember where I got the idea they were called 'permanent' connections now. It was something I read while investigating them.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

I found a discussion on ROS Answers which solved the issue for me. It is here.

I simply needed to wait for the service to be created, by the launch file, before I create the service client. The way to do it is shown below:

void InitializeTTS(ros::NodeHandle &n) {
  ros::service::waitForService("/tts");
  TTSclient = n.serviceClient<tts_serv::Gtts>("/tts",true);
}

Thanks to @appie for the advice. I looked at rosparam documentation, but I could not see how to use it to solve my issue.


Originally posted by elpidiovaldez with karma: 142 on 2021-07-12

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.