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

What is the best way to transform the frame of a twist?

asked 2022-07-03 05:35:14 -0500

Myzhar gravatar image

updated 2022-07-03 05:36:24 -0500

Hi all, before searching for an external library, I would like to know if ROS/ROS2 have a module to convert a twist from a frame to another. In particular I would like to convert a visual odometry twist from the camera frame to the base_link for obvious reasons.

Thanks Walter

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2022-07-03 07:22:08 -0500

ljaniec gravatar image

Maybe standard tf2 library will suit you - there you have a nice tutorial from Nav2 documentation:

https://navigation.ros.org/setup_guid...

(...)

Now let’s try publishing a very simple transform using the static_transform_publisher tool provided by TF2. We will be publishing a transformation from the link base_link to the link base_laser with a translation of (x: 0.1m, y: 0.0m, z: 0.2m). Note that we will be building the transform from the diagram earlier in this tutorial.

Open up your command line and execute the following command:

ros2 run tf2_ros static_transform_publisher 0.1 0 0.2 0 0 0 base_link base_laser

With this, we are now sucessfully publishing our base_link to base_laser transform in TF2. Let us now check if it is working properly through tf2_echo. Open up a separate command line window and execute the following:

ros2 run tf2_ros tf2_echo base_link base_laser

You should be able to observe a repeated output simiar to the one below.

At time 0.0
- Translation: [0.100, 0.000, 0.200]
- Rotation: in Quaternion [0.000, 0.000, 0.000, 1.000]
edit flag offensive delete link more

Comments

As far as I know TF2 does not provide twist transformation, but only pose transformation. Twist transformations require Lie Algebra SO(3), Sophus is a known library providing it, but I do not know if it's directly available for ROS/ROS2: https://github.com/strasdat/Sophus

Myzhar gravatar image Myzhar  ( 2022-07-03 07:29:42 -0500 )edit

Ok, I misunderstood your question, sorry. But fear not, Sophusis used in ROS 1: https://wiki.ros.org/sophus and some users ported it to ROS2 as well: https://github.com/stonier/sophus (e.g. for Turtlebot 2 migration from ROS1 to ROS2)

ljaniec gravatar image ljaniec  ( 2022-07-03 11:20:28 -0500 )edit
2

Could make for a nice contribution: transforming Twist (and Accel and further derivatives) has been requested a couple of times already. The accepted answer is typically along the lines of: convert to your math framework of choice, transform there, then convert back to ROS/TF.

But the same argument could be made for transforming regular Poses as well.

Perhaps a package extending TF with transform(..) methods for Twist et al. using something like Sophus could fill this gap, in a nice pluggable way (ie: contribute to the tf namespace, not extending base tf2_ros itself).

gvdhoorn gravatar image gvdhoorn  ( 2022-07-05 01:43:01 -0500 )edit

Question Tools

3 followers

Stats

Asked: 2022-07-03 05:35:14 -0500

Seen: 776 times

Last updated: Jul 03 '22