How should I think about static sensor transforms?
I have a drone where the drone_base
is represented in NWU coordinates. Then, I have a sensor on the right side of it, pointing to the right, represented by frame range1
. In writing my static_transform_publisher
, in order to transform from frame drone_base
to child range1
, I first translated to the point location of the sensor, then performed the rotation around the Z-axis by -pi/2 to point North to the right. The range message with range1
frame being published to RViz displays properly. Does that sound correct so far? The transform looks like this:
<node pkg="tf2_ros" type="static_transform_publisher" name="drone_base_range1_link_broadcaster" args="0.1 -0.15 0.041 -1.5708 0 0 drone_base range1" />
Here's where I get tripped up. I have four of these range measurements, two facing right and two facing left. I have a node that receives these range measurements as an array, and attempts to place the ranges in a PointCloud2 for re-publishing to RViz. I put the range into the X attribute of a PointStamped, with the same stamp and frame_id. Then I look up the transform and apply it:
auto transform = tfBuffer.lookupTransform("rangeX", "drone_base", ros::Time(0));
tf2::doTransform(inPt, outPt, transform);
(rangeX
where X = [0,1,2,3]
)
The points are in the incorrect positions. If I reverse the frame_ids in the lookup to:
auto transform = tfBuffer.lookupTransform("drone_base", "rangeX", ros::Time(0));
everything works fine. Is this the proper way to accomplish a child -> parent transform lookup? Or, what am I doing wrong?
Did you mean
lookupTransform("drone_base", "rangeX", ...
in the second one?@lucasw yes, thank you
Well what are you trying to look up? The transform that when applied to parent will give you child? Or the transform that will allow you to transform a point expressed in child into the parent frame? They are inverses of each other.
Read more here: http://wiki.ros.org/tf/Overview/Trans...
#q194046 points out one source of confusion, another is the terms parent/child vs. source/target, and the page above uses 'in'/'relative' ... my approach is to reverse the arguments if I don't get it right on the first try and move on, though that is slow for complex multiple transform situations.
@lucasw makes a good point. IMO, there is quite a lot of confusion around this point caused by lack of specificity and multiple terms terms being used inconsistently. I often follow his suggestion as well: try it one way, and if you get it wrong, flip the args.
I'm going to be annoying but: there is only one way this (the ambiguity) is going to change: if/when anyone of us steps up and fixes things.
@gvdhoorn Not annoying at all, and you are certainly correct that community effort could definitely improve the situation.