The message_tf_frame_transformer package provides a ROS / ROS 2 node(let) to transform ROS messages of arbitrary type to a different coordinate frame. This can be helpful if you cannot or do not want to modify the source code of other ROS nodes that require your data to be valid in a specific coordinate frame. Simply launch the message_tf_frame_transformer node and transform arbitrary ROS message to a target coordinate frame.
The message_tf_frame_transformer package is released as an official ROS / ROS 2 package and can easily be installed via a package manager.
sudo apt install ros-$ROS_DISTRO-message-tf-frame-transformer
If you would like to install message_tf_frame_transformer from source, simply clone this repository into your ROS workspace. All dependencies that are listed in the ROS package.xml
can be installed using rosdep.
# message_tf_frame_transformer$
rosdep install -r --ignore-src --from-paths .
# ROS 2
# workspace$
colcon build --packages-up-to message_tf_frame_transformer --cmake-args -DCMAKE_BUILD_TYPE=Release
# ROS
# workspace$
catkin build -DCMAKE_BUILD_TYPE=Release message_tf_frame_transformer
message_tf_frame_transformer is also available as a Docker image, containerized through docker-ros.
# ROS
docker run --rm ghcr.io/ika-rwth-aachen/message_tf_frame_transformer:ros
# ROS 2
docker run --rm ghcr.io/ika-rwth-aachen/message_tf_frame_transformer:ros2
In order to transform messages on topic $INPUT_TOPIC
to frame $TARGET_FRAME_ID
and publish them to topic $OUTPUT_TOPIC
, the message_tf_frame_transformer node can be started with the following topic remappings and parameter setting. Only the target_frame_id
parameter is required. The source_frame_id
parameter is only required for non-stamped messages without an std_msgs/Header
. The topics default to ~/input
and ~/transformed
in the node's private namespace.
# ROS 2
ros2 run message_tf_frame_transformer message_tf_frame_transformer --ros-args \
-r \~/input:=$INPUT_TOPIC \
-r \~/transformed:=$OUTPUT_TOPIC \
-p source_frame_id:=$SOURCE_FRAME_ID \
-p target_frame_id:=$TARGET_FRAME_ID
# ROS
rosrun message_tf_frame_transformer message_tf_frame_transformer \
~input:=$INPUT_TOPIC \
~transformed:=$OUTPUT_TOPIC \
_source_frame_id:=$SOURCE_FRAME_ID \
_target_frame_id:=$TARGET_FRAME_ID
The provided launch file enables you to directly launch a tf2_ros/static_transform_publisher
alongside the message_tf_frame_transformer node. This way you can transform a topic to a new coordinate frame with a single command.
# ROS 2
ros2 launch message_tf_frame_transformer message_tf_frame_transformer.launch.ros2.xml \
input_topic:=$INPUT_TOPIC \
output_topic:=$OUTPUT_TOPIC \
source_frame_id:=$SOURCE_FRAME_ID \
target_frame_id:=$TARGET_FRAME_ID \
x:=$X \
y:=$Y \
z:=$Z \
roll:=$ROLL \
pitch:=$PITCH \
yaw:=$YAW
# ROS
roslaunch message_tf_frame_transformer message_tf_frame_transformer.launch \
input_topic:=$INPUT_TOPIC \
output_topic:=$OUTPUT_TOPIC \
source_frame_id:=$SOURCE_FRAME_ID \
target_frame_id:=$TARGET_FRAME_ID \
xyzrpy:="$X $Y $Z $ROLL $PITCH $YAW"
The message_tf_frame_transformer package is able to support any ROS message type that integrates with tf2::doTransform
. Currently, the following message types are explicitly supported.
Through application of preprocessor macros, adding support for a new ROS message type is as easy as adding only two lines of code. Note that the ROS message types have to integrate with tf2::doTransform
. Feel free to open a pull request to add support for more message types!
message_types.h
(ROS) /message_types.ros2.hpp
(ROS 2)- include required message headers
message_types.macro
(ROS) /message_types.ros2.macro
(ROS 2)- define information about the new message type by calling the
MESSAGE_TYPE
macroTYPE
: ROS message type (e.g.geometry_msgs::msg::PointStamped
)NAME
: (ROS 2 only) ROS message type name (e.g.geometry_msgs/msg/PointStamped
)
- define information about the new message type by calling the
Package | Node | Description |
---|---|---|
message_tf_frame_transformer |
message_tf_frame_transformer |
transform arbitrary ROS messages to a different coordinate frame |
Package | Node | Nodelet | Description |
---|---|---|---|
message_tf_frame_transformer |
message_tf_frame_transformer |
MessageTfFrameTransformer |
transform arbitrary ROS messages to a different coordinate frame |
Topic | Type | Description |
---|---|---|
~/input |
see Supported Message Types | message to transform |
Topic | Type | Description |
---|---|---|
~/transformed |
see Supported Message Types | transformed message |
-
-
Parameter | Type | Description |
---|---|---|
~/target_frame_id |
string |
target frame ID |
~/source_frame_id |
string |
source frame ID (optional; if message has no std_msgs/Header ) |
This research is accomplished within the project 6GEM (FKZ 16KISK036K). We acknowledge the financial support for the project by the Federal Ministry of Education and Research of Germany (BMBF).