Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make SDF to USD a separate component of sdformat #817

Merged
merged 29 commits into from
Jan 24, 2022
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
5e13b49
make SDF to USD a separate component of sdformat
adlarkin Jan 6, 2022
fa4568b
Added ignition-common4 as a dependency
ahcorde Jan 7, 2022
18f3ac1
create world prim and add physics information
adlarkin Jan 10, 2022
3bbd6ea
add unit test for world conversion
adlarkin Jan 11, 2022
16e0789
Added ci to compile with USD
ahcorde Jan 11, 2022
ae3ee43
Added feedback
ahcorde Jan 17, 2022
36d42fc
improved doc
ahcorde Jan 17, 2022
4545723
update CMake code
adlarkin Jan 18, 2022
91629c0
included namespaces
ahcorde Jan 19, 2022
6347953
Added basic test to sdf2usd cmd
ahcorde Jan 19, 2022
bb6ee5a
changes in sdf2usd
ahcorde Jan 19, 2022
d1d7af6
Fixed usd tutorial
ahcorde Jan 19, 2022
bab9e37
Removed unneeded CMakeLists.txt
ahcorde Jan 19, 2022
cbdfa49
Moved CMakeLists.txt
ahcorde Jan 19, 2022
99fb170
update example docs and other nits before merge
adlarkin Jan 19, 2022
819d5f5
Merge branch 'sdf12' into ahcorde/sdf_to_usd_cmake
adlarkin Jan 19, 2022
92eca63
clean CI
ahcorde Jan 19, 2022
0618353
Fixed CMake warning
ahcorde Jan 19, 2022
bcc282b
Fixed cmake
ahcorde Jan 19, 2022
0fd2568
reverted changes in CMakeLists.txt
ahcorde Jan 19, 2022
0195564
Improved test
ahcorde Jan 21, 2022
d91557e
fix search path of sdf2usd executable in UNIT_sdf2usd_TEST
adlarkin Jan 22, 2022
f3922f0
alphabetize packages.apt
adlarkin Jan 22, 2022
4c454a3
cleanup before_cmake.sh
ahcorde Jan 24, 2022
95c07e9
changed file structure
ahcorde Jan 24, 2022
b29b737
Merge branch 'ahcorde/sdf_to_usd_cmake' of https://github.com/ignitio…
ahcorde Jan 24, 2022
c4c189f
File structure
ahcorde Jan 24, 2022
0851949
Added TODO
ahcorde Jan 24, 2022
01aeb57
fix include guard
adlarkin Jan 24, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .github/ci/before_cmake.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/sh -l

set -x

BUILD_DIR=`pwd`

cd /tmp

# check that we can compile USD from sources
mkdir cmake_test
cd cmake_test

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

return_code=0
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 libtbb-dev p7zip-full -y

wget https://github.com/PixarAnimationStudios/USD/archive/refs/tags/v21.11.zip
unzip v21.11.zip
sed -i '2059 i \ \ \ \ requiredDependencies.remove(BOOST)' USD-21.11/build_scripts/build_usd.py
ahcorde marked this conversation as resolved.
Show resolved Hide resolved
cd USD-21.11
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 \
-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_NO_BOOST_CMAKE=On \
-DBoost_INCLUDE_DIR=/usr/include \
-DBoost_NO_BOOST_CMAKE=FALSE \
ahcorde marked this conversation as resolved.
Show resolved Hide resolved
..

make -j$(nproc) install
fi

cd $BUILD_DIR
2 changes: 2 additions & 0 deletions .github/ci/packages.apt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
libignition-common4-dev
libignition-cmake2-dev
libignition-math6-dev
libignition-tools-dev
libignition-utils1-dev
libignition-utils1-cli-dev
libtinyxml2-dev
liburdfdom-dev
libxml2-utils
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ jobs:
runs-on: ubuntu-latest
name: Ubuntu Bionic CI
steps:
- name: Set env
run: |
export PATH=$PATH:/tmp/usd_binaries/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/tmp/usd_binaries/lib
export CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH:/tmp/usd_binaries
ahcorde marked this conversation as resolved.
Show resolved Hide resolved
- name: Checkout
uses: actions/checkout@v2
- name: Compile and test
Expand All @@ -18,6 +23,11 @@ jobs:
runs-on: ubuntu-latest
name: Ubuntu Focal 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
- name: Checkout
uses: actions/checkout@v2
- name: Compile and test
Expand Down
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,17 @@ if (BUILD_SDF)
ign_find_package(ignition-utils1 VERSION REQUIRED)
set(IGN_UTILS_VER ${ignition-utils1_VERSION_MAJOR})

########################################
# Find ignition common
ign_find_package(ignition-common4 COMPONENTS graphics REQUIRED_BY usd)
set(IGN_COMMON_VER ${ignition-common4_VERSION_MAJOR})

########################################
# Find PXR
ign_find_package(pxr QUIET REQUIRED_BY usd PKGCONFIG pxr)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like CI has a configuration warning still.

Copy link
Contributor

@adlarkin adlarkin Jan 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Configuration warnings should be gone now thanks to gazebo-tooling/release-tools#625, but I realize that until this PR is merged, gazebo-tooling/release-tools#625 will cause CI warnings on other sdformat PRs, as mentioned in gazebo-tooling/release-tools#625 (comment). I'm not sure if we should merge this PR first to take care of CI warnings on other PRs, or revert gazebo-tooling/release-tools#625 until it's time to merge this PR. Does anyone have thoughts on how to handle this?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we can merge this today? If so, I think it's fine, but if not, there are at least two PRs waiting to be merged blocked on the CI failure, so I would recommend reverting the release-tools change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think this can be merged today if the fix I mentioned in #817 (comment) seems valid. The only lingering question I have is about if we want to structure include guards in a particular way for the SDF -> USD and USD -> SDF converters, which isn't really a blocker: #817 (comment)

If CI is green, everything else has been addressed, so I think we should be good to go.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I addressed the include guard fix, so I'm just waiting on CI to see if it comes back green 🤞


ign_configure_build(HIDE_SYMBOLS_BY_DEFAULT QUIT_IF_BUILD_ERRORS)
ign_configure_build(HIDE_SYMBOLS_BY_DEFAULT QUIT_IF_BUILD_ERRORS
COMPONENTS usd)
ign_create_packages()

add_subdirectory(sdf)
Expand Down
23 changes: 23 additions & 0 deletions examples/usdConverter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Converting between SDF and USD

This example shows how a world in a SDF file can be converted to [USD](https://graphics.pixar.com/usd/release/index.html).

## Requirements

You will need all of the dependencies for sdformat, along with the following additional dependencies:
* USD: [installation instructions](https://github.com/PixarAnimationStudios/USD/blob/release/README.md#getting-and-building-the-code)
* [ignition-common4](https://github.com/ignitionrobotics/ign-common)

## Setup

Build sdformat, you should now have an executable named `sdf2usd`, which can be used to convert a SDF world file to a USD file.
The following command converts the example `shapes.sdf` file to its USD representation, stored in a file called `shapes.usd`:

```bash
sdf2usd ../shapes.sdf shapes.usd
```

You can now view the contents of the generated USD file with `usdview` (this should have been installed when setting up the USD dependency):
```bash
usdview shapes.usd
```
244 changes: 244 additions & 0 deletions examples/usdConverter/shapes.sdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@
<?xml version="1.0" ?>
<!--

Try moving a model:

ign service -s /world/shapes/set_pose --reqtype ignition.msgs.Pose --reptype ignition.msgs.Boolean --timeout 300 --req 'name: "box", position: {z: 5.0}'

-->
<sdf version="1.6">
<world name="shapes">
<scene>
<ambient>1.0 1.0 1.0</ambient>
<background>0.8 0.8 0.8</background>
</scene>

<light type="directional" name="sun">
<cast_shadows>true</cast_shadows>
<pose>0 0 10 0 0 0</pose>
<diffuse>0.8 0.8 0.8 1</diffuse>
<specular>0.2 0.2 0.2 1</specular>
<attenuation>
<range>1000</range>
<constant>0.9</constant>
<linear>0.01</linear>
<quadratic>0.001</quadratic>
</attenuation>
<direction>-0.5 0.1 -0.9</direction>
</light>

<model name="ground_plane">
<static>true</static>
<link name="link">
<collision name="collision">
<geometry>
<plane>
<normal>0 0 1</normal>
<size>100 100</size>
</plane>
</geometry>
</collision>
<visual name="visual">
<geometry>
<plane>
<normal>0 0 1</normal>
<size>100 100</size>
</plane>
</geometry>
<material>
<ambient>0.8 0.8 0.8 1</ambient>
<diffuse>0.8 0.8 0.8 1</diffuse>
<specular>0.8 0.8 0.8 1</specular>
</material>
</visual>
</link>
</model>

<model name="box">
<pose>0 0 0.5 0 0 0</pose>
<link name="box_link">
<inertial>
<inertia>
<ixx>0.16666</ixx>
<ixy>0</ixy>
<ixz>0</ixz>
<iyy>0.16666</iyy>
<iyz>0</iyz>
<izz>0.16666</izz>
</inertia>
<mass>1.0</mass>
</inertial>
<collision name="box_collision">
<geometry>
<box>
<size>1 1 1</size>
</box>
</geometry>
</collision>

<visual name="box_visual">
<geometry>
<box>
<size>1 1 1</size>
</box>
</geometry>
<material>
<ambient>1 0 0 1</ambient>
<diffuse>1 0 0 1</diffuse>
<specular>1 0 0 1</specular>
</material>
</visual>
</link>
</model>

<model name="cylinder">
<pose>0 -1.5 0.5 0 0 0</pose>
<link name="cylinder_link">
<inertial>
<inertia>
<ixx>0.1458</ixx>
<ixy>0</ixy>
<ixz>0</ixz>
<iyy>0.1458</iyy>
<iyz>0</iyz>
<izz>0.125</izz>
</inertia>
<mass>1.0</mass>
</inertial>
<collision name="cylinder_collision">
<geometry>
<cylinder>
<radius>0.5</radius>
<length>1.0</length>
</cylinder>
</geometry>
</collision>

<visual name="cylinder_visual">
<geometry>
<cylinder>
<radius>0.5</radius>
<length>1.0</length>
</cylinder>
</geometry>
<material>
<ambient>0 1 0 1</ambient>
<diffuse>0 1 0 1</diffuse>
<specular>0 1 0 1</specular>
</material>
</visual>
</link>
</model>

<model name="sphere">
<pose>0 1.5 0.5 0 0 0</pose>
<link name="sphere_link">
<inertial>
<inertia>
<ixx>0.1</ixx>
<ixy>0</ixy>
<ixz>0</ixz>
<iyy>0.1</iyy>
<iyz>0</iyz>
<izz>0.1</izz>
</inertia>
<mass>1.0</mass>
</inertial>
<collision name="sphere_collision">
<geometry>
<sphere>
<radius>0.5</radius>
</sphere>
</geometry>
</collision>

<visual name="sphere_visual">
<geometry>
<sphere>
<radius>0.5</radius>
</sphere>
</geometry>
<material>
<ambient>0 0 1 1</ambient>
<diffuse>0 0 1 1</diffuse>
<specular>0 0 1 1</specular>
</material>
</visual>
</link>
</model>

<model name="capsule">
<pose>0 -3.0 0.5 0 0 0</pose>
<link name="capsule_link">
<inertial>
<inertia>
<ixx>0.074154</ixx>
<ixy>0</ixy>
<ixz>0</ixz>
<iyy>0.074154</iyy>
<iyz>0</iyz>
<izz>0.018769</izz>
</inertia>
<mass>1.0</mass>
</inertial>
<collision name="capsule_collision">
<geometry>
<capsule>
<radius>0.2</radius>
<length>0.6</length>
</capsule>
</geometry>
</collision>
<visual name="capsule_visual">
<geometry>
<capsule>
<radius>0.2</radius>
<length>0.6</length>
</capsule>
</geometry>
<material>
<ambient>1 1 0 1</ambient>
<diffuse>1 1 0 1</diffuse>
<specular>1 1 0 1</specular>
</material>
</visual>
</link>
</model>

<model name="ellipsoid">
<pose>0 3.0 0.5 0 0 0</pose>
<link name="ellipsoid_link">
<inertial>
<inertia>
<ixx>0.068</ixx>
<ixy>0</ixy>
<ixz>0</ixz>
<iyy>0.058</iyy>
<iyz>0</iyz>
<izz>0.026</izz>
</inertia>
<mass>1.0</mass>
</inertial>
<collision name="ellipsoid_collision">
<geometry>
<ellipsoid>
<radii>0.2 0.3 0.5</radii>
</ellipsoid>
</geometry>
</collision>
<visual name="ellipsoid_visual">
<geometry>
<ellipsoid>
<radii>0.2 0.3 0.5</radii>
</ellipsoid>
</geometry>
<material>
<ambient>1 0 1 1</ambient>
<diffuse>1 0 1 1</diffuse>
<specular>1 0 1 1</specular>
</material>
</visual>
</link>
</model>
</world>
</sdf>
Loading