Ask Your Question

Why does service not work from launch file ?

asked 2021-07-06 23:05:00 -0500

elpidiovaldez gravatar image

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 ?

edit retag flag offensive close merge delete


Is permanent actually persistent here?

gvdhoorn gravatar image gvdhoorn  ( 2021-07-07 04:08:35 -0500 )edit

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.

elpidiovaldez gravatar image elpidiovaldez  ( 2021-07-12 11:28:04 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2021-07-12 12:11:56 -0500

elpidiovaldez gravatar image

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) {
  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.

edit flag offensive delete link more

answered 2021-07-07 02:44:34 -0500

appie gravatar image

roslaunch used to run nodes and setting parameters. So you need to start the service within your node using rosparam and getting the parameters from the launch file

edit flag offensive delete link more

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


Asked: 2021-07-06 23:05:00 -0500

Seen: 171 times

Last updated: Jul 12 '21