Add plugin support to Python bindings.
PiperOrigin-RevId: 480675078 Change-Id: I2967654b6662efced8ae62cae9b03c6c8e65c67c
This commit is contained in:
committed by
Copybara-Service
parent
23e4c03efc
commit
95fe2fbc40
@@ -54,5 +54,15 @@ if _MUJOCO_GL not in ('disable', 'disabled', 'off', 'false', '0'):
|
||||
from mujoco.glfw import GLContext
|
||||
|
||||
HEADERS_DIR = os.path.join(os.path.dirname(__file__), 'include/mujoco')
|
||||
PLUGINS_DIR = os.path.join(os.path.dirname(__file__), 'plugin')
|
||||
|
||||
PLUGIN_HANDLES = []
|
||||
|
||||
def _load_all_bundled_plugins():
|
||||
for directory, _, filenames in os.walk(PLUGINS_DIR):
|
||||
for filename in filenames:
|
||||
PLUGIN_HANDLES.append(ctypes.CDLL(os.path.join(directory, filename)))
|
||||
|
||||
_load_all_bundled_plugins()
|
||||
|
||||
__version__ = mj_versionString() # pylint: disable=undefined-variable
|
||||
|
||||
@@ -69,6 +69,14 @@ TEST_XML_SENSOR = r"""
|
||||
</mujoco>
|
||||
"""
|
||||
|
||||
TEST_XML_PLUGIN = r"""
|
||||
<mujoco model="test">
|
||||
<extension>
|
||||
<required plugin="mujoco.elasticity.cable"/>
|
||||
</extension>
|
||||
</mujoco>
|
||||
"""
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def temporary_callback(setter, callback):
|
||||
@@ -1111,5 +1119,8 @@ Euler integrator, semi-implicit in velocity.
|
||||
self.fail("Attribute '{}' differs from expected value: {}".format(
|
||||
name, str(e)))
|
||||
|
||||
def test_load_plugin(self):
|
||||
mujoco.MjModel.from_xml_string(TEST_XML_PLUGIN)
|
||||
|
||||
if __name__ == '__main__':
|
||||
absltest.main()
|
||||
|
||||
Reference in New Issue
Block a user