File tree Expand file tree Collapse file tree 3 files changed +18
-13
lines changed
Expand file tree Collapse file tree 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(
8484 fulltype = fulltype .replace ('mjOption' , 'raw::MjOption' )
8585 fulltype = fulltype .replace ('mjVisual' , 'raw::MjVisual' )
8686 fulltype = fulltype .replace ('mjStatistic' , 'raw::MjStatistic' )
87+ element = '.element' if fullvarname == 'plugin' else ''
8788
8889 def_property_args = (
8990 f'"{ varname } "' ,
9091 f"""[]({ rawclassname } & self) -> { fulltype } {{
9192 return self.{ fullvarname } ;
9293 }}""" ,
9394 f"""[]({ rawclassname } & self, { fulltype } { varname } ) {{
94- self.{ fullvarname } = { varname } ;
95+ self.{ fullvarname } { element } = { varname } { element } ;
9596 }}""" ,
9697 )
9798
Original file line number Diff line number Diff line change @@ -483,6 +483,13 @@ PYBIND11_MODULE(_specs, m) {
483483 py::arg (" suffix" ) = py::none (), py::arg (" site" ) = py::none (),
484484 py::arg (" frame" ) = py::none (),
485485 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);
486493
487494 // ============================= MJSBODY =====================================
488495 mjsBody.def (
Original file line number Diff line number Diff line change @@ -835,22 +835,19 @@ def test_delete(self):
835835 self .assertEqual (model .nsensor , 9 )
836836
837837 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+ )
848846
849847 body = spec .worldbody .add_body ()
848+ body .plugin = plugin
850849 body .plugin .plugin_name = 'mujoco.elasticity.cable'
851- body .plugin .id = spec .add_plugin ()
852850 body .plugin .active = True
853- self .assertEqual (body .plugin .id , 0 )
854851
855852 geom = body .add_geom ()
856853 geom .type = mujoco .mjtGeom .mjGEOM_BOX
You can’t perform that action at this time.
0 commit comments