diff --git a/README.md b/README.md index 0545d70..4d7b648 100644 --- a/README.md +++ b/README.md @@ -11,3 +11,23 @@ See the [README in the `sdformat_urdf` package](./sdformat_urdf/README.md) for m * provides a library and a `urdf_parser_plugin` using that library to convert SDFormat XML to URDF C++ DOM structures * [`sdformat_test_files`](./sdformat_test_files/README.md) * provides SDFormat models using different parts of the SDFormat XML specification for testing + +## Version combinations + +This package can be compiled against versions of libSDFormat. + +Set the `GZ_VERSION` environment variable to match the libSDFormat version you'd like to compile against. +For example: + + export GZ_VERSION=fortress + +> You only need to set this variable when compiling, not when running. +ROS version | Gazebo version | libSDFormat version | Branch | Binaries hosted at +-- | -- | -- | -- | -- +Galactic | Citadel | 9.x | [galactic](https://github.com/ros/ros_ign/tree/galactic) | https://packages.ros.org +Galactic | Edifice | 11.x | [galactic](https://github.com/ros/ros_ign/tree/galactic) | only from source +Galactic | Fortress | 12.x | [galactic](https://github.com/ros/ros_ign/tree/galactic) | only from source +Humble | Fortress | 12.x | [ros2](https://github.com/ros/ros_ign/tree/ros2) | https://packages.ros.org +Humble | Garden | 13.x | [ros2](https://github.com/ros/ros_ign/tree/ros2) | only from source +Rolling | Fortress | 12.x | [ros2](https://github.com/ros/ros_ign/tree/ros2) | https://packages.ros.org +Rolling | Garden | 13.x | [ros2](https://github.com/ros/ros_ign/tree/ros2) | only from source diff --git a/sdformat_urdf/CMakeLists.txt b/sdformat_urdf/CMakeLists.txt index a6923d6..5c82e21 100644 --- a/sdformat_urdf/CMakeLists.txt +++ b/sdformat_urdf/CMakeLists.txt @@ -14,18 +14,49 @@ find_package(ament_cmake_ros REQUIRED) find_package(pluginlib REQUIRED) find_package(rcutils REQUIRED) -find_package(sdformat12 REQUIRED) find_package(urdfdom_headers 1.0.6 REQUIRED) find_package(urdf_parser_plugin REQUIRED) find_package(tinyxml2_vendor REQUIRED) find_package(TinyXML2 REQUIRED) +# Default to Fortress +set(SDF_VER 12) + +# If the user didn't specify a GZ distribution, pick the one matching the ROS distribution according to REP 2000 +if(NOT DEFINED ENV{GZ_VERSION} AND DEFINED ENV{ROS_DISTRO}) + if("$ENV{ROS_DISTRO}" STREQUAL "humble") + set(ENV{GZ_VERSION} "fortress") + endif() +endif() + +# Find libsdformat matching the picked GZ distribution +if("$ENV{GZ_VERSION}" STREQUAL "fortress") + find_package(sdformat12 REQUIRED) + set(SDF_VER ${sdformat12_VERSION_MAJOR}) + message(STATUS "Compiling against Gazebo Fortress (libSDFormat 12)") +elseif("$ENV{GZ_VERSION}" STREQUAL "garden") + find_package(sdformat13 REQUIRED) + set(SDF_VER ${sdformat13_VERSION_MAJOR}) + message(STATUS "Compiling against Gazebo Garden (libSDFormat 13)") +# No GZ distribution specified, find any version of libsdformat we can +else() + foreach(major RANGE 13 9) + find_package(sdformat${major} QUIET) + if(sdformat${major}_FOUND) + # Next `find_package` call will be a noop + set(SDF_VER ${major}) + message(STATUS "Compiling against libSDFormat ${major}") + break() + endif() + endforeach() +endif() + # Add sdformat_urdf shared library add_library(sdformat_urdf SHARED src/sdformat_urdf.cpp ) target_link_libraries(sdformat_urdf PUBLIC - sdformat12::sdformat12 + sdformat${SDF_VER}::sdformat${SDF_VER} urdfdom_headers::urdfdom_headers ) target_link_libraries(sdformat_urdf PRIVATE @@ -51,7 +82,7 @@ target_link_libraries(sdformat_urdf_plugin PRIVATE ament_export_dependencies(pluginlib) ament_export_dependencies(rcutils) -ament_export_dependencies(sdformat12) +ament_export_dependencies(sdformat${SDF_VER}) ament_export_dependencies(tinyxml2) ament_export_dependencies(urdf_parser_plugin) ament_export_dependencies(urdfdom_headers) diff --git a/sdformat_urdf/package.xml b/sdformat_urdf/package.xml index 9baf09f..c8ecf65 100644 --- a/sdformat_urdf/package.xml +++ b/sdformat_urdf/package.xml @@ -1,5 +1,5 @@ - + sdformat_urdf 1.0.1 @@ -17,7 +17,15 @@ ament_cmake_ros ament_cmake_ros - sdformat12 + + sdformat12 + sdformat12 + sdformat12 + sdformat12 + + + sdformat13 + urdf liburdfdom-headers-dev diff --git a/sdformat_urdf/test/joint_tests.cpp b/sdformat_urdf/test/joint_tests.cpp index cdf2973..303f65b 100644 --- a/sdformat_urdf/test/joint_tests.cpp +++ b/sdformat_urdf/test/joint_tests.cpp @@ -17,6 +17,8 @@ #include #include +#include +#include #include #include "sdf_paths.hpp" diff --git a/sdformat_urdf/test/material_tests.cpp b/sdformat_urdf/test/material_tests.cpp index 960313e..2133616 100644 --- a/sdformat_urdf/test/material_tests.cpp +++ b/sdformat_urdf/test/material_tests.cpp @@ -18,6 +18,7 @@ #include #include +#include #include #include "sdf_paths.hpp"