ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

No tf function for applying transformations?

asked 2017-05-18 07:30:33 -0500

TristanTrim gravatar image

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 flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2017-05-18 08:48:04 -0500

BrettHemes gravatar image

updated 2017-05-18 08:49:56 -0500

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.

edit flag offensive delete link more

Comments

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.

TristanTrim gravatar image TristanTrim  ( 2017-05-18 09:03:19 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2017-05-18 07:28:02 -0500

Seen: 222 times

Last updated: May 18 '17