Skip to content

Commit

Permalink
Use gz vendor packages and update to Harmonic (#28)
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 22, 2024
1 parent 9cec63e commit e0c618f
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 67 deletions.
17 changes: 9 additions & 8 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@ on:
pull_request
jobs:
test_sdformat_urdf:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
strategy:
matrix:
ros-distro: ["humble", "rolling"]
gazebo-version:
- "fortress" # libsdformat12
env:
GAZEBO_VERSION: ${{ matrix.gazebo-version }}
include:
- ros-distro: "rolling"
docker-image: "ubuntu:24.04"
container:
image: ${{ matrix.docker-image }}
steps:
- uses: ros-tooling/setup-ros@v0.7
- uses: ros-tooling/setup-ros@master
with:
required-ros-distributions: ${{ matrix.ros-distro }}
use-ros2-testing: true
- name: Build and test all packages
uses: ros-tooling/action-ros-ci@v0.2
uses: ros-tooling/action-ros-ci@v0.3
with:
target-ros2-distro: ${{ matrix.ros-distro }}
41 changes: 4 additions & 37 deletions sdformat_urdf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,48 +19,15 @@ 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)")
elseif("$ENV{GZ_VERSION}" STREQUAL "harmonic")
find_package(sdformat14 REQUIRED)
set(SDF_VER ${sdformat14_VERSION_MAJOR})
message(STATUS "Compiling against Gazebo Harmonic (libSDFormat 14)")
# 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()
find_package(sdformat_vendor REQUIRED)
find_package(sdformat REQUIRED)

# Add sdformat_urdf shared library
add_library(sdformat_urdf SHARED
src/sdformat_urdf.cpp
)
target_link_libraries(sdformat_urdf PUBLIC
sdformat${SDF_VER}::sdformat${SDF_VER}
sdformat::core
urdfdom_headers::urdfdom_headers
)
target_link_libraries(sdformat_urdf PRIVATE
Expand Down Expand Up @@ -88,7 +55,7 @@ target_link_libraries(sdformat_urdf_plugin PRIVATE

ament_export_dependencies(pluginlib)
ament_export_dependencies(rcutils)
ament_export_dependencies(sdformat${SDF_VER})
ament_export_dependencies(sdformat_vendor)
ament_export_dependencies(tinyxml2)
ament_export_dependencies(urdf_parser_plugin)
ament_export_dependencies(urdfdom_headers)
Expand Down
5 changes: 0 additions & 5 deletions sdformat_urdf/colcon.pkg

This file was deleted.

11 changes: 1 addition & 10 deletions sdformat_urdf/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,7 @@
<buildtool_depend>ament_cmake_ros</buildtool_depend>
<buildtool_export_depend>ament_cmake_ros</buildtool_export_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>
<!-- Harmonic -->
<depend condition="$GZ_VERSION == harmonic">sdformat14</depend>
<depend>sdformat_vendor</depend>

<depend>urdf</depend>

Expand Down
10 changes: 5 additions & 5 deletions sdformat_urdf/src/sdformat_urdf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ sdformat_urdf::convert_model(const sdf::Model & sdf_model, sdf::Errors & errors)
std::string relative_joint_name{""};
for (uint64_t j = 0; j < sdf_model.JointCount(); ++j) {
const sdf::Joint * sdf_joint = sdf_model.JointByIndex(j);
if (sdf_joint && sdf_joint->ChildLinkName() == sdf_link->Name()) {
if (sdf_joint && sdf_joint->ChildName() == sdf_link->Name()) {
relative_joint_name = sdf_joint->Name();
break;
}
Expand Down Expand Up @@ -212,7 +212,7 @@ sdformat_urdf::convert_model(const sdf::Model & sdf_model, sdf::Errors & errors)
// Fix poses and check for tree structure issues
while (joint_iter != joints_to_visit.end()) {
const sdf::Joint * sdf_joint = *joint_iter;
if (sdf_joint->ParentLinkName() == sdf_parent_link->Name()) {
if (sdf_joint->ParentName() == sdf_parent_link->Name()) {
// Visited parent link of this joint - don't look at it again
joint_iter = joints_to_visit.erase(joint_iter);

Expand Down Expand Up @@ -269,7 +269,7 @@ sdformat_urdf::convert_model(const sdf::Model & sdf_model, sdf::Errors & errors)

// Explore this child link later
link_stack.push_back(sdf_child_link);
} else if (sdf_joint->ChildLinkName() == sdf_parent_link->Name()) {
} else if (sdf_joint->ChildName() == sdf_parent_link->Name()) {
// Something is wrong here
if (sdf_parent_link == sdf_canonical_link) {
// The canonical link can't be a child of a joint
Expand Down Expand Up @@ -573,8 +573,8 @@ sdformat_urdf::convert_joint(const sdf::Joint & sdf_joint, sdf::Errors & errors)
}
}

urdf_joint->child_link_name = sdf_joint.ChildLinkName();
urdf_joint->parent_link_name = sdf_joint.ParentLinkName();
urdf_joint->child_link_name = sdf_joint.ChildName();
urdf_joint->parent_link_name = sdf_joint.ParentName();

return urdf_joint;
}
Expand Down
4 changes: 2 additions & 2 deletions sdformat_urdf/test/joint_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@ TEST(Joint, joint_revolute_default_limits)
EXPECT_EQ("joint_revolute", joint->name);
EXPECT_EQ(urdf::Joint::REVOLUTE, joint->type);
ASSERT_NE(nullptr, joint->limits);
EXPECT_DOUBLE_EQ(-1e16, joint->limits->lower); // SDFormat default
EXPECT_DOUBLE_EQ(1e16, joint->limits->upper); // SDFormat default
EXPECT_DOUBLE_EQ(-std::numeric_limits<double>::infinity(), joint->limits->lower);
EXPECT_DOUBLE_EQ(std::numeric_limits<double>::infinity(), joint->limits->upper);
EXPECT_DOUBLE_EQ(std::numeric_limits<double>::infinity(), joint->limits->effort);
EXPECT_DOUBLE_EQ(std::numeric_limits<double>::infinity(), joint->limits->velocity);
}
Expand Down

0 comments on commit e0c618f

Please sign in to comment.