ros2 / geometry2

A set of ROS packages for keeping track of coordinate transforms.
BSD 3-Clause "New" or "Revised" License
113 stars 193 forks source link

Why does tf2 geometry msgs treat a transform as an affine transformation (rotation before translation)? #640

Closed roshambo919 closed 6 months ago

roshambo919 commented 7 months ago

It is my understanding that, in tf2_geometry_msgs, conversions use PyKDL to do transformations (e.g., in do_transform_point here). This means that the translation and rotation of the transform are used to construct a classic transformation matrix:

T = [[ M,  p],
     [ 0,  1]]

When this type of transformation is applied to a point, the rotation of the point happens first, then the point is translated in the new rotated frame. I thought tf2 applied the translation before the rotation according to some forums?

Is this not inconsistent? Can someone clear this up?

roshambo919 commented 7 months ago

This could be a useful discussion point.

Transforms are specified in the direction such that they will transform the coordinate frame "frame_id" into "child_frame_id" in tf::StampedTransform and [geometry_msgs/TransformStamped](http://docs.ros.org/en/api/geometry_msgs/html/msg/TransformStamped.html). This is the same transform which will take data from "child_frame_id" into **"frame_id".**

I recommend better documentation of do_transform_point and do_transform_pose to illustrate how to use them properly.

sloretz commented 6 months ago

@tfoote would you be willing to describe how transformations are done in tf2? 🧇

tfoote commented 6 months ago

That's not my understanding of the definition of an affine transform. And you're citing the documentation for publishing transforms versus applying transforms. In particular when you change this semantic the value is inverted. And then it will consequently reverse the order of applying the transform.

The API will return you the transform to move a point from the source frame to the target frame. Do transform should apply the transform to the data to move it from the source to target. In the case of a point it is just a left multiply by the transform. This allows you to implement it for more complex data types.

For more help please ask a question on stack exchange and make sure to provide some concrete examples of what you think should be happening as well as what is not working for you.