-
Notifications
You must be signed in to change notification settings - Fork 108
Make SDF -> USD code a separate component of SDF #816
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
Changes from 1 commit
2349364
0c6e7ad
3b385c9
520b74f
9ba8ea1
3266e33
8de1eb6
b28967c
e8a73e4
93c045c
5b48e41
2f21fb2
24a2782
826e7d6
4a6b5b6
1a88972
ef48530
41ad073
de356cd
e5c29da
5e91938
6b53f95
92d20d2
1a2c406
cf81994
1741bb0
5f326e9
38a69ab
bff502f
5c6e870
09c06ea
f03ec70
206e698
08eccbf
15e6793
8785b7a
6404afd
63cc4c0
26c1a47
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if the Can someone confirm if adding |
||
|
||
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) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) | ||
|
||
project(usdSdfConversions) | ||
|
||
set(SDF_VER 12) | ||
find_package(sdformat${SDF_VER} COMPONENTS usd REQUIRED) | ||
|
||
add_executable(usdConverter usdConverter.cc) | ||
|
||
target_link_libraries(usdConverter | ||
PUBLIC | ||
sdformat${SDF_VER}::usd | ||
) |
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 `usdConverter`, 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 | ||
./usdConverter ../shapes.sdf shapes.usda | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. right now, this is not working - whenever I try to run the executable generated by the example, I get the following error:
This was not happening with this executable before turning all of this code into a separate component, so perhaps the component is not being created correctly at the moment. Does anyone know what's happening here? cc @scpeters |
||
``` | ||
|
||
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 | ||
``` |
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> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ | |
#include <pxr/usd/usd/stage.h> | ||
|
||
#include "sdf/sdf.hh" | ||
#include "sdf_usd_parser/world.hh" | ||
#include "sdf/world.hh" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried following the file structure for components in
This means that for the USD component, header files are in the path |
||
|
||
int main(int argc, const char* argv[]) | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ign_install_all_headers(COMPONENT usd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to have a dependency on
ign-common
in order to parse meshes to/from SDF and USD. I realize that this is a new dependency that we probably don't want to have, but since it's only needed by theusd
component, is it okay to have this new dependency?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it's ok