Enable to attach a spec to a frame.
PiperOrigin-RevId: 699703988 Change-Id: Idbddcbce1e68286248458eb0bd24d5080451a58a
This commit is contained in:
committed by
Copybara-Service
parent
3a12db9ad2
commit
f909d63cdf
@@ -665,6 +665,24 @@ PYBIND11_MODULE(_specs, m) {
|
||||
return new_body;
|
||||
},
|
||||
py::return_value_policy::reference_internal);
|
||||
mjsFrame.def(
|
||||
"attach",
|
||||
[](raw::MjsFrame& self, MjSpec& spec, std::string& prefix,
|
||||
std::string& suffix) -> raw::MjsFrame* {
|
||||
auto world = mjs_findBody(spec.ptr, "world");
|
||||
if (!world) {
|
||||
throw pybind11::value_error(
|
||||
mjs_getError(mjs_getSpec(self.element)));
|
||||
}
|
||||
auto attached_world =
|
||||
mjs_attachBody(&self, world, prefix.c_str(), suffix.c_str());
|
||||
if (!attached_world) {
|
||||
throw pybind11::value_error(
|
||||
mjs_getError(mjs_getSpec(self.element)));
|
||||
}
|
||||
return mjs_bodyToFrame(&attached_world);
|
||||
},
|
||||
py::return_value_policy::reference_internal);
|
||||
|
||||
// ============================= MJSGEOM =====================================
|
||||
mjsGeom.def("delete", [](raw::MjsGeom& self) { mjs_delete(self.element); });
|
||||
|
||||
Reference in New Issue
Block a user