Skip to content

Allow running Simulate app with plugin libraries from any folder #3357

Description

@scastro-nasa

The feature, motivation and pitch

Hi all -- I'm an engineer working with NASA on building out tools/applications with mujoco_ros2_control.

One thing that we have been working on is making new plugins, which works great with our custom entrypoint in mujoco_ros2_control.

However, we run into limitations running the simulate app standalone with our custom plugins if MuJoCo happens to be installed in a root-owned folder. This is due to the logic below, which assumes plugins are placed in a specific location which is tunable via preprocessor directive, but always is relative to the mujoco executable directory -- meaning that users have to copy their plugin libraries to this folder when they may not necessarily have permissions to do so:

mujoco/simulate/main.cc

Lines 189 to 197 in 080668d

const std::string plugin_dir = getExecutableDir() + sep + MUJOCO_PLUGIN_DIR;
mj_loadAllPluginLibraries(
plugin_dir.c_str(), +[](const char* filename, int first, int count) {
std::printf("Plugins registered by library '%s':\n", filename);
for (int i = first; i < first + count; ++i) {
std::printf(" %s\n", mjp_getPluginAtSlot(i)->name);
}
});
}

Would the maintainers be amenable to providing some kind of environment variable, command-line args, or other mechanism where users could specify additional paths to scan for plugins that may be anywhere on a user's file system? Or maybe we're unaware of an existing mechanism to do this.

We're happy to contribute changes, but wanted to get alignment from maintainers. Thanks for your help!

Alternatives

Our only alternative, really, is what we have working now: Automation that tries to copy the built plugin libraries to the install location, but gives users a warning if there is a permissions-related failure or their simulate binary is not found, prompting them to manually do the copying if possible.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions