reading tf data from ROSBAG is way to slow

5 次查看(过去 30 天)
I would like to get all tf data the whole run in a rosbag using a timeseries or struc object.
for i = 1:1000:tfselection.NumMessages
transformdata =cellfun(@(x) x.Transforms, readMessages(tfselection, [i:min(i+999,tfselection.NumMessages)]), 'UniformOutput', 0);
for im = 1:numel(transformdata)
for tfm = 1:numel(transformdata{im})
tt = transformdata{im}(tfm);
messages(index, :) = {tt.Header.Stamp.Sec + tt.Header.Stamp.Sec/10^9, tt.Header.FrameId, tt.ChildFrameId, tt.Transform.Translation, tt.Transform.Rotation};
index = index+1;
end
disp(['at ' num2str(im + i) ' from ' num2str(tfselection.NumMessages) ' msgs - containing ' num2str(index) ' msgs']);
end
end
since i was running out of java heap i access the messages in steps.
Without any perfomance boost I already tried
  • calling transformdata{im}(tfm).copy()
  • calling transformdata{im}(tfm).toStruc()
  • calling exthead = tt.header and using exthead.Stamp... etc..
Now I would like to use the vectorising functions like structfun and cell fun but unfortunately Im not quite sure how to implement these in this case.
Is this the fastest solution and can someone give me an hint please?
transformdata
1000x1 cell containing Nx1 TansformStamped where n can vary
  2 个评论
Robin
Robin 2017-11-7
编辑:Robin 2017-11-7
After a deeply debugging session I found out that the get method from the Message Classes costs the most time:
classdef TransformStamped < robotics.ros.Message
[...]
if isempty(obj.Cache.Header)
obj.Cache.Header = feval(obj.StdMsgsHeaderClass, obj.JavaMessage.getHeader);
end
header = obj.Cache.Header;
[...]
end
unfortunalety i don't dont have acces to these classes and I'm running out of options.
In HERE is briefly explained how to increase speed with slow java classes but nothing is giving me any boost.
Is there another way to read rosbag data without using java?
MathWorks Robotics and Autonomous Systems Team
Sorry for the delay in responding, in couple of weeks the R2018a Prerelease version is going to be out on mathworks.com, I strongly recommend you to try the latest "rosbag" and TF extraction functionality.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 ROS Log Files and Transformations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by