How should I think about static sensor transforms?

asked 2018-05-09 14:02:34 -0500

seanarm gravatar image

updated 2018-05-10 10:52:19 -0500

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?

edit retag flag offensive close merge delete

Comments

1

Did you mean lookupTransform("drone_base", "rangeX", ... in the second one?

lucasw gravatar image lucasw  ( 2018-05-09 15:05:45 -0500 )edit

@lucasw yes, thank you

seanarm gravatar image seanarm  ( 2018-05-10 10:51:55 -0500 )edit

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.

jarvisschultz gravatar image jarvisschultz  ( 2018-05-10 15:11:45 -0500 )edit
jarvisschultz gravatar image jarvisschultz  ( 2018-05-10 15:12:21 -0500 )edit
1

#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 gravatar image lucasw  ( 2018-05-10 17:16:54 -0500 )edit
1

@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.

jarvisschultz gravatar image jarvisschultz  ( 2018-05-11 08:08:40 -0500 )edit
1

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 gravatar image gvdhoorn  ( 2018-05-11 08:41:16 -0500 )edit

@gvdhoorn Not annoying at all, and you are certainly correct that community effort could definitely improve the situation.

jarvisschultz gravatar image jarvisschultz  ( 2018-05-15 17:55:06 -0500 )edit