Skip to content

Commit 699a676

Browse files
quaglacopybara-github
authored andcommitted
Add find functions for joints, lights, and cameras to mjSpec bindings.
PiperOrigin-RevId: 717578768 Change-Id: I2087ccbb9cf8b3b8ec03e9eb2edb0707d4a4cac1
1 parent 600f4ac commit 699a676

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

python/mujoco/specs.cc

+21
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,27 @@ PYBIND11_MODULE(_specs, m) {
408408
return mjs_asGeom(mjs_findElement(self.ptr, mjOBJ_GEOM, name.c_str()));
409409
},
410410
py::return_value_policy::reference_internal);
411+
mjSpec.def(
412+
"find_joint",
413+
[](MjSpec& self, std::string& name) -> raw::MjsJoint* {
414+
return mjs_asJoint(
415+
mjs_findElement(self.ptr, mjOBJ_JOINT, name.c_str()));
416+
},
417+
py::return_value_policy::reference_internal);
418+
mjSpec.def(
419+
"find_light",
420+
[](MjSpec& self, std::string& name) -> raw::MjsLight* {
421+
return mjs_asLight(
422+
mjs_findElement(self.ptr, mjOBJ_LIGHT, name.c_str()));
423+
},
424+
py::return_value_policy::reference_internal);
425+
mjSpec.def(
426+
"find_camera",
427+
[](MjSpec& self, std::string& name) -> raw::MjsCamera* {
428+
return mjs_asCamera(
429+
mjs_findElement(self.ptr, mjOBJ_CAMERA, name.c_str()));
430+
},
431+
py::return_value_policy::reference_internal);
411432
mjSpec.def("compile", [mjmodel_from_spec_ptr](MjSpec& self) -> py::object {
412433
if (self.assets.empty()) {
413434
return mjmodel_from_spec_ptr(reinterpret_cast<uintptr_t>(self.ptr));

0 commit comments

Comments
 (0)