Skip to content

Commit

Permalink
Support Gazebo Harmonic and Ionic (#24)
Browse files Browse the repository at this point in the history
Signed-off-by: Alejandro Hernández Cordero <[email protected]>
  • Loading branch information
ahcorde authored Sep 17, 2024
1 parent f7c02fa commit 9a04432
Show file tree
Hide file tree
Showing 74 changed files with 401 additions and 442 deletions.
76 changes: 8 additions & 68 deletions .github/ci/before_cmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,73 +6,13 @@ BUILD_DIR=`pwd`

cd /tmp

# check that we can compile USD from sources (only Focal)
# see https://github.com/ignitionrobotics/sdformat/issues/869
return_code=0
if [ "$(lsb_release -r -s)" == "20.04" ]; then
USD_VERSION="21.11"
elif [ "$(lsb_release -r -s)" == "22.04" ]; then
USD_VERSION="22.11"
else
return_code=$(($return_code + 1))
fi

mkdir cmake_test
cd cmake_test

echo "cmake_minimum_required(VERSION 3.12)" > CMakeLists.txt

cmake . || return_code=$(($return_code + $?))
if [ $return_code -eq 0 ]
then
# compile USD from sources
cd /tmp
mkdir usd_binaries
cd usd_binaries

apt-get install libboost-all-dev p7zip-full -y

wget https://github.com/oneapi-src/oneTBB/archive/refs/tags/2019_U6.tar.gz
tar -xvf 2019_U6.tar.gz
cd oneTBB-2019_U6/
make -j 2
mkdir -p /tmp/install_tbb/lib
mkdir -p /tmp/install_tbb/include
cp build/*_release/libtbb* /tmp/install_tbb/lib
cp -r include/serial /tmp/install_tbb/include/
cp -r include/tbb /tmp/install_tbb/include/

cd ..

wget https://github.com/PixarAnimationStudios/USD/archive/refs/tags/v$USD_VERSION.zip
unzip v$USD_VERSION.zip
cd OpenUSD-$USD_VERSION
mkdir build
cd build

cmake -DCMAKE_INSTALL_PREFIX="/tmp/USD" -DCMAKE_PREFIX_PATH="/tmp/USD" \
-DCMAKE_BUILD_TYPE=Release \
-DPXR_PREFER_SAFETY_OVER_SPEED=ON \
-DPXR_ENABLE_PYTHON_SUPPORT=OFF \
-DBUILD_SHARED_LIBS=ON \
-DTBB_USE_DEBUG_BUILD=OFF \
-DTBB_ROOT=/tmp/install_tbb \
-DPXR_BUILD_DOCUMENTATION=OFF \
-DPXR_BUILD_TESTS=OFF \
-DPXR_BUILD_EXAMPLES=OFF \
-DPXR_BUILD_TUTORIALS=OFF \
-DPXR_BUILD_USD_TOOLS=OFF \
-DPXR_BUILD_IMAGING=OFF \
-DPXR_BUILD_USD_IMAGING=OFF \
-DPXR_BUILD_USDVIEW=OFF \
-DPXR_BUILD_ALEMBIC_PLUGIN=OFF \
-DPXR_BUILD_DRACO_PLUGIN=OFF \
-DPXR_ENABLE_MATERIALX_SUPPORT=OFF \
-DBoost_INCLUDE_DIR=/usr/include \
-DBoost_NO_BOOST_CMAKE=FALSE \
..

make -j$(nproc) install
fi
USD_VERSION="24.08"

# compile USD from sources
apt install libpyside2-dev python3-opengl cmake libglu1-mesa-dev freeglut3-dev mesa-common-dev libx11-dev -y
wget https://github.com/PixarAnimationStudios/USD/archive/refs/tags/v$USD_VERSION.zip
unzip v$USD_VERSION.zip
cd OpenUSD-$USD_VERSION
python3 build_scripts/build_usd.py --build-variant release --no-tests --no-imaging --no-examples --no-tutorials --no-docs --onetbb --no-python /tmp/USD

cd $BUILD_DIR
4 changes: 2 additions & 2 deletions .github/ci/packages.apt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
libgz-cmake3-dev
libgz-common5-dev
libgz-math7-dev
libgz-tools-dev
libgz-tools2-dev
libgz-utils2-dev
libgz-utils2-cli-dev
libsdformat13-dev
libsdformat14-dev
11 changes: 6 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,22 @@ name: Ubuntu
on: [push, pull_request]

jobs:
jammy-ci:
noble-ci:
runs-on: ubuntu-latest
name: Ubuntu Jammy CI
name: Ubuntu Noble CI
steps:
- name: Set env
run: |
echo "PATH=$PATH:/tmp/USD/bin" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/tmp/USD/lib" >> $GITHUB_ENV
echo "CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH:/tmp/USD" >> $GITHUB_ENV
echo "GZ_VERSION=harmonic" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Compile and test
id: ci
uses: gazebo-tooling/action-gz-ci@jammy
uses: gazebo-tooling/action-gz-ci@noble
with:
codecov-enabled: true
codecov-enabled: false
cppcheck-enabled: true
cpplint-enabled: true
2 changes: 1 addition & 1 deletion .github/workflows/pr-collection-labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ jobs:
steps:
- name: Add collection labels
if: github.event.action == 'opened'
uses: ignition-tooling/pr-collection-labeler@v1
uses: gazebo-tooling/pr-collection-labeler@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
55 changes: 34 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,41 @@ cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR)
#============================================================================
# Initialize the project
#============================================================================
project(ignition-usd0 VERSION 0.0.1)

#============================================================================
# Find ignition-cmake
#============================================================================
# If you get an error at this line, you need to install ignition-cmake
find_package(gz-cmake3 REQUIRED)
#--------------------------------------
# Find ignition-common
gz_find_package(gz-common5 REQUIRED COMPONENTS graphics)
set(GZ_COMMON_VER ${gz-common5_VERSION_MAJOR})
set(GZ_COMMON_LIB gz-common${GZ_COMMON_VER}::gz-common${GZ_COMMON_VER})
set(GZ_COMMON_GRAPHICS_LIB gz-common${GZ_COMMON_VER}::graphics)
#--------------------------------------
# Find ignition-utils
gz_find_package(gz-utils2 REQUIRED COMPONENTS cli)
set(GZ_UTILS_VER ${gz-utils2_VERSION_MAJOR})
set(GZ_UTILS_LIB gz-utils${GZ_UTILS_VER}::gz-utils${GZ_UTILS_VER})
set(GZ_UTILS_CLI_LIB gz-utils${GZ_UTILS_VER}::cli)
find_package(sdformat13 REQUIRED)
SET(SDFORMAT_VER 13)
project(gz_usd0 VERSION 0.0.1)

if("$ENV{GZ_VERSION}" STREQUAL "harmonic")
find_package(gz-cmake3 REQUIRED)
#--------------------------------------
# Find gz-common
gz_find_package(gz-common5 REQUIRED COMPONENTS graphics)
set(GZ_COMMON_VER ${gz-common5_VERSION_MAJOR})
set(GZ_COMMON_LIB gz-common${GZ_COMMON_VER}::gz-common${GZ_COMMON_VER})
set(GZ_COMMON_GRAPHICS_LIB gz-common${GZ_COMMON_VER}::graphics)
#--------------------------------------
# Find gz-utils
gz_find_package(gz-utils2 REQUIRED COMPONENTS cli)
set(GZ_UTILS_VER ${gz-utils2_VERSION_MAJOR})
set(GZ_UTILS_LIB gz-utils${GZ_UTILS_VER}::gz-utils${GZ_UTILS_VER})
set(GZ_UTILS_CLI_LIB gz-utils${GZ_UTILS_VER}::cli)
find_package(sdformat14 REQUIRED)
SET(SDFORMAT_VER 14)
else()
find_package(gz-cmake4 REQUIRED)
#--------------------------------------
# Find gz-common
gz_find_package(gz-common6 REQUIRED COMPONENTS graphics)
set(GZ_COMMON_VER ${gz-common6_VERSION_MAJOR})
set(GZ_COMMON_LIB gz-common${GZ_COMMON_VER}::gz-common${GZ_COMMON_VER})
set(GZ_COMMON_GRAPHICS_LIB gz-common${GZ_COMMON_VER}::graphics)
#--------------------------------------
# Find gz-utils
gz_find_package(gz-utils3 REQUIRED COMPONENTS cli)
set(GZ_UTILS_VER ${gz-utils3_VERSION_MAJOR})
set(GZ_UTILS_LIB gz-utils${GZ_UTILS_VER}::gz-utils${GZ_UTILS_VER})
set(GZ_UTILS_CLI_LIB gz-utils${GZ_UTILS_VER}::cli)
find_package(sdformat15 REQUIRED)
SET(SDFORMAT_VER 15)
endif()
########################################
# Find PXR
gz_find_package(pxr REQUIRED)
Expand Down
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
Gazebo version | Branch
-- | --
Fortress | [fortress](https://github.com/gazebosim/gz-usd/tree/fortress) |
Garden and higher versions | [main](https://github.com/gazebosim/gz-usd) |
Garden and higher versions | [garden](https://github.com/gazebosim/gz-usd/tree/garden) |
Harmonic and higher versions | [main](https://github.com/gazebosim/gz-usd) |

USD is a high-performance extensible software platform for collaboratively constructing animated 3D
scenes, designed to meet the needs of large-scale film and visual effects production.
Expand All @@ -17,14 +18,14 @@ If you have already installed `gz-usd` you might want to visit [the tutorial sec
# Requirements

You will need all of the dependencies for sdformat, along with the following additional dependencies:
* [USD](https://github.com/PixarAnimationStudios/USD/tree/v21.11#getting-and-building-the-code):
* [USD](https://github.com/PixarAnimationStudios/USD/tree/v24.08#getting-and-building-the-code):
Note: USD support is only available when building sdformat from source. USD requires CMAKE 3.12 this package is available from Ubuntu 20.0.

Clone the USD repository
```bash
git clone --depth 1 -b v21.11 https://github.com/PixarAnimationStudios/USD.git
git clone --depth 1 -b v24.08 https://github.com/PixarAnimationStudios/USD.git
```
Note: Only v21.11 supported currently
Note: Only v24.08 supported currently

Install dependencies not managed by the build script

Expand All @@ -34,7 +35,7 @@ You will need all of the dependencies for sdformat, along with the following add
Use the build script to compile USD. In order to speed up compilation, it is recommended to disable unneeded components.
```bash
cd USD
python3 build_scripts/build_usd.py --build-variant release --no-tests --no-examples --no-tutorials --no-docs --no-python <install_dir>
python3 build_scripts/build_usd.py --build-variant release --no-tests --no-examples --no-imaging --onetbb --no-tutorials --no-docs --no-python <install_dir>
```
For more information regarding the build options, see the USD docs at https://github.com/PixarAnimationStudios/USD/tree/v21.11#getting-and-building-the-code.

Expand All @@ -60,6 +61,7 @@ git clone https://github.com/gazebosim/gz-usd
cd gz-usd
mkdir build
cd build
export GZ_VERSION=<harmonic or ionic>
cmake ..
make
```
Expand All @@ -71,7 +73,6 @@ To see how the executable works, run the following command from the `./build/bin
./sdf2usd -h
```


### Note about building with colcon

You may need to add the USD library path to your `LD_LIBRARY_PATH` environment variable after sourcing the colcon workspace.
Expand Down
4 changes: 2 additions & 2 deletions include/gz/usd/UsdError.hh
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
#include <string>
#include <vector>

#include <ignition/utils/ImplPtr.hh>
#include <gz/utils/ImplPtr.hh>

#include <sdf/Error.hh>
#include <gz/usd/Export.hh>
#include <gz/gz_usd/Export.hh>
#include <gz/usd/config.hh>

namespace gz
Expand Down
2 changes: 2 additions & 0 deletions include/gz/usd/config.hh.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#ifndef GZ_USD_CONFIG_HH_
#define GZ_USD_CONFIG_HH_

#define GZ_USD_VISIBLE GZ_GZ_USD_VISIBLE

/* Package version number */
#define GZ_USD_MAJOR_VERSION ${PROJECT_VERSION_MAJOR}
#define GZ_USD_MINOR_VERSION ${PROJECT_VERSION_MINOR}
Expand Down
2 changes: 1 addition & 1 deletion include/gz/usd/sdf_parser/World.hh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#pragma pop_macro ("__DEPRECATED")

#include <gz/usd/config.hh>
#include "gz/usd/Export.hh"
#include "gz/gz_usd/Export.hh"
#include "gz/usd/UsdError.hh"
#include "sdf/World.hh"

Expand Down
2 changes: 1 addition & 1 deletion include/gz/usd/usd_parser/Parser.hh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <string>

#include <gz/usd/config.hh>
#include "gz/usd/Export.hh"
#include "gz/gz_usd/Export.hh"
#include "gz/usd/UsdError.hh"

namespace gz
Expand Down
4 changes: 2 additions & 2 deletions include/gz/usd/usd_parser/USDData.hh
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
#include <unordered_map>
#include <utility>

#include <ignition/utils/ImplPtr.hh>
#include <gz/utils/ImplPtr.hh>

#include "sdf/Material.hh"
#include "sdf/Types.hh"
#include <gz/usd/config.hh>
#include "sdf/system_util.hh"
#include "gz/usd/usd_parser/USDStage.hh"
#include "gz/usd/Export.hh"
#include "gz/gz_usd/Export.hh"
#include "gz/usd/UsdError.hh"

namespace gz
Expand Down
4 changes: 2 additions & 2 deletions include/gz/usd/usd_parser/USDStage.hh
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
#include <set>
#include <string>

#include <ignition/utils/ImplPtr.hh>
#include <gz/utils/ImplPtr.hh>

#include "sdf/Types.hh"
#include <gz/usd/config.hh>
#include "sdf/system_util.hh"
#include "gz/usd/Export.hh"
#include "gz/gz_usd/Export.hh"
#include "gz/usd/UsdError.hh"

namespace gz
Expand Down
10 changes: 5 additions & 5 deletions include/gz/usd/usd_parser/USDTransforms.hh
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
#include <string>
#include <vector>

#include <ignition/math/Pose3.hh>
#include <ignition/math/Quaternion.hh>
#include <ignition/math/Vector3.hh>
#include <gz/math/Pose3.hh>
#include <gz/math/Quaternion.hh>
#include <gz/math/Vector3.hh>

#include <ignition/utils/ImplPtr.hh>
#include <gz/utils/ImplPtr.hh>

// TODO(ahcorde) this is to remove deprecated "warnings" in usd, these warnings
// are reported using #pragma message so normal diagnostic flags cannot remove
Expand All @@ -38,7 +38,7 @@

#include <gz/usd/config.hh>
#include "sdf/system_util.hh"
#include "gz/usd/Export.hh"
#include "gz/gz_usd/Export.hh"
#include "gz/usd/UsdError.hh"
#include "USDData.hh"

Expand Down
Loading

0 comments on commit 9a04432

Please sign in to comment.