());
167 | rclcpp::shutdown();
168 |
169 | return 0;
170 | }
171 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # message_tf_frame_transformer
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | The *message_tf_frame_transformer* package provides a ROS node to transform 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 messages to a target coordinate frame.
13 |
14 | - [Installation](#installation)
15 | - [docker-ros](#docker-ros)
16 | - [Usage](#usage)
17 | - [Supported Message Types](#supported-message-types)
18 | - [Nodes](#nodes)
19 | - [Acknowledgements](#acknowledgements)
20 |
21 |
22 | ## Installation
23 |
24 | The *message_tf_frame_transformer* package is released as an official ROS package and can easily be installed via a package manager.
25 |
26 | ```bash
27 | sudo apt install ros-$ROS_DISTRO-message-tf-frame-transformer
28 | ```
29 |
30 | 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`](./package.xml) can be installed using [*rosdep*](http://wiki.ros.org/rosdep).
31 |
32 | ```bash
33 | # message_tf_frame_transformer$
34 | rosdep install -r --ignore-src --from-paths .
35 |
36 | # workspace$
37 | colcon build --packages-up-to message_tf_frame_transformer --cmake-args -DCMAKE_BUILD_TYPE=Release
38 | ```
39 |
40 | ### docker-ros
41 |
42 | *message_tf_frame_transformer* is also available as a Docker image, containerized through [*docker-ros*](https://github.com/ika-rwth-aachen/docker-ros).
43 |
44 | ```bash
45 | docker run --rm ghcr.io/ika-rwth-aachen/message_tf_frame_transformer:latest # or distro-specific tags, e.g., :ros2-rolling
46 | ```
47 |
48 |
49 | ## Usage
50 |
51 | 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`](https://docs.ros.org/en/api/std_msgs/html/msg/Header.html). The topics default to `~/input` and `~/transformed` in the node's private namespace.
52 |
53 | ```bash
54 | ros2 run message_tf_frame_transformer message_tf_frame_transformer --ros-args \
55 | -r \~/input:=$INPUT_TOPIC \
56 | -r \~/transformed:=$OUTPUT_TOPIC \
57 | -p source_frame_id:=$SOURCE_FRAME_ID \
58 | -p target_frame_id:=$TARGET_FRAME_ID
59 | ```
60 |
61 | The provided launch file enables you to directly launch a [`tf2_ros/static_transform_publisher`](http://wiki.ros.org/tf2_ros) alongside the *message_tf_frame_transformer* node. This way you can transform a topic to a new coordinate frame with a single command.
62 |
63 | ```bash
64 | ros2 launch message_tf_frame_transformer message_tf_frame_transformer.launch.xml \
65 | input_topic:=$INPUT_TOPIC \
66 | output_topic:=$OUTPUT_TOPIC \
67 | source_frame_id:=$SOURCE_FRAME_ID \
68 | target_frame_id:=$TARGET_FRAME_ID \
69 | x:=$X \
70 | y:=$Y \
71 | z:=$Z \
72 | roll:=$ROLL \
73 | pitch:=$PITCH \
74 | yaw:=$YAW
75 | ```
76 |
77 |
78 | ## Supported Message Types
79 |
80 | The *message_tf_frame_transformer* package is able to support any ROS message type that integrates with [`tf2::doTransform`](http://wiki.ros.org/tf2/Tutorials/Transforming%20your%20own%20datatypes). Currently, the following message types are explicitly supported.
81 |
82 | | ROS Message |
83 | | --- |
84 | | [`geometry_msgs/msg/Point`](https://docs.ros.org/en/ros2_packages/jazzy/api/geometry_msgs/msg/Point.html) |
85 | | [`geometry_msgs/msg/Point32`](https://docs.ros.org/en/ros2_packages/jazzy/api/geometry_msgs/msg/Point32.html) |
86 | | [`geometry_msgs/msg/PointStamped`](https://docs.ros.org/en/ros2_packages/jazzy/api/geometry_msgs/msg/PointStamped.html) |
87 | | [`geometry_msgs/msg/Polygon`](https://docs.ros.org/en/ros2_packages/jazzy/api/geometry_msgs/msg/Polygon.html) |
88 | | [`geometry_msgs/msg/PolygonStamped`](https://docs.ros.org/en/ros2_packages/jazzy/api/geometry_msgs/msg/PolygonStamped.html) |
89 | | [`geometry_msgs/msg/Pose`](https://docs.ros.org/en/ros2_packages/jazzy/api/geometry_msgs/msg/Pose.html) |
90 | | [`geometry_msgs/msg/PoseStamped`](https://docs.ros.org/en/ros2_packages/jazzy/api/geometry_msgs/msg/PoseStamped.html) |
91 | | [`geometry_msgs/msg/PoseWithCovariance`](https://docs.ros.org/en/ros2_packages/jazzy/api/geometry_msgs/msg/PoseWithCovariance.html) |
92 | | [`geometry_msgs/msg/PoseWithCovarianceStamped`](https://docs.ros.org/en/ros2_packages/jazzy/api/geometry_msgs/msg/PoseWithCovarianceStamped.html) |
93 | | [`geometry_msgs/msg/Quaternion`](https://docs.ros.org/en/ros2_packages/jazzy/api/geometry_msgs/msg/Quaternion.html) |
94 | | [`geometry_msgs/msg/QuaternionStamped`](https://docs.ros.org/en/ros2_packages/jazzy/api/geometry_msgs/msg/QuaternionStamped.html) |
95 | | [`geometry_msgs/msg/Transform`](https://docs.ros.org/en/ros2_packages/jazzy/api/geometry_msgs/msg/Transform.html) |
96 | | [`geometry_msgs/msg/TransformStamped`](https://docs.ros.org/en/ros2_packages/jazzy/api/geometry_msgs/msg/TransformStamped.html) |
97 | | [`geometry_msgs/msg/Vector3`](https://docs.ros.org/en/ros2_packages/jazzy/api/geometry_msgs/msg/Vector3.html) |
98 | | [`geometry_msgs/msg/Vector3Stamped`](https://docs.ros.org/en/ros2_packages/jazzy/api/geometry_msgs/msg/Vector3Stamped.html) |
99 | | [`geometry_msgs/msg/Wrench`](https://docs.ros.org/en/ros2_packages/jazzy/api/geometry_msgs/msg/Wrench.html) |
100 | | [`geometry_msgs/msg/WrenchStamped`](https://docs.ros.org/en/ros2_packages/jazzy/api/geometry_msgs/msg/WrenchStamped.html) |
101 | | [`sensor_msgs/msg/PointCloud2`](https://docs.ros.org/en/jazzy/p/sensor_msgs/msg/PointCloud2.html) |
102 |
103 | ### Adding Support for a New Message Type
104 |
105 | 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`](http://wiki.ros.org/tf2/Tutorials/Transforming%20your%20own%20datatypes). Feel free to open a pull request to add support for more message types!
106 |
107 | 1. [`message_types.hpp`](./include/message_tf_frame_transformer/message_types.hpp)
108 | - include required message headers
109 | 1. [`message_types.macro`](./include/message_tf_frame_transformer/message_types.macro)
110 | - define information about the new message type by calling the `MESSAGE_TYPE` macro
111 | - `TYPE`: ROS message type (e.g. `geometry_msgs::msg::PointStamped`)
112 | - `NAME`: ROS message type name (e.g. `geometry_msgs/msg/PointStamped`)
113 |
114 |
115 | ## Nodes
116 |
117 | | Package | Node | Description |
118 | | --- | --- | --- |
119 | | `message_tf_frame_transformer` | `message_tf_frame_transformer` | transform arbitrary ROS messages to a different coordinate frame |
120 |
121 | ### message_tf_frame_transformer/message_tf_frame_transformer
122 |
123 | #### Subscribed Topics
124 |
125 | | Topic | Type | Description |
126 | | --- | --- | --- |
127 | | `~/input` | see [Supported Message Types](#supported-message-types) | message to transform |
128 |
129 | #### Published Topics
130 |
131 | | Topic | Type | Description |
132 | | --- | --- | --- |
133 | | `~/transformed` | see [Supported Message Types](#supported-message-types) | transformed message |
134 |
135 | #### Services
136 |
137 | \-
138 |
139 | #### Actions
140 |
141 | \-
142 |
143 | #### Parameters
144 |
145 | | Parameter | Type | Description |
146 | | --- | --- | --- |
147 | | `~/target_frame_id` | `string` | target frame ID |
148 | | `~/source_frame_id` | `string` | source frame ID (optional; if message has no [`std_msgs/Header`](https://docs.ros.org/en/api/std_msgs/html/msg/Header.html)) |
149 |
150 |
151 | ## Acknowledgements
152 |
153 | This research is accomplished within the project [6GEM](https://6gem.de/) (FKZ 16KISK036K). We acknowledge the financial support for the project by the Federal Ministry of Education and Research of Germany (BMBF).
154 |
155 |
--------------------------------------------------------------------------------