Skip to content

Commit

Permalink
Support Gazebo Garden (#17)
Browse files Browse the repository at this point in the history
Signed-off-by: Louise Poubel <[email protected]>
  • Loading branch information
chapulina authored Jul 18, 2022
1 parent fde1884 commit 68906cd
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 5 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
37 changes: 34 additions & 3 deletions sdformat_urdf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
12 changes: 10 additions & 2 deletions sdformat_urdf/package.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<package format="2">
<package format="3">
<name>sdformat_urdf</name>
<version>1.0.1</version>
<description>
Expand All @@ -17,7 +17,15 @@
<buildtool_depend>ament_cmake_ros</buildtool_depend>
<buildtool_export_depend>ament_cmake_ros</buildtool_export_depend>

<depend>sdformat12</depend>
<!-- Fortress (default) -->
<depend condition="$ROS_DISTRO == 'humble'">sdformat12</depend>
<depend condition="$ROS_DISTRO == 'rolling'">sdformat12</depend>
<depend condition="$GZ_VERSION == fortress">sdformat12</depend>
<depend condition="$GZ_VERSION == ''">sdformat12</depend>

<!-- Garden -->
<depend condition="$GZ_VERSION == garden">sdformat13</depend>

<depend>urdf</depend>

<build_depend>liburdfdom-headers-dev</build_depend>
Expand Down
2 changes: 2 additions & 0 deletions sdformat_urdf/test/joint_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include <urdf_model/types.h>
#include <sdformat_urdf/sdformat_urdf.hpp>

#include <ignition/math/Pose3.hh>
#include <ignition/math/Vector3.hh>
#include <sdf/Types.hh>

#include "sdf_paths.hpp"
Expand Down
1 change: 1 addition & 0 deletions sdformat_urdf/test/material_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <urdf_model/types.h>
#include <sdformat_urdf/sdformat_urdf.hpp>

#include <ignition/math/Vector4.hh>
#include <sdf/Types.hh>

#include "sdf_paths.hpp"
Expand Down

0 comments on commit 68906cd

Please sign in to comment.