Clear Filters
Clear Filters

Using readMessages() on ROS bag gives incomplete TF data

2 views (last 30 days)
I have read TF messages in Matlab from a recorded ROS bag but realised some of them are missing. I have recordings of the Baxter robot. I've attached a 5s sample of the bag (bag_sample_5s.bag) and the Matlab extracted messages (tfMsgs_sample.mat). Inspecting element tfMsgs{5, 1}.Transforms(10, 1).Transform.Translation gives (x,y,z) as expected but the values are not as expected.
Looking at the same rosbag in rviz and inspecting the same frame "reference/left_hand" I notice that there exists a "Position" and "Orientation" message but also a "Relative Position" and "Relative Orientation" message.
The "Position" as viewed in rviz is correct and the value I want to extract but Matlab appears to be reading the "Relative Position" which is incorrect. Given that no other messages are present in the Matlab message structure I'm puzzled at how to get to the data I need!
Any help greatly appreciated.
bag = rosbag(ROSBagPath);
tfBag = select(bag, 'Time',[start, stop],'Topic','/tf');
nMesgs = tfBag.NumMessages;
tfMsgs = readMessages(tfBag);

Answers (1)

YJ Lim
YJ Lim on 27 Aug 2018
With live ROS connection, you can use existing rostf function (shipping in 15a - https://www.mathworks.com/help/robotics/ref/robotics.transformationtree.html?searchHighlight=rostf&s_tid=doc_srchtitle)
From rosbag file, tf extraction can only get the relative transforms before R2018a. In R2018a, we have added AvailableFrames/getTransform in rosbag selection to get tf between two coordinate frames. (https://www.mathworks.com/help/robotics/ref/bagselection.html)

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!