MATLAB ROS Transform Error
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I'm getting the following error when atempting to use getTransform():
"Lookup would require extrapolation into the past. Requested time Wed Feb 13 14:23:57 2019 but the earliest data is at time Wed Feb 13 14:23:57 2019 when looking up transform from frame [base_link] to frame [world]"
This error makes it seem as though the transform should be available... but it's not.
Additionally, canTransform() returns a logical 0 when requesting a transform at that time. What's going on here?
Code below:
bagfile = 'multiradar_2019-02-13_rangeRes_0-04_velRes_0-09_loop.bag'
bag = rosbag(bag_file);
% topic information
radar_topic = 'radar_fwd/mmWaveDataHdl/RScan';
% Understand how to use ROS TFs in MATLAB
radar_bag = select(bag,'Topic',radar_topic);
radar_messages = readMessages(radar_bag);
radar_struct = readMessages(radar_bag,'DataFormat','struct');
radar_x = readField(radar_messages{1}, 'x');
radar_y = readField(radar_messages{1}, 'y');
radar_z = readField(radar_messages{1}, 'z');
for i=1:radar_struct{1}.Width
%transform each point in radar message to 'world' frame
pt = rosmessage('geometry_msgs/PointStamped');
pt.Header.FrameId = radar_struct{1}.Header.FrameId;
pt.Header.Stamp = rostime(radar_struct{1}.Header.Stamp.Sec, ...
radar_struct{1}.Header.Stamp.Nsec);
pt.Point.X = radar_x(i);
pt.Point.Y = radar_y(i);
pt.Point.Z = radar_z(i);
% transform point in 'radar_fwd_link' frame to 'world' frame
tfTime = rostime(radar_struct{attempting 1}.Header.Stamp.Sec, ...
radar_struct{1}.Header.Stamp.Nsec);
if canTransform(bag,'world',radar_struct{1}.Header.FrameId,tfTime)
disp('TF available!')
tf = getTransform(bag,'world',radar_struct{1}.Header.FrameId,tfTime, ...
'Timeout',5);
tfpt = apply(tf,pt);
else
disp('TF not available!')
end
disp([pt.Point.X, pt.Point.Y, pt.Point.Z])
tf = getTransform(bag,'world',radar_struct{1}.Header.FrameId,tfTime)
tfpt2 = apply(tf,pt)
end
3 Kommentare
Cam Salzberger
am 1 Mai 2020
Hey Carl,
Jeeze this took me a long time to get back to you. Yes, that is a typo. If you check the help text for the "apply" method, you'll notice it is correct there:
m = rosmessage('geometry_msgs/TransformStamped');
help apply
I'll put in a note to the appropriate team to update the documentation. Thanks again!
-Cam
Antworten (0)
Siehe auch
Kategorien
Mehr zu Specialized Messages finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!