It seems like there is an internal timeout. I used this basic simple callback function
function resp = test_timenout(~,~,resp)
tic
pause(10)
disp('A service client is calling');
toc
end
And called the service with the following commands:
%Creating a service
testserver = rossvcserver('/test', 'std_srvs/Empty', @test_timenout)
%Creating a client
testclient = rossvcclient('/test')
%Creating a message for the service
testreq = rosmessage(testclient)
%Calling the service
testresp = call(testclient,testreq,'Timeout',7);
For the last line I get the expected error that a timeout occured
Error using ros.ServiceClient/call (line 254)
The service call timed out after waiting 7.00 seconds for a response. Try a longer timeout.
However if I increase the timeout (e. g. up to 20) or if I don't define it I get the following error:
Error using ros.ServiceClient/call (line 260)
The service server returned an error: "A timeout occurred while waiting for a response of the
service server.".
If I decrease the time that the callbackfunction waits to 9s (by replacing pause(10) by pause(9))the error disappears and everthing works fine. Sadly this is not a solution, for my problem