Skip to content

Commit

Permalink
Use gz_vendor packages (#531)
Browse files Browse the repository at this point in the history
Signed-off-by: Addisu Z. Taddese <[email protected]>
  • Loading branch information
azeey authored Apr 24, 2024
1 parent deccb5b commit e6e6b45
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 177 deletions.
25 changes: 4 additions & 21 deletions .github/workflows/build-and-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,15 @@ export ROS_PYTHON_VERSION=3
apt update -qq
apt install -qq -y lsb-release wget curl build-essential

if [ "$GZ_VERSION" == "garden" ]; then
echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list
wget https://packages.osrfoundation.org/gazebo.key -O - | apt-key add -

GZ_DEPS="libgz-sim7-dev"

ROSDEP_ARGS="--skip-keys='sdformat-urdf'"
elif [ "$GZ_VERSION" == "harmonic" ]; then
echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list
echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-prerelease `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-prerelease.list
wget https://packages.osrfoundation.org/gazebo.key -O - | apt-key add -

GZ_DEPS="libgz-sim8-dev"

ROSDEP_ARGS="--skip-keys='sdformat-urdf'"
fi

# Fortress comes through rosdep for Focal and Jammy
echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list
wget https://packages.osrfoundation.org/gazebo.key -O - | apt-key add -

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

rosdep init
rosdep update
Expand Down
12 changes: 1 addition & 11 deletions .github/workflows/ros2-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ jobs:
fail-fast: false
matrix:
include:
- docker-image: "ubuntu:22.04"
gz-version: "garden"
ros-distro: "rolling"
- docker-image: "ubuntu:22.04"
- docker-image: "ubuntu:24.04"
gz-version: "harmonic"
ros-distro: "rolling"
container:
Expand All @@ -27,10 +24,3 @@ jobs:
DOCKER_IMAGE: ${{ matrix.docker-image }}
GZ_VERSION: ${{ matrix.gz-version }}
ROS_DISTRO: ${{ matrix.ros-distro }}
ROSDISTRO_INDEX_URL: https://raw.githubusercontent.com/ros/rosdistro/rolling/2024-02-28/index-v4.yaml # Temporarily pin rosdep to fix rolling on Jammy
- name: Build sdformat_urdf from source
uses: actions/checkout@v4
if: ${{ matrix.gz-version }} == "garden"
with:
repository: ros/sdformat_urdf
ref: ros2
68 changes: 22 additions & 46 deletions ros_gz_bridge/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,15 @@ find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_components REQUIRED)
find_package(yaml_cpp_vendor REQUIRED)
find_package(yaml-cpp REQUIRED)

if(NOT DEFINED ENV{GZ_VERSION})
set(ENV{GZ_VERSION} "garden")
endif()

# Garden
if("$ENV{GZ_VERSION}" STREQUAL "garden")
find_package(gz-transport12 REQUIRED)
find_package(gz-msgs9 REQUIRED)
find_package(gz_transport_vendor REQUIRED)
find_package(gz-transport REQUIRED)

set(GZ_TARGET_PREFIX gz)
set(GZ_MSGS_VER ${gz-msgs9_VERSION_MAJOR})
set(GZ_TRANSPORT_VER ${gz-transport12_VERSION_MAJOR})
find_package(gz_msgs_vendor REQUIRED)
find_package(gz-msgs REQUIRED)

message(STATUS "Compiling against Gazebo Garden")
elseif("$ENV{GZ_VERSION}" STREQUAL "harmonic")
find_package(gz-transport13 REQUIRED)
find_package(gz-msgs10 REQUIRED)

set(GZ_TARGET_PREFIX gz)
set(GZ_MSGS_VER ${gz-msgs10_VERSION_MAJOR})
set(GZ_TRANSPORT_VER ${gz-transport13_VERSION_MAJOR})

message(STATUS "Compiling against Gazebo Harmonic")
else()
message(FATAL_ERROR "This branch is only compatible with Gazebo Garden forward.")
endif()

set(GZ_MSGS_VERSION_MAJOR ${${GZ_TARGET_PREFIX}-msgs${GZ_MSGS_VER}_VERSION_MAJOR})
set(GZ_MSGS_VERSION_MINOR ${${GZ_TARGET_PREFIX}-msgs${GZ_MSGS_VER}_VERSION_MINOR})
set(GZ_MSGS_VERSION_PATCH ${${GZ_TARGET_PREFIX}-msgs${GZ_MSGS_VER}_VERSION_PATCH})
set(GZ_MSGS_VERSION_FULL ${GZ_MSGS_VERSION_MAJOR}.${GZ_MSGS_VERSION_MINOR}.${GZ_MSGS_VERSION_PATCH})
set(GZ_MSGS_VERSION_FULL ${gz-msgs_VERSION})

set(BRIDGE_MESSAGE_TYPES
builtin_interfaces
Expand Down Expand Up @@ -118,15 +95,18 @@ add_library(${bridge_lib}
)

target_link_libraries(${bridge_lib}
${GZ_TARGET_PREFIX}-msgs${GZ_MSGS_VER}::core
${GZ_TARGET_PREFIX}-transport${GZ_TRANSPORT_VER}::core
PUBLIC
gz-msgs::core
gz-transport::core
PRIVATE
yaml-cpp::yaml-cpp
)

ament_target_dependencies(${bridge_lib}
rclcpp
rclcpp_components
yaml_cpp_vendor
${BRIDGE_MESSAGE_TYPES}
PUBLIC
rclcpp
rclcpp_components
${BRIDGE_MESSAGE_TYPES}
)

target_include_directories(${bridge_lib}
Expand All @@ -138,11 +118,6 @@ target_include_directories(${bridge_lib}
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/generated>"
)

target_link_libraries(${bridge_lib}
${GZ_TARGET_PREFIX}-msgs${GZ_MSGS_VER}::core
${GZ_TARGET_PREFIX}-transport${GZ_TRANSPORT_VER}::core
)

rclcpp_components_register_node(
${bridge_lib}
PLUGIN ros_gz_bridge::RosGzBridge
Expand Down Expand Up @@ -193,7 +168,7 @@ if(BUILD_TESTING)
${PROJECT_SOURCE_DIR}/src/convert/rcl_interfaces_TEST.cpp
)
target_link_libraries(test_rcl_interfaces
${GZ_TARGET_PREFIX}-msgs${GZ_MSGS_VER}::core
gz-msgs::core
${rcl_interfaces_TARGETS}
gtest
gtest_main
Expand Down Expand Up @@ -228,8 +203,8 @@ if(BUILD_TESTING)
)
target_link_libraries(test_utils
${GTEST_LIBRARIES}
${GZ_TARGET_PREFIX}-msgs${GZ_MSGS_VER}::core
${GZ_TARGET_PREFIX}-transport${GZ_TRANSPORT_VER}::core
gz-msgs::core
gz-transport::core
)
ament_target_dependencies(test_utils
rclcpp
Expand Down Expand Up @@ -341,9 +316,10 @@ ament_export_targets(export_${PROJECT_NAME})
# specific order: dependents before dependencies
ament_export_dependencies(rclcpp)
ament_export_dependencies(rclcpp_components)
ament_export_dependencies(${GZ_TARGET_PREFIX}-msgs${GZ_MSGS_VER})
ament_export_dependencies(${GZ_TARGET_PREFIX}-transport${GZ_TRANSPORT_VER})
ament_export_dependencies(yaml_cpp_vendor)
ament_export_dependencies(gz_msgs_vendor)
ament_export_dependencies(gz-msgs)
ament_export_dependencies(gz_transport_vendor)
ament_export_dependencies(gz-transport)
ament_export_dependencies(${BRIDGE_MESSAGE_TYPES})

ament_package()
8 changes: 2 additions & 6 deletions ros_gz_bridge/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,8 @@
<depend>yaml_cpp_vendor</depend>
<depend>vision_msgs</depend>

<!-- Garden (default) -->
<depend condition="$GZ_VERSION == '' or $GZ_VERSION == garden">gz-msgs9</depend>
<depend condition="$GZ_VERSION == '' or $GZ_VERSION == garden">gz-transport12</depend>
<!-- Harmonic -->
<depend condition="$GZ_VERSION == harmonic">gz-msgs10</depend>
<depend condition="$GZ_VERSION == harmonic">gz-transport13</depend>
<depend>gz_msgs_vendor</depend>
<depend>gz_transport_vendor</depend>

<test_depend>ament_cmake_gtest</test_depend>
<test_depend>ament_lint_auto</test_depend>
Expand Down
3 changes: 1 addition & 2 deletions ros_gz_bridge/src/factory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ class Factory : public FactoryInterface
{
std::function<void(const GZ_T &,
const gz::transport::MessageInfo &)> subCb =
[this, ros_pub](const GZ_T & _msg,
const gz::transport::MessageInfo & _info)
[this, ros_pub](const GZ_T & _msg, const gz::transport::MessageInfo & _info)
{
// Ignore messages that are published from this bridge.
if (!_info.IntraProcess()) {
Expand Down
41 changes: 10 additions & 31 deletions ros_gz_image/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,11 @@ find_package(ros_gz_bridge REQUIRED)
find_package(rclcpp REQUIRED)
find_package(sensor_msgs REQUIRED)

if(NOT DEFINED ENV{GZ_VERSION})
set(ENV{GZ_VERSION} "garden")
endif()

# Garden
if("$ENV{GZ_VERSION}" STREQUAL "garden")
find_package(gz-transport12 REQUIRED)
find_package(gz-msgs9 REQUIRED)

set(GZ_TARGET_PREFIX gz)
set(GZ_MSGS_VER ${gz-msgs9_VERSION_MAJOR})
set(GZ_TRANSPORT_VER ${gz-transport12_VERSION_MAJOR})
find_package(gz_transport_vendor REQUIRED)
find_package(gz-transport REQUIRED)

message(STATUS "Compiling against Gazebo Garden")
elseif("$ENV{GZ_VERSION}" STREQUAL "harmonic")
find_package(gz-transport13 REQUIRED)
find_package(gz-msgs10 REQUIRED)

set(GZ_TARGET_PREFIX gz)
set(GZ_MSGS_VER ${gz-msgs10_VERSION_MAJOR})
set(GZ_TRANSPORT_VER ${gz-transport13_VERSION_MAJOR})

message(STATUS "Compiling against Gazebo Garden")
else()
message(FATAL_ERROR "This branch is only compatible with Gazebo Garden forward.")
endif()
find_package(gz_msgs_vendor REQUIRED)
find_package(gz-msgs REQUIRED)

include_directories(include)

Expand All @@ -54,8 +33,8 @@ add_executable(${executable}
)

target_link_libraries(${executable}
${GZ_TARGET_PREFIX}-msgs${GZ_MSGS_VER}::core
${GZ_TARGET_PREFIX}-transport${GZ_TRANSPORT_VER}::core
gz-msgs::core
gz-transport::core
)

ament_target_dependencies(${executable}
Expand Down Expand Up @@ -89,8 +68,8 @@ if(BUILD_TESTING)
# )
# target_link_libraries(${test_publisher}_image
# ${catkin_LIBRARIES}
# ${GZ_TARGET_PREFIX}-msgs${GZ_MSGS_VER}::core
# ${GZ_TARGET_PREFIX}-transport${GZ_TRANSPORT_VER}::core
# $gz-msgs$::core
# $gz-transport::core
# gtest
# gtest_main
# )
Expand All @@ -102,8 +81,8 @@ if(BUILD_TESTING)
# test/subscribers/${test_subscriber}.cpp)
# target_link_libraries(test_${test_subscriber}_image
# ${catkin_LIBRARIES}
# ${GZ_TARGET_PREFIX}-msgs${GZ_MSGS_VER}::core
# ${GZ_TARGET_PREFIX}-transport${GZ_TRANSPORT_VER}::core
# $gz-msgs::core
# $gz-transport::core
# )
# endforeach(test_subscriber)
endif()
Expand Down
9 changes: 2 additions & 7 deletions ros_gz_image/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,8 @@
<depend>rclcpp</depend>
<depend>sensor_msgs</depend>

<!-- Garden (default) -->
<depend condition="$GZ_VERSION == '' or $GZ_VERSION == garden">gz-msgs9</depend>
<depend condition="$GZ_VERSION == '' or $GZ_VERSION == garden">gz-transport12</depend>

<!-- Harmonic -->
<depend condition="$GZ_VERSION == harmonic">gz-msgs10</depend>
<depend condition="$GZ_VERSION == harmonic">gz-transport13</depend>
<depend>gz_msgs_vendor</depend>
<depend>gz_transport_vendor</depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
Expand Down
54 changes: 14 additions & 40 deletions ros_gz_sim/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,45 +14,19 @@ find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)

if(NOT DEFINED ENV{GZ_VERSION})
set(ENV{GZ_VERSION} "garden")
endif()

if("$ENV{GZ_VERSION}" STREQUAL "garden")
find_package(gz-math7 REQUIRED)
set(GZ_MATH_VER ${gz-math7_VERSION_MAJOR})

find_package(gz-transport12 REQUIRED)
set(GZ_TRANSPORT_VER ${gz-transport12_VERSION_MAJOR})

find_package(gz-msgs9 REQUIRED)
set(GZ_MSGS_VER ${gz-msgs9_VERSION_MAJOR})

find_package(gz-sim7 REQUIRED)
set(GZ_SIM_VER ${gz-sim7_VERSION_MAJOR})
find_package(gz_math_vendor REQUIRED)
find_package(gz-math REQUIRED)

set(GZ_TARGET_PREFIX gz)
find_package(gz_transport_vendor REQUIRED)
find_package(gz-transport REQUIRED)

message(STATUS "Compiling against Gazebo Garden")
elseif("$ENV{GZ_VERSION}" STREQUAL "harmonic")
find_package(gz-math7 REQUIRED)
set(GZ_MATH_VER ${gz-math7_VERSION_MAJOR})
find_package(gz_msgs_vendor REQUIRED)
find_package(gz-msgs REQUIRED)

find_package(gz-transport13 REQUIRED)
set(GZ_TRANSPORT_VER ${gz-transport13_VERSION_MAJOR})

find_package(gz-msgs10 REQUIRED)
set(GZ_MSGS_VER ${gz-msgs10_VERSION_MAJOR})

find_package(gz-sim8 REQUIRED)
set(GZ_SIM_VER ${gz-sim8_VERSION_MAJOR})

set(GZ_TARGET_PREFIX gz)

message(STATUS "Compiling against Gazebo Harmonic")
else()
message(FATAL_ERROR "This branch is only compatible with Gazebo Garden forward.")
endif()
find_package(gz_sim_vendor REQUIRED)
find_package(gz-sim REQUIRED)
# Needed in launch/gz_sim.launch.py.in
set(GZ_SIM_VER ${gz-sim_VERSION_MAJOR})

gz_find_package(gflags
REQUIRED
Expand All @@ -66,9 +40,9 @@ ament_target_dependencies(create
)
target_link_libraries(create
gflags
${GZ_TARGET_PREFIX}-math${GZ_MATH_VER}::core
${GZ_TARGET_PREFIX}-msgs${GZ_MSGS_VER}::core
${GZ_TARGET_PREFIX}-transport${GZ_TRANSPORT_VER}::core
gz-math::core
gz-msgs::core
gz-transport::core
)
ament_target_dependencies(create std_msgs)

Expand Down Expand Up @@ -144,7 +118,7 @@ if(BUILD_TESTING)
${PROJECT_NAME}
)
target_link_libraries(test_create
${GZ_TARGET_PREFIX}-transport${GZ_TRANSPORT_VER}::core
gz-transport::core
)

install(
Expand Down
15 changes: 4 additions & 11 deletions ros_gz_sim/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,10 @@
<depend>rclcpp</depend>
<depend>std_msgs</depend>

<!-- Garden -->
<depend condition="$GZ_VERSION == '' or $GZ_VERSION == garden">gz-math7</depend>
<depend condition="$GZ_VERSION == '' or $GZ_VERSION == garden">gz-msgs9</depend>
<depend condition="$GZ_VERSION == '' or $GZ_VERSION == garden">gz-sim7</depend>
<depend condition="$GZ_VERSION == '' or $GZ_VERSION == garden">gz-transport12</depend>

<!-- Harmonic -->
<depend condition="$GZ_VERSION == harmonic">gz-math7</depend>
<depend condition="$GZ_VERSION == harmonic">gz-msgs10</depend>
<depend condition="$GZ_VERSION == harmonic">gz-sim8</depend>
<depend condition="$GZ_VERSION == harmonic">gz-transport13</depend>
<depend>gz_math_vendor</depend>
<depend>gz_msgs_vendor</depend>
<depend>gz_sim_vendor</depend>
<depend>gz_transport_vendor</depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
Expand Down
3 changes: 1 addition & 2 deletions ros_gz_sim_demos/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@

<buildtool_depend>ament_cmake</buildtool_depend>

<!-- Garden -->
<depend condition="$GZ_VERSION == '' or $GZ_VERSION == garden">gz-sim7</depend>
<depend>gz_sim_vendor</depend>

<exec_depend>image_transport_plugins</exec_depend>
<exec_depend>robot_state_publisher</exec_depend>
Expand Down

0 comments on commit e6e6b45

Please sign in to comment.