From e6e6b4584bbf7611d1f043b8ce1ff49e0ff2fd00 Mon Sep 17 00:00:00 2001 From: "Addisu Z. Taddese" Date: Wed, 24 Apr 2024 11:07:01 -0500 Subject: [PATCH] Use gz_vendor packages (#531) Signed-off-by: Addisu Z. Taddese --- .github/workflows/build-and-test.sh | 25 ++--------- .github/workflows/ros2-ci.yml | 12 +---- ros_gz_bridge/CMakeLists.txt | 68 ++++++++++------------------- ros_gz_bridge/package.xml | 8 +--- ros_gz_bridge/src/factory.hpp | 3 +- ros_gz_image/CMakeLists.txt | 41 +++++------------ ros_gz_image/package.xml | 9 +--- ros_gz_sim/CMakeLists.txt | 54 ++++++----------------- ros_gz_sim/package.xml | 15 ++----- ros_gz_sim_demos/package.xml | 3 +- 10 files changed, 61 insertions(+), 177 deletions(-) diff --git a/.github/workflows/build-and-test.sh b/.github/workflows/build-and-test.sh index e7aaf2f9..8909db55 100755 --- a/.github/workflows/build-and-test.sh +++ b/.github/workflows/build-and-test.sh @@ -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 diff --git a/.github/workflows/ros2-ci.yml b/.github/workflows/ros2-ci.yml index 1732131e..bf1cbd4e 100644 --- a/.github/workflows/ros2-ci.yml +++ b/.github/workflows/ros2-ci.yml @@ -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: @@ -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 diff --git a/ros_gz_bridge/CMakeLists.txt b/ros_gz_bridge/CMakeLists.txt index 6c2d4b3e..125acb5e 100644 --- a/ros_gz_bridge/CMakeLists.txt +++ b/ros_gz_bridge/CMakeLists.txt @@ -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 @@ -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} @@ -138,11 +118,6 @@ target_include_directories(${bridge_lib} "$" ) -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 @@ -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 @@ -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 @@ -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() diff --git a/ros_gz_bridge/package.xml b/ros_gz_bridge/package.xml index cf626a38..95247e4a 100644 --- a/ros_gz_bridge/package.xml +++ b/ros_gz_bridge/package.xml @@ -31,12 +31,8 @@ yaml_cpp_vendor vision_msgs - - gz-msgs9 - gz-transport12 - - gz-msgs10 - gz-transport13 + gz_msgs_vendor + gz_transport_vendor ament_cmake_gtest ament_lint_auto diff --git a/ros_gz_bridge/src/factory.hpp b/ros_gz_bridge/src/factory.hpp index 35daf416..ec00af7b 100644 --- a/ros_gz_bridge/src/factory.hpp +++ b/ros_gz_bridge/src/factory.hpp @@ -107,8 +107,7 @@ class Factory : public FactoryInterface { std::function 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()) { diff --git a/ros_gz_image/CMakeLists.txt b/ros_gz_image/CMakeLists.txt index 463bae6f..e6e8de26 100644 --- a/ros_gz_image/CMakeLists.txt +++ b/ros_gz_image/CMakeLists.txt @@ -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) @@ -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} @@ -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 # ) @@ -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() diff --git a/ros_gz_image/package.xml b/ros_gz_image/package.xml index cf46fb47..aa225d9b 100644 --- a/ros_gz_image/package.xml +++ b/ros_gz_image/package.xml @@ -16,13 +16,8 @@ rclcpp sensor_msgs - - gz-msgs9 - gz-transport12 - - - gz-msgs10 - gz-transport13 + gz_msgs_vendor + gz_transport_vendor ament_lint_auto ament_lint_common diff --git a/ros_gz_sim/CMakeLists.txt b/ros_gz_sim/CMakeLists.txt index 7f420e09..1cf5b4cc 100644 --- a/ros_gz_sim/CMakeLists.txt +++ b/ros_gz_sim/CMakeLists.txt @@ -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 @@ -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) @@ -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( diff --git a/ros_gz_sim/package.xml b/ros_gz_sim/package.xml index a4cad906..e06448fe 100644 --- a/ros_gz_sim/package.xml +++ b/ros_gz_sim/package.xml @@ -19,17 +19,10 @@ rclcpp std_msgs - - gz-math7 - gz-msgs9 - gz-sim7 - gz-transport12 - - - gz-math7 - gz-msgs10 - gz-sim8 - gz-transport13 + gz_math_vendor + gz_msgs_vendor + gz_sim_vendor + gz_transport_vendor ament_lint_auto ament_lint_common diff --git a/ros_gz_sim_demos/package.xml b/ros_gz_sim_demos/package.xml index 84dc78a7..bd4eeed7 100644 --- a/ros_gz_sim_demos/package.xml +++ b/ros_gz_sim_demos/package.xml @@ -10,8 +10,7 @@ ament_cmake - - gz-sim7 + gz_sim_vendor image_transport_plugins robot_state_publisher