Why is my ROS node running slower than expected when deployed?

I am generating a ROS node from a Simulink model and deploying to an embedded computer. My model includes ROS Publisher/Subscriber blocks within an enabled subsystem, so that my algorithm only runs when a message is received. When I set the sample time in Solver Parameters to 200 Hz, and then inherit this sample time in my Subscriber block, I can only achieve performance of 30 Hz upon deployment. Why is this the case and how can I improve performance?

 Accepted Answer

In some cases, increasing the "Length of the subscribe callback queue" parameter on the Subscribe block may resolve the issue. See the following documentation to learn more about this parameter:
Please run the following command in the command window of MATLAB R2020a to access the release-specific documentation:
>> web(fullfile(docroot, 'ros/ref/subscribe.html'))
It is possible that if messages arrive very fast and the queue is not large enough, roscpp will start throwing away messages, as described in the roscpp documentation here: http://wiki.ros.org/roscpp/Overview/Publishers%20and%20Subscribers#Subscriber_Options
Please follow the below link to search for the required information regarding the current release:

More Answers (0)

Products

Release

R2020a

Tags

No tags entered yet.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!