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

Out of the box use of bundled plugins when MuJoCo is used as a pure C/C++ library #554

Closed
traversaro opened this issue Oct 30, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@traversaro
Copy link
Contributor

traversaro commented Oct 30, 2022

Is your feature request related to a problem? Please describe.

I am working on the packaging of MuJoCo 2.3.0 for conda-forge, and I had doubt (that then can be a enhancement proposal, hence the type of issue).

From what I understand, the new plugin system, can be used out of the box in the following contexts:

Instead, if one is using MuJoCo C++, as of 2.3.0 plugins can not be loaded out of the box, unless copy and adapts the code in https://github.com/deepmind/mujoco/blob/2.3.0/simulate/main.cc#L173 to her/his application. Is my understanding correct? If not, please ignore the rest of the issue, thanks!

Describe the solution you'd like

It would be great if the bundled plugins loaded out of the box also in the C++ library. How to do it is a bit more tricky, basically as long MuJoCo is compiled as a shared library it would be possible to implement a mechanism similar to the one used for simulate, while if MuJoCo is compiled as static library this is not possible, leaving the option either to hardcoded the install path used as compilation, or use an environment variable.

Describe alternatives you've considered

That each executable using MuJoCo implemented its own code to load the bundled plugin, similar to what simulate does.

Additional context

Some interesting pointers on relocatability in C++ libraries can be found in:

@traversaro traversaro added the enhancement New feature or request label Oct 30, 2022
@saran-t
Copy link
Member

saran-t commented Oct 31, 2022

The original intention was that if someone is writing a new application that links against MuJoCo then they should decide for themselves how they would like to link and register their plugins. The logic that you point out in simulate is primarily for applications that are supposed to be general, which might expect users to be able to bring precompiled plugins along without having to rebuild the application itself.

Since it's still early days for plugins, I don't know how people will end up using the system. It's possible that the simulate way of working where all plugins in a particular directory are scanned and loaded is more suitable across the board.

We will likely add the loading loop like the one we use in simulate as a MuJoCo API function in our next release. User code will still be responsible for calling the loading loop function however.

@nimrod-gileadi
Copy link
Collaborator

Since version 2.3.1, we have the function mj_loadAllPluginLibraries which scans a directory for plugins. Hopefully that solves the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants