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

Manual loading of plugins libraries fails via python api, but works fine via c++ api #2204

Open
2 tasks done
aaarne opened this issue Nov 3, 2024 · 0 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@aaarne
Copy link

aaarne commented Nov 3, 2024

Intro

Hi!

I am a graduate student at TU Munich and the German Aerospace Center (DLR); I use MuJoCo to research elastic robots with variable stiffness actuators.

My setup

MuJoCo version: 2.3.4
API: Both (Plugin Development: C++, Using the model: Python)
Architecture: Arch Linux on 6.11.5 kernel

What's happening? What did you expect?

I have an actuator plugin compiled into a separate shared library (.so) and a model using that plugin. Different scenarios:

  1. I use the model via the mujoco C++ API. I register the library via mj_loadPluginLibrary/mj_loadAllPluginLibraries or I use the simulate application and put the so where simulate wants. This works fine! (so model and plugin should be okay)
  2. I use the Python API and put the plugin .so into the mujoco plugin folder, where mujoco's __init__.py finds and loads it. This also works fine. (so it should generally work using the python API)
  3. I use the Python API, but keep my plugin .so in some folder where I want it. I use mujoco.mj_loadPluginLibrary/mujoco.mj_loadAllPluginLibraries to load the plugin manual via the python API. This does not work. I see that the library registers the plugin. I have compiled a printout into the .so that prints a message before registering the plugin in the mjPLUGIN_LIB_INIT, and I see that message. However, it then fails on loading the XML model with ValueError: XML Error: plugin vsa not found.

Steps for reproduction

  1. Generate a plugin library compiled into a separate .so file, and a model referencing that plugin.
  2. Load the library in python using the exposed functions mj_loadPluginLibrary or mj_loadAllPluginLibraries.
  3. The library registers the plugins.
  4. Load the XML model referencing the plugin. It will fail claiming it cannot find the plugin.

Minimal model for reproduction

<mujoco>
  <extension>
    <plugin plugin="testplugin"/>
  </extension>
  <worldbody>
    <light pos="0 0 1"/>
    <geom type="sphere" size="1" rgba="1 0 0 1"/>
  </worldbody>
</mujoco>

Code required for reproduction

import mujoco

mujoco.mj_loadPluginLibrary("somepath/mypluginlibrary.so")  
# after this call mjPLUGIN_LIB_INIT in mypluginlibrary.so is executed, so it is somehow loaded.

model = mujoco.MjModel.from_xml_string("some_model_using_testplugin_in_mypluginlibrary.xml")
# This fails with ValueError: XML Error: plugin testplugin not found, but testplugin is registered by mypluginlibrary.so

Doing the above steps via the c++ API works on the same files. It also works via the python API when removing the mj_loadPluginLibrary call and placing mypluginlibrary.so into mujoco/plugin.

Confirmations

@aaarne aaarne added the bug Something isn't working label Nov 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant