File tree 3 files changed +18
-13
lines changed
3 files changed +18
-13
lines changed Original file line number Diff line number Diff line change @@ -84,14 +84,15 @@ def _value_binding_code(
84
84
fulltype = fulltype .replace ('mjOption' , 'raw::MjOption' )
85
85
fulltype = fulltype .replace ('mjVisual' , 'raw::MjVisual' )
86
86
fulltype = fulltype .replace ('mjStatistic' , 'raw::MjStatistic' )
87
+ element = '.element' if fullvarname == 'plugin' else ''
87
88
88
89
def_property_args = (
89
90
f'"{ varname } "' ,
90
91
f"""[]({ rawclassname } & self) -> { fulltype } {{
91
92
return self.{ fullvarname } ;
92
93
}}""" ,
93
94
f"""[]({ rawclassname } & self, { fulltype } { varname } ) {{
94
- self.{ fullvarname } = { varname } ;
95
+ self.{ fullvarname } { element } = { varname } { element } ;
95
96
}}""" ,
96
97
)
97
98
Original file line number Diff line number Diff line change @@ -483,6 +483,13 @@ PYBIND11_MODULE(_specs, m) {
483
483
py::arg (" suffix" ) = py::none (), py::arg (" site" ) = py::none (),
484
484
py::arg (" frame" ) = py::none (),
485
485
py::return_value_policy::reference_internal);
486
+ mjSpec.def (
487
+ " activate_plugin" ,
488
+ [](MjSpec& self, std::string& name) {
489
+ mjs_activatePlugin (self.ptr , name.c_str ());
490
+ },
491
+ py::arg (" name" ),
492
+ py::return_value_policy::reference_internal);
486
493
487
494
// ============================= MJSBODY =====================================
488
495
mjsBody.def (
Original file line number Diff line number Diff line change @@ -835,22 +835,19 @@ def test_delete(self):
835
835
self .assertEqual (model .nsensor , 9 )
836
836
837
837
def test_plugin (self ):
838
- xml = """
839
- <mujoco>
840
- <extension>
841
- <plugin plugin="mujoco.elasticity.cable"/>
842
- </extension>
843
- </mujoco>
844
- """
845
-
846
- spec = mujoco .MjSpec .from_string (xml )
847
- self .assertIsNotNone (spec .worldbody )
838
+ spec = mujoco .MjSpec ()
839
+ spec .activate_plugin ('mujoco.elasticity.cable' )
840
+ plugin = spec .add_plugin (
841
+ name = 'instance_name' ,
842
+ plugin_name = 'mujoco.elasticity.cable' ,
843
+ active = True ,
844
+ info = 'info' ,
845
+ )
848
846
849
847
body = spec .worldbody .add_body ()
848
+ body .plugin = plugin
850
849
body .plugin .plugin_name = 'mujoco.elasticity.cable'
851
- body .plugin .id = spec .add_plugin ()
852
850
body .plugin .active = True
853
- self .assertEqual (body .plugin .id , 0 )
854
851
855
852
geom = body .add_geom ()
856
853
geom .type = mujoco .mjtGeom .mjGEOM_BOX
You can’t perform that action at this time.
0 commit comments