- Try creating the service client in MATLAB using DataFormat-struct. This feature was implemented specifically to improve performance, though using object messages would not be responsible for the 7-8 second delay you are seeing, so expect improvement to be marginal.
- Ensure that your VM has sufficient resources. Increase the amount of RAM, cores, and memory it is allowed to use, as Gazebo can be quite resource-intensive.
- Try calling the service with the profiler running (profile on; call(client, msg); profile off; profile viewer) to see where the delay is occurring. If it's in "waiting" method, then the slow-down is on the external side of things.
- Check if you encounter the same issue with all services. Shut down Gazebo, start a new Core, and just try running in a Melodic terminal:
Long delay calling ROS service
8 views (last 30 days)
Show older comments
Hello, I've been having some issues with Matlab's ROS service caller since upgrading from release 2020a to 2021a. I have a robot running in Gazebo and I'm trying to make a call on the '/gazebo/apply_body_wrench' service in Matlab, but it consistantly takes 7-8 seconds for the client to receive a response from the server. When making the same service call natively in ROS via the service caller plugin in rqt_gui, there is no response delay. What can be done to reduce the long delay while calling the service from Matlab?
0 Comments
Answers (1)
Cam Salzberger
on 27 Sep 2021
Hello Bryce,
I wasn't able to reproduce this on my machine with R2021a and the standard Melodic VM. I tested with both the PR2 simulator and the Gazebo Empty worlds, and both returned immediately to my service call, whether it was successful or not. Setting different start times or durations for applying the wrench didn't matter either.
The only suggestions I can give you are general ones then:
rosrun roscpp_tutorials add_two_ints_server
Then make a client and call that service from MATLAB.
client = rossvcclient('/add_two_ints');
msg = rosmessage(client);
msg.A = 1;
msg.B = 2;
call(client, msg)
If this also sees the delay, then the issue is probably with the network communication or the VM. If you do not see the slow down, then the issue is probably with Gazebo or that specific world/model/command.
-Cam
See Also
Categories
Find more on Network Connection and Exploration in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!