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 OpenUSD to the build #20898

Open
12 of 22 tasks
Tracked by #17833
jwnimmer-tri opened this issue Feb 7, 2024 · 7 comments
Open
12 of 22 tasks
Tracked by #17833

Add OpenUSD to the build #20898

jwnimmer-tri opened this issue Feb 7, 2024 · 7 comments
Assignees
Labels
component: build system Bazel, CMake, dependencies, memory checkers, linters priority: medium type: feature request

Comments

@jwnimmer-tri
Copy link
Collaborator

jwnimmer-tri commented Feb 7, 2024

This is a sub-task of #17833.

I'm filing it separately because it will involve a non-trivial amount of details that are mostly unrelated to the multibody and parsing side of Drake.

The call to action is to be able to run a unit test inside Drake that loads some minimal *.usd file by calling into OpenUSD and call some various accessor functions that interrogate the loaded scene. Basically a "proof of life" that we've successfully linked to a copy of OpenUSD can be run without crashing.

@jwnimmer-tri
Copy link
Collaborator Author

jwnimmer-tri commented Feb 7, 2024

I'll post here some info I've gathered on the build system front. As I learn more, I'll probably circle back and edit the summary in this post, as well as the original post.


One aspect of building OpenUSD is to identify any required dependencies, and any optional dependencies that we would like to opt-in to.

We need to check the licenses of those dependencies, and how to integrate them into our build. On first skim, all of the licensing questions will be easy (the licenses are unremarkable) and the only question on that front will be ensuring that we properly redistribute all of the notice texts.

The main question will be integrating OpenUSD and its dependencies the build system.

Some of the dependencies are already vendored:

  • OpenUSD/pxr/base/js/rapidjson
  • OpenUSD/pxr/base/tf/pxrDoubleConversion
  • OpenUSD/pxr/base/tf/pxrLZ4
  • etc

For these, we just need to be sure to obey ODR -- if we have another copy of the library in Drake, we either need to unify them in the workspace, or else ensure that their names will not conflict. For example in the case of pxrDoubleConversion the OpenUSD code has already patched in their own custom namespace, and so it would not conflict with our VTK copy of double-conversion (which is also wrapped in a custom namespace).


One required, non-vendored dependency is libtbb.

We already link a copy of libtbb as part of our MOSEK integration. I'm inclined to use the MOSEK version of TBB even in our non-MOSEK builds. I think it would simplify testing to always pin a single version, instead of different versions depending on build flags.


Another required, non-vendored dependency is boost.

It's a little tricky to figure out the exact subset of boost that is required (because the OpenUSD code mixes the Python bindings next to the non-Python sources, so I'm not sure exactly which OpenUSD files we need in Drake), but as a first approximation I'm seeing:

$ find OpenUSD/pxr/base OpenUSD/pxr/usd -name testenv -prune -o -name plugin -prune -o -name 'py*' -prune -o -name 'wrap*' -prune -o -name 'module.cpp' -prune -o -name '*Module*' -prune -o -name '*Py*' -prune -o -name 'pch.h' -prune -o -name '*.dox' -prune -o -type f -exec grep -h -e '#include.*<boost' \{\} + | sort -u
#include <boost/any.hpp>
#include <boost/intrusive_ptr.hpp>
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/hashed_index.hpp>
#include <boost/multi_index/identity.hpp>
#include <boost/none.hpp>
#include <boost/numeric/conversion/cast.hpp>
#include <boost/optional.hpp>
#include <boost/optional/optional_fwd.hpp>
#include <boost/preprocessor/...lots...>
#include <boost/ptr_container/ptr_set.hpp>
#include <boost/smart_ptr/intrusive_ptr.hpp>
#include <boost/utility.hpp>
#include <boost/variant.hpp>
#include <boost/vmd/is_empty.hpp>

Drake has a policy of not using Boost, because of ABI conflicts with other libraries that users might want to use that also use Boost, but of a different version.

That doesn't matter for things like BOOST_PP macros which evaporate in the object code, but will matter for anything with linkage.

Possibly we could use BCP to re-namespace the subset of Boost that we need for OpenUSD.

There are some heros trying to de-boostify OpenUSD with pull requests; possibly we could pour our fuel on that fire instead of working around the problem. TBD.

@jwnimmer-tri
Copy link
Collaborator Author

The next task is to identify exactly which modules of OpenUSD would be required to parse *.usd files into Drake. For example, we might need usd/usd and usd/usdGeom and usd/usdPhysics. Once we know that starting point, we can figure out the transitive closure of which dependencies are in play, and then start working out how to incorporate each of them.

@sherm1
Copy link
Member

sherm1 commented Feb 7, 2024

cc @erwincoumans

@jwnimmer-tri
Copy link
Collaborator Author

Perhaps a the first goal should be to get usdcat working? If that program runs successfully, that seems like a good proxy for what the Drake integration would need, at least as a first pass.

@jwnimmer-tri
Copy link
Collaborator Author

It looks like we might need to cherry-pick some patches from open pull requests, so that we can use a non-ancient version of TBB:

PixarAnimationStudios/OpenUSD#1600 (comment)

PixarAnimationStudios/OpenUSD#2825

@jwnimmer-tri
Copy link
Collaborator Author

The boost problem is a bit more acute than I had realized. For now in #20994 we've disabled OpenUSD in CI.

I'll try to get boost compiling in CI in perhaps the next two weeks.

@sherm1
Copy link
Member

sherm1 commented Feb 21, 2024

cc @hong-nvidia

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: build system Bazel, CMake, dependencies, memory checkers, linters priority: medium type: feature request
Projects
Status: Todo
Development

No branches or pull requests

2 participants