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

Add sdf -> usd light functionality to usd component #818

Merged
merged 30 commits into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
30 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
3443bbb
add light converting code to usd component
adlarkin Jan 8, 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
0ea1ac9
Merge branch 'ahcorde/sdf_to_usd_cmake' into adlarkin/add_lights_to_u…
adlarkin Jan 11, 2022
4cdd054
cleanup light code before first review
adlarkin Jan 12, 2022
b32b0f3
remove extra includes, add symbol visibility
adlarkin Jan 12, 2022
ae3ee43
Added feedback
ahcorde Jan 17, 2022
36d42fc
improved doc
ahcorde Jan 17, 2022
4545723
update CMake code
adlarkin Jan 18, 2022
2d0e6d7
Merge branch 'ahcorde/sdf_to_usd_cmake' into adlarkin/add_lights_to_u…
adlarkin Jan 19, 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
d1c7b1a
Merge branch 'ahcorde/sdf_to_usd_cmake' into adlarkin/add_lights_to_u…
adlarkin Jan 19, 2022
5d2c902
fix namespaces and build warnings, use sdf::Errors, set usdLux intens…
adlarkin Jan 19, 2022
3b292c6
Merge branch 'sdf12' into adlarkin/add_lights_to_usd_cmake
adlarkin Jan 24, 2022
d14dc37
update to work with sdf12 branch
adlarkin Jan 24, 2022
8073b07
Merge branch 'sdf12' into adlarkin/add_lights_to_usd_cmake
ahcorde Jan 25, 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
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 \
..

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
- 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 REQUIRED_BY usd PKGCONFIG pxr)

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
30 changes: 30 additions & 0 deletions examples/usdConverter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# 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, and then run the following commands to build the example (run these commands from this example directory):
```bash
mkdir build
cd build
cmake ..
make
```

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.usda` (run this command from the `build` directory):
```bash
./sdf2usd ../shapes.sdf shapes.usda
```

You can now view the contents of the generated USD file with `usdview` (this should have been installed when setting up the USD dependency):
```
usdview shapes.usda
```
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