MATLAB ROS Transform Error

4 visualizaciones (últimos 30 días)
Carl Stahoviak
Carl Stahoviak el 14 de Feb. de 2019
Comentada: Cam Salzberger el 1 de Mayo de 2020
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 comentarios
Carl Stahoviak
Carl Stahoviak el 14 de Feb. de 2019
Editada: Carl Stahoviak el 14 de Feb. de 2019
Thank you Cam. The problem was that only the very first radar message had a timestamp that just barely (in the Nsecs range) pre-dated the first transfrom message. So all other messages in the bag can be properly transformed.
I have a follow up question though. I think there is an error in the following documentation page: https://www.mathworks.com/help/robotics/ref/apply.html#buqbf3f-entity
The list of transformable entities includes the type: geometry_msgs/PointCloud2Stamped
However, in ROS, there is no such thing as a PointCloud2Stamped message. Did the documentation mean to refer to the sensor_msgs/PointCloud2 message type?
This message type is listed in the entity types under the documentation page that describes the transform() function: https://www.mathworks.com/help/robotics/ref/transform.html#buqbzo2-entity
Cam Salzberger
Cam Salzberger el 1 de Mayo de 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

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre ROS Log Files and Transformations en Help Center y File Exchange.

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by