ros / geometry

Packages for common geometric calculations including the ROS transform library, "tf". Also includes ROS bindings for "bullet" physics engine and "kdl" kinematics/dynamics package.
173 stars 274 forks source link

Potential issue of switched variables #192

Closed danielwangksu closed 4 years ago

danielwangksu commented 5 years ago

Not sure if this is a potential issue, the order of variable is reverse to the definition. This could be confusing

source_frameid, target_frameid

https://github.com/ros/geometry/blob/ea5eb79f479223d2b95f0a5e051554fbaceca7ff/tf/src/tf_echo.cpp#L112

https://github.com/ros/geometry/blob/ea5eb79f479223d2b95f0a5e051554fbaceca7ff/tf/include/tf/tf.h#L206

https://github.com/ros/geometry/blob/ea5eb79f479223d2b95f0a5e051554fbaceca7ff/tf/src/tf_echo.cpp#L122

https://github.com/ros/geometry/blob/ea5eb79f479223d2b95f0a5e051554fbaceca7ff/tf/include/tf/tf.h#L242

matt-attack commented 4 years ago

I've also run into this issue. It has led to a lot of confusion on our end since it returns the inverse of the expected transform.

@tfoote do you know if this is expected behavior for tf_echo or should the order be swapped to match the functions?

If it is expected behavior that should probably be documented and made more clear.

tfoote commented 4 years ago

The transform from A to B is the inverse of the transform from B to A. To get the inverse directly you just change the order of the arguments.

If you're printing the transform of Frames A to B it's the inverse of the transform to move data from A to B. Thus when you're echoing the transforms for the frames A to B you have to switch the source and target frames which are specifically referring to moving data from source to target.

The echo command print the transform for the coordinate frames not for the data so they're inverse and thus reversed.