0
$\begingroup$

Rosanswers logo

First of all, I would like to say that I have some background in computer graphics (e.g., I know what homogenous transformations, etc., are). So, please, do not explain to me what matrix multiplications are.


I have a question regarding the sendTransform method of the class TransformBroadcaster.

The documentation says:

Broadcast the transformation from tf frame child to parent on ROS topic "/tf".

So, e.g., suppose we subscribe to the topic /turtle1/pose and, in the callback, we use sendTransform, for example

def _send_pose_transform(self, pose):
    br = tf.TransformBroadcaster()

    translation = (pose.x, pose.y, 0)
    rotation = tf.transformations.quaternion_from_euler(0, 0, pose.theta)

    br.sendTransform(translation, rotation, rospy.Time.now(),
                        self.turtle_name, self.parent_frame)

I have at least two questions.

The last two arguments of sendTransform are the child and parent frames. Can either the child or the parent frames be different than the frame of the object associated with the topic I subscribed to (i.e. /turtle1/pose), i.e. can the child or the parent frames be a frame which is not the local frame of turtle1? I suppose the answer is "yes", given that I don't see why this use case should be "forbidden".

Now, my actual questions/doubts.

What exactly does it mean to send a transformation from the child to the parent frame, in this case? Let's now assume that tf keeps track of the local frames of the child and the parent objects. Does "send a transformation from the child to the parent frame" actually mean that tf sends e.g. a homogenous matrix representing the transformation (i.e. rotation and orientation) of a point in the local frame of the child to a point in the local frame of the parent, or is it vice-versa, or something else?


Originally posted by nbro on ROS Answers with karma: 372 on 2018-04-12

Post score: 1

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Edit:

Does "send a transformation from the child to the parent frame" actually mean that tf sends e.g. a homogenous matrix representing the transformation (i.e. rotation and orientation) of a point in the local frame of the child to a point in the local frame of the parent, or is it vice-versa, or something else?

I would say this is more what the various transformX(..) methods in TF do. The TransformBroadcaster really only updates the transformation matrices that you refer to (but they're not encoded as matrices, but as separate Vector3 and Quaternion).

re-reading your question you might actually be saying the same as I was. The TransformBroadcaster is not about points, but the transformation matrices themselves. If that is what you were describing, then yes, that is what it is doing. The transformX(..) methods in TF(2) then use those to do the actual transformation of points between those frames.


Could this be a misinterpretation / misquote of the docs? "Broadcasting" is the word used in the docs. This just means: sending a msg to all who are/will listen. "Sending to" implies there is some unidirectional transfer going on. TF does not send anything "from X to Y" (well, the TransformBroadcaster does, but at a different level perhaps).

The example you show just broadcasts a single message that contains the information about a single transform "from the child to the parent frame". It's a piece of information that TF listeners will use to update their tree of transforms.

The "child" and "parent" are just labels (ie: names for humans), not entities in a ROS node graph (ie: nodes or similar active constructs) that receive or send any messages.

From the same docs on TransformBroadcaster:

TransformBroadcaster is a convenient way to send transformation updates on the "/tf" message topic.

All the methods in this class do is send out messages (geometry_msgs/TransformStamped) that inform listeners about a single or multiple edge(s) in the TF tree. Between each node a transformation matrix exists. For new transforms, an edge is added and the matrix attached. For existing transforms, the matrix is updated.


Originally posted by gvdhoorn with karma: 86574 on 2018-04-12

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by nbro on 2018-04-12:
Sorry, I am asking about the transformation itself which is sent, not to whom or to which topic it is sent.

Comment by gvdhoorn on 2018-04-12:
I believe I touched on that with the last paragraph.

You ask about TransformBroadcaster. That class inherently has to do with topics and msgs, because that is what is used to broadcast this information.

"a transformation" is not a thing in TF. Transforms are broadcast, those contain ..

Comment by gvdhoorn on 2018-04-12:
.. translations and rotations in separate fields (but conceptually the same as the matrix you're referring to).

So to broadcast a transform is to publish a msg that contains that information. That is then used by listeners to insert or update edges in their local view of the tree.

Comment by nbro on 2018-04-12:
@gvdhoorn Ok, thanks, it starts to make more sense. I think we should add this "verbose" but, IMHO, helpful description/explanation to the documentation of those methods so that we don't have to click a few times to infer what those methods do.

Comment by gvdhoorn on 2018-04-12:
It's all open-source. There is a good chance an update to the documentation submitted in a PR would be accepted. For TF, the sources are here. For TF2 here.

Note that TF (not TF2) is deprecated.

Comment by nbro on 2018-04-12:
You're saying that TransformStampeds, which are sent, already exist, and we only update them using sendTransform. However, in this tutorial, http://wiki.ros.org/tf/Tutorials/Adding%20a%20frame%20%28Python%29, a new local frame is created using sendTransform...

Comment by gvdhoorn on 2018-04-12:
TransformStamped is just the msg containing the information. The internal data structure may be different. Doesn't matter, as long as the information (ie: transform) is retained.

re: new or existing: doesn't matter. Both can be done. Each broadcaster notifies listeners that it has ..

Comment by gvdhoorn on 2018-04-12:
.. (potentially) new information. If the listener already knew about the transform (ie: received msgs about it earlier), then it updates its internal view of the tree. If it's new, it incorporates the new info (ie: add edge(s)).

Comment by gvdhoorn on 2018-04-12:
This reminds me of a question about two weeks ago (can't find it). The OP there also asked about "when do TF frames 'exist'".

Thing is, they don't really. It's (conceptually) just a big tree of vertices and edges with transform matrices attached (it's not really necessarily, but it helps).

Comment by gvdhoorn on 2018-04-12:
It's perfectly ok for a listener to have only a partial view of the big, global tree. It'll just mean that if you ask it to transform between frames it hasn't heard about, you'll get a LookupException.

If your TF tree has missing edges, that's a problem too.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.