-
Notifications
You must be signed in to change notification settings - Fork 195
Add ROS parameters for configuring GZ to ROS optical frame conversion #703
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
iche033
wants to merge
13
commits into
ros2
Choose a base branch
from
gz_to_ros_optical_frame
base: ros2
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
4b0cda1
Add ROS param for converting gz to ros optical frame
iche033 aa46906
remove unused code
iche033 017bdea
support custom transform
iche033 8ec7d7c
throttle broadcast rate, fixes
iche033 8820a64
cleanup
iche033 9d4af9e
Merge branch 'ros2' into gz_to_ros_optical_frame
iche033 5166feb
fixes
iche033 5e255a2
lint, and add test
iche033 11ca34c
remove comment
iche033 717d756
fix test
iche033 8fa6b71
pub tf once
iche033 75e4892
Merge branch 'ros2' into gz_to_ros_optical_frame
iche033 8a7d40e
fix spelling
iche033 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -190,6 +190,55 @@ The screenshot shows all the shell windows and their expected content | |
|  | ||
| ### GZ to ROS Optical frame conversion | ||
| For sensors like cameras, it is commonly expected that ROS image data are in a | ||
| z-forward optical frame, see [REP-0103](https://www.ros.org/reps/rep-0103.html). | ||
| Historically, when bridging GZ to ROS `Image` and `CameraInfo` topics, users | ||
| would typically create a new optical frame with a x to z-forward transformation, | ||
| e.g. by using a static transform publisher. The sensor's frame id in SDF would | ||
| then be set to point to the new optical frame. | ||
| The bridge now has a parameter named `publish_optical_frame` to automate | ||
| this process. In the above example for bridging image topics, you can run the | ||
| bridge and pass these extra ROS arguments: | ||
| ```bash | ||
| . ~/bridge_ws/install/setup.bash | ||
| ros2 run ros_gz_bridge parameter_bridge /rgbd_camera/image@sensor_msgs/msg/[email protected] --ros-args -p publish_optical_frame:=true -r /rgbd_camera/image:=/rgbd_camera/optical/image | ||
| ros2 run ros_gz_bridge parameter_bridge /rgbd_camera/camera_info@sensor_msgs/msg/[email protected] --ros-args -p publish_optical_frame:=true -r /rgbd_camera/camera_info:=/rgbd_camera/optical/camera_info | ||
| ``` | ||
| Each command above sets the `publish_optical_frame` parameter to `true`, and | ||
| it also remaps the original topic to a new name with an `optical` sub-namespace: | ||
| ```bash | ||
| # Original topics: | ||
| # /rgbd_camera/image | ||
| # /rgbd_camera/camera_info | ||
| # New remapped optical frame topics | ||
| /rgbd_camera/optical/image | ||
| /rgbd_camera/optical/camera_info | ||
| ``` | ||
| The messages from these topics will include a header with its `frame_id` set | ||
| to a new optical frame that contains a `_optical` suffix string. This new | ||
| optical frame is published by the bridge using a static transform broadcaster. | ||
| You can introspect the TF tree using `tf2_tools` and viewing the generated pdf: | ||
| ```bash | ||
| ros2 run tf2_tools view_frames | ||
| evince frames_<timestamp>.pdf | ||
| ``` | ||
| The TF tree should look like: | ||
| ```bash | ||
| # New TF tree. A new frame with `_optical` suffix is added | ||
| /rgbd_camera/link/rgbd_camera -> /rgbd_camera/link/rgbd_camera_optical | ||
| ``` | ||
| ## Example 3: Static bridge | ||
| In this example, we're going to run an executable that starts a bidirectional | ||
|
|
@@ -333,6 +382,45 @@ By changing `chatter` to `/chatter` or `~/chatter` you can obtain different resu | |
| ROS 2 Parameters: | ||
| * `subscription_heartbeat` - Period at which the node checks for new subscribers for lazy bridges. | ||
| * `config_file` - YAML file to be loaded as the bridge configuration | ||
| * `expand_gz_topic_names` - Enable or disable ROS namespace applied on GZ topics. | ||
| * `subscription_heartbeat` | ||
| * type: double | ||
| * default: 1000 | ||
| * description: Period (ms) at which the node checks for new subscribers for | ||
| lazy bridges. | ||
| * `config_file` | ||
| * type: string | ||
| * default: "" | ||
| * description: YAML file to be loaded as the bridge configuration | ||
| * `expand_gz_topic_names` | ||
| * type: bool | ||
| * default: false | ||
| * description: Enable or disable ROS namespace applied on GZ topics. | ||
| * `override_timestamps_with_wall_time` | ||
| * type: bool | ||
| * default: false | ||
| * direction: GZ to ROS | ||
| * description: Override the header.stamp field of outgoing messages with | ||
| wall time. | ||
| * `publish_optical_frame` | ||
| * type: bool | ||
| * default: false | ||
| * direction: GZ to ROS | ||
| * description: Apply x-forward to z-forward transformation to outgoing | ||
| messages. A new frame with a `_optical` suffix will be broadcasted. | ||
| * `override_frame_id_string` | ||
| * type: string | ||
| * default: "" | ||
| * direction: GZ to ROS | ||
| * description: Override the `header.frame_id` field with a new string value. | ||
| * `override_frame_transform` | ||
| * type: double array | ||
| * default: {} | ||
| * direction: GZ to ROS | ||
| * description: Publish messages under a new frame which has the specified | ||
| transformation from the original frame. This is done by broadcasting a | ||
| tf with the `frame_id` set to the frame id in the original message, and | ||
| the `child_frame_id` set to the new frame id in the updated outgoing | ||
| message. The new frame id of the outgoing messages must be set via the | ||
| `override_frame_id_string` parameter. The array of doubles are: | ||
| `[x, y, z, roll, pitch, yaw]`, where the translational components are | ||
| in meters and the rotational components are in radians. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| // Copyright 2025 Open Source Robotics Foundation, Inc. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #ifndef BRIDGE_HANDLE_GZ_TO_ROS_PARAMETERS_HPP_ | ||
| #define BRIDGE_HANDLE_GZ_TO_ROS_PARAMETERS_HPP_ | ||
|
|
||
| #include <optional> | ||
| #include <string> | ||
|
|
||
| #include <geometry_msgs/msg/transform.hpp> | ||
|
|
||
| namespace ros_gz_bridge | ||
| { | ||
|
|
||
| struct BridgeHandleGzToRosParameters | ||
| { | ||
| /// \brief Override the header.stamp field of the outgoing messages with | ||
| /// the wall time | ||
| bool override_timestamps_with_wall_time = false; | ||
|
|
||
| /// Publish messages under a new frame which has the specified transformation | ||
| /// from the original frame. This is done by broadcasting a tf with the | ||
| /// frame_id set to the frame_id in the original message, and the | ||
| /// child_frame_id set to the new frame id in the updated outgoing message. | ||
| /// The new frame id of the outgoing messages must be set via the | ||
| /// override_frame_id_string parameter. | ||
| std::optional<geometry_msgs::msg::Transform> override_frame_transform; | ||
|
|
||
| /// \brief Override the header.frame_id field of the outgoing messages with | ||
| /// this new frame_id string | ||
| std::string override_frame_id_string; | ||
|
|
||
| /// \brief Append the header.frame_id field of the outgoing messages with | ||
| /// a suffix string. Used internally for publishing optical frames. | ||
| std::string override_frame_id_suffix_string; | ||
| }; | ||
|
|
||
| } // namespace ros_gz_bridge | ||
|
|
||
| #endif // BRIDGE_HANDLE_GZ_TO_ROS_PARAMETERS_HPP_ | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.