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

Timeout error in service defined in matlab

asked 2015-08-31 05:54:52 -0500

musiv gravatar image

updated 2021-12-03 09:51:32 -0500

Evgeny gravatar image

Hi all!

I am using ROS support from MATLAB, and came across an issue which seems strange to me, and would really appreciate your input on this. In short, I am creating a service (and its callback) from within MATLAB and every time I call this service and the callback lasts for more than a few seconds the caller receives the following error message: "The service server returned an error: "A timeout occurred while waiting for a response of the service server.". This behavior is the same if the service is called from MATLAB, python, C++ or shell.

This seems strange to me as there is no timeout defined anywhere in my code, neither anywhere in the caller. Does anyone came across a similar issue? Thanks in advance!

edit retag flag offensive close merge delete

Comments

1

This is not an answer, more a remark, but in general it's considered bad practice to have service calls take longer than <insert arbitrary max length> here. For long running operations, it's recommended to use actions. Not sure whether matlab supports those though.

gvdhoorn gravatar image gvdhoorn  ( 2015-08-31 08:40:49 -0500 )edit

Thanks for your comment, gvdhoorn. It is important to know that. Indeed, matlab currently does not support actions, thus we must rely on services.

musiv gravatar image musiv  ( 2015-08-31 12:16:07 -0500 )edit

Hi musiv, Did you happen to find a resolution for this at all? I am having the same issue. Thanks, James

jsergeant gravatar image jsergeant  ( 2016-08-15 22:10:19 -0500 )edit

jsergeant, I didn't. As far as I remember, this behavior is hardcoded somewhere in the java code that implements ROS functionalities in Matlab. My workaround was to implement one service on the server that receives the original service request, and other in the caller that receives the response info

musiv gravatar image musiv  ( 2016-08-18 08:28:08 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-08-18 22:06:46 -0500

jsergeant gravatar image

updated 2016-08-18 22:07:51 -0500

Hi,

The awesome Remo from MathWorks helped me through this process however it involves modifying the Matlab ROS Toolbox.

Enter edit robotics.ros.ServiceServer to open the ServiceServer.m file in your editor.

Search for the following line (should be on or around line 173):

obj.ResponseBuilder = com.mathworks.toolbox.robotics.ros.service.ServiceResponseBuilder;

You can now manually change the default timeout to a value other than 10 seconds by adding additional code. If you want your default timeout to be 2 minutes (120 seconds), add the following line:

obj.ResponseBuilder.setTimeout(120000);

Save the file and execute

rehash toolboxcache

Restart Matlab. After that, your service server should wait longer before returning a timeout message. Given extra effort you can probably break this out as an input argument when setting up the service server.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2015-08-31 05:54:52 -0500

Seen: 818 times

Last updated: Aug 18 '16