Skip to content

Commit

Permalink
Add find functions for joints, lights, and cameras to mjSpec bindings.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 717578768
Change-Id: I2087ccbb9cf8b3b8ec03e9eb2edb0707d4a4cac1
  • Loading branch information
quagla authored and copybara-github committed Jan 20, 2025
1 parent 600f4ac commit 699a676
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions python/mujoco/specs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,27 @@ PYBIND11_MODULE(_specs, m) {
return mjs_asGeom(mjs_findElement(self.ptr, mjOBJ_GEOM, name.c_str()));
},
py::return_value_policy::reference_internal);
mjSpec.def(
"find_joint",
[](MjSpec& self, std::string& name) -> raw::MjsJoint* {
return mjs_asJoint(
mjs_findElement(self.ptr, mjOBJ_JOINT, name.c_str()));
},
py::return_value_policy::reference_internal);
mjSpec.def(
"find_light",
[](MjSpec& self, std::string& name) -> raw::MjsLight* {
return mjs_asLight(
mjs_findElement(self.ptr, mjOBJ_LIGHT, name.c_str()));
},
py::return_value_policy::reference_internal);
mjSpec.def(
"find_camera",
[](MjSpec& self, std::string& name) -> raw::MjsCamera* {
return mjs_asCamera(
mjs_findElement(self.ptr, mjOBJ_CAMERA, name.c_str()));
},
py::return_value_policy::reference_internal);
mjSpec.def("compile", [mjmodel_from_spec_ptr](MjSpec& self) -> py::object {
if (self.assets.empty()) {
return mjmodel_from_spec_ptr(reinterpret_cast<uintptr_t>(self.ptr));
Expand Down

0 comments on commit 699a676

Please sign in to comment.