Skip to content

Commit 53f0f88

Browse files
authored
Merge branch 'gazebosim:ros2' into pr-ros2-material_color
2 parents d122cd2 + 98b9d13 commit 53f0f88

29 files changed

+480
-193
lines changed

.github/workflows/build-and-test.sh

+4-21
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,15 @@ export ROS_PYTHON_VERSION=3
1010
apt update -qq
1111
apt install -qq -y lsb-release wget curl build-essential
1212

13-
if [ "$GZ_VERSION" == "garden" ]; then
14-
echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list
15-
wget https://packages.osrfoundation.org/gazebo.key -O - | apt-key add -
16-
17-
GZ_DEPS="libgz-sim7-dev"
18-
19-
ROSDEP_ARGS="--skip-keys='sdformat-urdf'"
20-
elif [ "$GZ_VERSION" == "harmonic" ]; then
21-
echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list
22-
echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-prerelease `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-prerelease.list
23-
wget https://packages.osrfoundation.org/gazebo.key -O - | apt-key add -
24-
25-
GZ_DEPS="libgz-sim8-dev"
26-
27-
ROSDEP_ARGS="--skip-keys='sdformat-urdf'"
28-
fi
29-
30-
# Fortress comes through rosdep for Focal and Jammy
13+
echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list
14+
wget https://packages.osrfoundation.org/gazebo.key -O - | apt-key add -
3115

3216
# Dependencies.
3317
echo "deb http://packages.ros.org/ros2-testing/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/ros2-testing.list
3418
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | apt-key add -
3519
apt-get update -qq
36-
apt-get install -y $GZ_DEPS \
37-
python3-colcon-common-extensions \
38-
python3-rosdep
20+
apt-get install -y python3-colcon-common-extensions \
21+
python3-rosdep
3922

4023
rosdep init
4124
rosdep update

.github/workflows/ros2-ci.yml

+2-14
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,17 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
include:
13-
- docker-image: "ubuntu:22.04"
14-
gz-version: "garden"
15-
ros-distro: "iron"
16-
- docker-image: "ubuntu:22.04"
17-
gz-version: "garden"
18-
ros-distro: "rolling"
19-
- docker-image: "ubuntu:22.04"
13+
- docker-image: "ubuntu:24.04"
2014
gz-version: "harmonic"
2115
ros-distro: "rolling"
2216
container:
2317
image: ${{ matrix.docker-image }}
2418
steps:
2519
- name: Checkout
26-
uses: actions/checkout@v2
20+
uses: actions/checkout@v4
2721
- name: Build and Test
2822
run: .github/workflows/build-and-test.sh
2923
env:
3024
DOCKER_IMAGE: ${{ matrix.docker-image }}
3125
GZ_VERSION: ${{ matrix.gz-version }}
3226
ROS_DISTRO: ${{ matrix.ros-distro }}
33-
- name: Build sdformat_urdf from source
34-
uses: actions/checkout@v2
35-
if: ${{ matrix.gz-version }} == "garden"
36-
with:
37-
repository: ros/sdformat_urdf
38-
ref: ros2

ros_gz/CHANGELOG.rst

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
Changelog for package ros_gz
33
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
44

5+
1.0.0 (2024-04-24)
6+
------------------
7+
58
0.246.0 (2023-08-31)
69
--------------------
710
* Port: humble to ros2 (`#386 <https://github.com/gazebosim/ros_gz/issues/386>`_)

ros_gz/package.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<!-- TODO: Make this a metapackage, see
55
https://github.com/ros2/ros2/issues/408 -->
66
<name>ros_gz</name>
7-
<version>0.246.0</version>
7+
<version>1.0.0</version>
88
<description>Meta-package containing interfaces for using ROS 2 with <a href="https://gazebosim.org">Gazebo</a> simulation.</description>
99
<maintainer email="[email protected]">Aditya Pande</maintainer>
1010
<maintainer email="[email protected]">Alejandro Hernandez</maintainer>

ros_gz_bridge/CHANGELOG.rst

+16
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@
22
Changelog for package ros_gz_bridge
33
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
44

5+
1.0.0 (2024-04-24)
6+
------------------
7+
* Use gz_vendor packages (`#531 <https://github.com/gazebosim/ros_gz/issues/531>`_)
8+
* Added conversion for Detection3D and Detection3DArray (`#523 <https://github.com/gazebosim/ros_gz/issues/523>`_) (`#525 <https://github.com/gazebosim/ros_gz/issues/525>`_)
9+
Co-authored-by: wittenator <[email protected]>
10+
* [Backport rolling] Add ROS namespaces to GZ topics (`#517 <https://github.com/gazebosim/ros_gz/issues/517>`_)
11+
Co-authored-by: Krzysztof Wojciechowski <[email protected]>
12+
* ign to gz (`#519 <https://github.com/gazebosim/ros_gz/issues/519>`_)
13+
* Correctly export ros_gz_bridge for downstream targets (`#503 <https://github.com/gazebosim/ros_gz/issues/503>`_)
14+
* Add a virtual destructor to suppress compiler warning (`#502 <https://github.com/gazebosim/ros_gz/issues/502>`_)
15+
* Add conversion for geometry_msgs/msg/TwistStamped <-> gz.msgs.Twist (`#468 <https://github.com/gazebosim/ros_gz/issues/468>`_)
16+
* Added messages for 2D Bounding Boxes to ros_gz_bridge (`#458 <https://github.com/gazebosim/ros_gz/issues/458>`_) (`#466 <https://github.com/gazebosim/ros_gz/issues/466>`_)
17+
Co-authored-by: Alejandro Hernandez Cordero <[email protected]>
18+
* populate imu covariances when converting (`#375 <https://github.com/gazebosim/ros_gz/issues/375>`_)
19+
* Contributors: Addisu Z. Taddese, Alejandro Hernández Cordero, El Jawad Alaa, Michael Carroll
20+
521
0.246.0 (2023-08-31)
622
--------------------
723
* Add harmonic CI (`#447 <https://github.com/gazebosim/ros_gz/issues/447>`_)

ros_gz_bridge/CMakeLists.txt

+22-46
Original file line numberDiff line numberDiff line change
@@ -14,38 +14,15 @@ find_package(ament_cmake REQUIRED)
1414
find_package(rclcpp REQUIRED)
1515
find_package(rclcpp_components REQUIRED)
1616
find_package(yaml_cpp_vendor REQUIRED)
17+
find_package(yaml-cpp REQUIRED)
1718

18-
if(NOT DEFINED ENV{GZ_VERSION})
19-
set(ENV{GZ_VERSION} "garden")
20-
endif()
21-
22-
# Garden
23-
if("$ENV{GZ_VERSION}" STREQUAL "garden")
24-
find_package(gz-transport12 REQUIRED)
25-
find_package(gz-msgs9 REQUIRED)
19+
find_package(gz_transport_vendor REQUIRED)
20+
find_package(gz-transport REQUIRED)
2621

27-
set(GZ_TARGET_PREFIX gz)
28-
set(GZ_MSGS_VER ${gz-msgs9_VERSION_MAJOR})
29-
set(GZ_TRANSPORT_VER ${gz-transport12_VERSION_MAJOR})
22+
find_package(gz_msgs_vendor REQUIRED)
23+
find_package(gz-msgs REQUIRED)
3024

31-
message(STATUS "Compiling against Gazebo Garden")
32-
elseif("$ENV{GZ_VERSION}" STREQUAL "harmonic")
33-
find_package(gz-transport13 REQUIRED)
34-
find_package(gz-msgs10 REQUIRED)
35-
36-
set(GZ_TARGET_PREFIX gz)
37-
set(GZ_MSGS_VER ${gz-msgs10_VERSION_MAJOR})
38-
set(GZ_TRANSPORT_VER ${gz-transport13_VERSION_MAJOR})
39-
40-
message(STATUS "Compiling against Gazebo Harmonic")
41-
else()
42-
message(FATAL_ERROR "This branch is only compatible with Gazebo Garden forward.")
43-
endif()
44-
45-
set(GZ_MSGS_VERSION_MAJOR ${${GZ_TARGET_PREFIX}-msgs${GZ_MSGS_VER}_VERSION_MAJOR})
46-
set(GZ_MSGS_VERSION_MINOR ${${GZ_TARGET_PREFIX}-msgs${GZ_MSGS_VER}_VERSION_MINOR})
47-
set(GZ_MSGS_VERSION_PATCH ${${GZ_TARGET_PREFIX}-msgs${GZ_MSGS_VER}_VERSION_PATCH})
48-
set(GZ_MSGS_VERSION_FULL ${GZ_MSGS_VERSION_MAJOR}.${GZ_MSGS_VERSION_MINOR}.${GZ_MSGS_VERSION_PATCH})
25+
set(GZ_MSGS_VERSION_FULL ${gz-msgs_VERSION})
4926

5027
set(BRIDGE_MESSAGE_TYPES
5128
builtin_interfaces
@@ -118,15 +95,18 @@ add_library(${bridge_lib}
11895
)
11996

12097
target_link_libraries(${bridge_lib}
121-
${GZ_TARGET_PREFIX}-msgs${GZ_MSGS_VER}::core
122-
${GZ_TARGET_PREFIX}-transport${GZ_TRANSPORT_VER}::core
98+
PUBLIC
99+
gz-msgs::core
100+
gz-transport::core
101+
PRIVATE
102+
yaml-cpp::yaml-cpp
123103
)
124104

125105
ament_target_dependencies(${bridge_lib}
126-
rclcpp
127-
rclcpp_components
128-
yaml_cpp_vendor
129-
${BRIDGE_MESSAGE_TYPES}
106+
PUBLIC
107+
rclcpp
108+
rclcpp_components
109+
${BRIDGE_MESSAGE_TYPES}
130110
)
131111

132112
target_include_directories(${bridge_lib}
@@ -138,11 +118,6 @@ target_include_directories(${bridge_lib}
138118
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/generated>"
139119
)
140120

141-
target_link_libraries(${bridge_lib}
142-
${GZ_TARGET_PREFIX}-msgs${GZ_MSGS_VER}::core
143-
${GZ_TARGET_PREFIX}-transport${GZ_TRANSPORT_VER}::core
144-
)
145-
146121
rclcpp_components_register_node(
147122
${bridge_lib}
148123
PLUGIN ros_gz_bridge::RosGzBridge
@@ -193,7 +168,7 @@ if(BUILD_TESTING)
193168
${PROJECT_SOURCE_DIR}/src/convert/rcl_interfaces_TEST.cpp
194169
)
195170
target_link_libraries(test_rcl_interfaces
196-
${GZ_TARGET_PREFIX}-msgs${GZ_MSGS_VER}::core
171+
gz-msgs::core
197172
${rcl_interfaces_TARGETS}
198173
gtest
199174
gtest_main
@@ -228,8 +203,8 @@ if(BUILD_TESTING)
228203
)
229204
target_link_libraries(test_utils
230205
${GTEST_LIBRARIES}
231-
${GZ_TARGET_PREFIX}-msgs${GZ_MSGS_VER}::core
232-
${GZ_TARGET_PREFIX}-transport${GZ_TRANSPORT_VER}::core
206+
gz-msgs::core
207+
gz-transport::core
233208
)
234209
ament_target_dependencies(test_utils
235210
rclcpp
@@ -341,9 +316,10 @@ ament_export_targets(export_${PROJECT_NAME})
341316
# specific order: dependents before dependencies
342317
ament_export_dependencies(rclcpp)
343318
ament_export_dependencies(rclcpp_components)
344-
ament_export_dependencies(${GZ_TARGET_PREFIX}-msgs${GZ_MSGS_VER})
345-
ament_export_dependencies(${GZ_TARGET_PREFIX}-transport${GZ_TRANSPORT_VER})
346-
ament_export_dependencies(yaml_cpp_vendor)
319+
ament_export_dependencies(gz_msgs_vendor)
320+
ament_export_dependencies(gz-msgs)
321+
ament_export_dependencies(gz_transport_vendor)
322+
ament_export_dependencies(gz-transport)
347323
ament_export_dependencies(${BRIDGE_MESSAGE_TYPES})
348324

349325
ament_package()

ros_gz_bridge/README.md

+39-4
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ The following message types can be bridged for topics:
6969
| trajectory_msgs/msg/JointTrajectory | gz.msgs.JointTrajectory |
7070
| vision_msgs/msg/Detection2D | gz.msgs.AnnotatedAxisAligned2DBox |
7171
| vision_msgs/msg/Detection2DArray | gz.msgs.AnnotatedAxisAligned2DBox_V |
72-
72+
| vision_msgs/msg/Detection3D | gz::msgs::AnnotatedOriented3DBox |
73+
| vision_msgs/msg/Detection3DArray | gz::msgs::AnnotatedOriented3DBox_V |
7374

7475
And the following for services:
7576

@@ -102,7 +103,7 @@ Now we start the ROS listener.
102103
103104
```
104105
# Shell B:
105-
. /opt/ros/galactic/setup.bash
106+
. /opt/ros/rolling/setup.bash
106107
ros2 topic echo /chatter
107108
```
108109
@@ -134,7 +135,7 @@ Now we start the ROS talker.
134135
135136
```
136137
# Shell C:
137-
. /opt/ros/galactic/setup.bash
138+
. /opt/ros/rolling/setup.bash
138139
ros2 topic pub /chatter std_msgs/msg/String "data: 'Hi'" --once
139140
```
140141
@@ -172,7 +173,7 @@ Now we start the ROS GUI:
172173
173174
```
174175
# Shell C:
175-
. /opt/ros/galactic/setup.bash
176+
. /opt/ros/rolling/setup.bash
176177
ros2 run rqt_image_view rqt_image_view /rgbd_camera/image
177178
```
178179
@@ -290,9 +291,43 @@ To run the bridge node with the above configuration:
290291
ros2 run ros_gz_bridge parameter_bridge --ros-args -p config_file:=$WORKSPACE/ros_gz/ros_gz_bridge/test/config/full.yaml
291292
```
292293
294+
## Example 6: Using ROS namespace with the Bridge
295+
296+
When spawning multiple robots inside the same ROS environment, it is convenient to use namespaces to avoid overlapping topic names.
297+
There are three main types of namespaces: relative, global (`/`) and private (`~/`). For more information, refer to ROS documentation.
298+
Namespaces are applied to Gazebo topic both when specified as `topic_name` as well as `gz_topic_name`.
299+
300+
By default, the Bridge will not apply ROS namespace on the Gazebo topics. To enable this feature, use parameter `expand_gz_topic_names`.
301+
Let's test our topic with namespace:
302+
303+
```bash
304+
# Shell A:
305+
. ~/bridge_ws/install/setup.bash
306+
ros2 run ros_gz_bridge parameter_bridge chatter@std_msgs/msg/[email protected] \
307+
--ros-args -p expand_gz_topic_names:=true -r __ns:=/demo
308+
```
309+
310+
Now we start the Gazebo Transport listener.
311+
312+
```bash
313+
# Shell B:
314+
gz topic -e -t /demo/chatter
315+
```
316+
317+
Now we start the ROS talker.
318+
319+
```bash
320+
# Shell C:
321+
. /opt/ros/rolling/setup.bash
322+
ros2 topic pub /demo/chatter std_msgs/msg/String "data: 'Hi from inside of a namespace'" --once
323+
```
324+
325+
By changing `chatter` to `/chatter` or `~/chatter` you can obtain different results.
326+
293327
## API
294328
295329
ROS 2 Parameters:
296330
297331
* `subscription_heartbeat` - Period at which the node checks for new subscribers for lazy bridges.
298332
* `config_file` - YAML file to be loaded as the bridge configuration
333+
* `expand_gz_topic_names` - Enable or disable ROS namespace applied on GZ topics.

ros_gz_bridge/include/ros_gz_bridge/convert/vision_msgs.hpp

+26
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717

1818
// Gazebo Msgs
1919
#include <gz/msgs/annotated_axis_aligned_2d_box_v.pb.h>
20+
#include <gz/msgs/annotated_oriented_3d_box_v.pb.h>
2021

2122
// ROS 2 messages
2223
#include "vision_msgs/msg/detection2_d_array.hpp"
24+
#include "vision_msgs/msg/detection3_d_array.hpp"
2325
#include <ros_gz_bridge/convert_decl.hpp>
2426

2527
namespace ros_gz_bridge
@@ -47,6 +49,30 @@ void
4749
convert_gz_to_ros(
4850
const gz::msgs::AnnotatedAxisAligned2DBox_V & gz_msg,
4951
vision_msgs::msg::Detection2DArray & ros_msg);
52+
53+
template<>
54+
void
55+
convert_ros_to_gz(
56+
const vision_msgs::msg::Detection3D & ros_msg,
57+
gz::msgs::AnnotatedOriented3DBox & gz_msg);
58+
59+
template<>
60+
void
61+
convert_gz_to_ros(
62+
const gz::msgs::AnnotatedOriented3DBox & gz_msg,
63+
vision_msgs::msg::Detection3D & ros_msg);
64+
65+
template<>
66+
void
67+
convert_ros_to_gz(
68+
const vision_msgs::msg::Detection3DArray & ros_msg,
69+
gz::msgs::AnnotatedOriented3DBox_V & gz_msg);
70+
71+
template<>
72+
void
73+
convert_gz_to_ros(
74+
const gz::msgs::AnnotatedOriented3DBox_V & gz_msg,
75+
vision_msgs::msg::Detection3DArray & ros_msg);
5076
} // namespace ros_gz_bridge
5177

5278
#endif // ROS_GZ_BRIDGE__CONVERT__VISION_MSGS_HPP_

ros_gz_bridge/package.xml

+3-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
33
<package format="3">
44
<name>ros_gz_bridge</name>
5-
<version>0.246.0</version>
5+
<version>1.0.0</version>
66
<description>Bridge communication between ROS and Gazebo Transport</description>
77
<maintainer email="[email protected]">Aditya Pande</maintainer>
88
<maintainer email="[email protected]">Alejandro Hernandez</maintainer>
@@ -31,12 +31,8 @@
3131
<depend>yaml_cpp_vendor</depend>
3232
<depend>vision_msgs</depend>
3333

34-
<!-- Garden (default) -->
35-
<depend condition="$GZ_VERSION == '' or $GZ_VERSION == garden">gz-msgs9</depend>
36-
<depend condition="$GZ_VERSION == '' or $GZ_VERSION == garden">gz-transport12</depend>
37-
<!-- Harmonic -->
38-
<depend condition="$GZ_VERSION == harmonic">gz-msgs10</depend>
39-
<depend condition="$GZ_VERSION == harmonic">gz-transport13</depend>
34+
<depend>gz_msgs_vendor</depend>
35+
<depend>gz_transport_vendor</depend>
4036

4137
<test_depend>ament_cmake_gtest</test_depend>
4238
<test_depend>ament_lint_auto</test_depend>

ros_gz_bridge/ros_gz_bridge/mappings.py

+2
Original file line numberDiff line numberDiff line change
@@ -112,5 +112,7 @@
112112
'vision_msgs': [
113113
Mapping('Detection2DArray', 'AnnotatedAxisAligned2DBox_V'),
114114
Mapping('Detection2D', 'AnnotatedAxisAligned2DBox'),
115+
Mapping('Detection3DArray', 'AnnotatedOriented3DBox_V'),
116+
Mapping('Detection3D', 'AnnotatedOriented3DBox'),
115117
],
116118
}

0 commit comments

Comments
 (0)