How to rectify the frame rate drop that occurs while subscribing to the topic of camera image from ROS in Simulink ?
6 views (last 30 days)
Show older comments
I am trying to observe the camera feed captured by ros in simulink and even though the image is being published at 30fps when i try to observe in Simulink it reduces to around 5fps. I have used to ROS toolbox to subscribe to /camera/image_color and used read image block to observe the images in Simulink Video Viewer but the fps is 5 not 30 even though i checked the hz of the topic and verified it to be 30. Any possible solution to rectify this issue
0 Comments
Answers (1)
Cam Salzberger
on 28 Jan 2019
Hello Arun,
There are two major potential sources for the delay that I can think of offhand. One is that using subscribers on the topic involves copying the data in the message. For large amounts of data, like images, this can take considerable time. I would suggest ensuring that you are making use of enabled subsystems (enabling them with the IsNew output from the Subscribe block), to avoid passing along and copying data that is not actually from a new message. This also should cut down on time by avoiding processing non-new messages.
Another (usually larger) factor in slowing down processing of anything is visualization. In MATLAB, this typically comes from plotting data or outputting text to the Command Window. In Simulink, this includes using Scopes or viewing images. If your model is sensitive to the rate, I would highly suggest removing all visualization while the model is running. Instead, collect the output for later viewing.
Another possibility, if you are testing an algorithm, is to collect the camera data and save it, then process the file through your algorithm later. You can either save the data as a rosbag on your ROS machine or subscribe to the topic from within MATLAB, directly saving the data to a MAT file. If you are able to update to R2018b, you could even play back the rosbag within Simulink, and process the data with model time synced to the rosbag timestamps.
Hope this helps you to get things moving.
-Cam
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!