ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A answers.ros.org

No tf function for applying transformations?

I'm seeing this design strategy in the online course I'm doing:

translation = tf.transformations.translation_from_matrix(T)
rotation = tf.transformations.quaternion_from_matrix(T)
t.transform.translation.x = translation[0]
t.transform.translation.y = translation[1]
t.transform.translation.z = translation[2]
t.transform.rotation.x = rotation[0]
t.transform.rotation.y = rotation[1]
t.transform.rotation.z = rotation[2]
t.transform.rotation.w = rotation[3]


Is there a function for doing something like:

t.apply_translation(translation)
t.apply_rotation(rotation)


or

t.apply_transformation(translation=translation, rotation=rotation)


I think it would make for more readable code, and be faster to write. If there is a function like that, what is it? If not, why not?

Thanks! TT

edit retag close merge delete

Sort by ยป oldest newest most voted

From the snippet you posted it seems you are basically populating a geometry_msgs/TransformStamped message from the matrix conversions (done via transformations.py). ROS messages don't have apply methods like you have asked for but are often accompanied by conversion utilities/packages such as tf_conversions or eigen_conversions. For your particular case you might find something in posemath.py useful either directly or for some ideas on how to implement your own helpers/conversions.

more

Ahh, yes, this makes sense. I'm guessing then that what you're publishing as a message will vary enough that it makes sense to always include some kind of conversion utility, rather than just having a built in conversion utility.

( 2017-05-18 09:03:19 -0600 )edit

Stats

Seen: 190 times

Last updated: May 18 '17