tf2 convert python

asked 2020-10-17 17:32:32 -0600

plafer gravatar image

My ultimate goal is to transform a Twist between two frames. Unfortunately, this doesn't seem to be included in the documentation, and the source code documentation links are often broken for Python.

After much research, I found that there is a function do_transform_twist(twist, transform) in /opt/ros/kinetic/lib/python2.7/dist-packages/tf2_kdl/tf2_kdl.py, which is exactly what I need! However, the twist is of type PyKDL.Twist, so I need to convert my geometry_msgs/Twist to PyKDL.Twist.

After some more research, I found that there is a convert() method in /opt/ros/kinetic/lib/python2.7/dist-packages/tf2_ros/buffer_interface.py, which uses ConvertRegistration. Essentially, I would expect to see a call ConvertRegistration().add_to/from_msg() somewhere. I grep'd /opt/ros/kinetic/lib/python2.7/dist-packages/ for that, and didn't find any which registered such methods.

My question is then: Is such a conversion from geometry_msgs/Twist to PyKDL.Twist provided somewhere? If not, am I expected to write my own? Or, what is the canonical way to transform a Twist between two frames in tf2?

Note: As you can see, figuring out how to do things in tf2 is currently extremely difficult, since the documentation is lacking (which has been discussed previously on this forum). I would be happy to help with that, however I still am not an expert in using/understanding the library.

Thank you!

edit retag flag offensive close merge delete