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?
Asked by seanarm on 2018-05-09 14:02:34 UTC
Comments
Did you mean
lookupTransform("drone_base", "rangeX", ...
in the second one?Asked by lucasw on 2018-05-09 15:05:45 UTC
@lucasw yes, thank you
Asked by seanarm on 2018-05-10 10:51:55 UTC
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.
Asked by jarvisschultz on 2018-05-10 15:11:45 UTC
Read more here: http://wiki.ros.org/tf/Overview/Transformations
Asked by jarvisschultz on 2018-05-10 15:12:21 UTC
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.
Asked by lucasw on 2018-05-10 17:16:54 UTC
@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.
Asked by jarvisschultz on 2018-05-11 08:08:40 UTC
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.
Asked by gvdhoorn on 2018-05-11 08:41:16 UTC
@gvdhoorn Not annoying at all, and you are certainly correct that community effort could definitely improve the situation.
Asked by jarvisschultz on 2018-05-15 17:55:06 UTC