add mjs_detachDefault to delete a default class from mjSpec

PiperOrigin-RevId: 738452369
Change-Id: I5a53a6dc8f89e1e8136aeefc09d7d9b7b7204e1f
This commit is contained in:
Tom Power
2025-03-19 10:30:08 -07:00
committed by Copybara-Service
parent a1b9ffd124
commit be64747166
18 changed files with 261 additions and 24 deletions
+12 -2
View File
@@ -3851,7 +3851,16 @@ Attach child frame to a parent site, return the attached frame if success or NUL
.. mujoco-include:: mjs_detachBody
Detach body from mjSpec, remove all references and delete the body, return 0 on success.
Delete body and descendants from mjSpec, remove all references, return 0 on success.
.. _mjs_detachDefault:
`mjs_detachDefault <#mjs_detachDefault>`__
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. mujoco-include:: mjs_detachDefault
Delete default class and descendants from mjSpec, remove all references, return 0 on success.
.. _AddTreeElements:
@@ -3936,7 +3945,8 @@ Add frame to body.
.. mujoco-include:: mjs_delete
Delete object corresponding to the given element, return 0 on success.
Delete object corresponding to the given element, return 0 on success. This function should only be used for element
types that cannot have children, i.e. excluding bodies and default classes.
.. _AddNonTreeElements:
+5
View File
@@ -704,3 +704,8 @@ to the inputs. Below, :math:`\bar q` denotes the pre-modified quaternion:
Note that derivatives depend only on :math:`h` and :math:`v` (in fact, on :math:`s = h v`).
All outputs are optional.
.. _mjs_delete:
Delete object corresponding to the given element, return 0 on success. This function should only be used for element
types that cannot have children, i.e. excluding bodies and default classes.
+5 -2
View File
@@ -603,7 +603,9 @@ typedef enum mjtObj_ { // type of MujoCo object
mjNOBJECT, // number of object types
// meta elements, do not appear in mjModel
mjOBJ_FRAME = 100 // frame
mjOBJ_FRAME = 100, // frame
mjOBJ_DEFAULT // default
} mjtObj;
typedef enum mjtConstraint_ { // type of constraint
mjCNSTR_EQUALITY = 0, // equality constraint
@@ -3612,6 +3614,7 @@ mjsBody* mjs_attachToSite(mjsSite* parent, const mjsBody* child,
mjsFrame* mjs_attachFrameToSite(mjsSite* parent, const mjsFrame* child,
const char* prefix, const char* suffix);
int mjs_detachBody(mjSpec* s, mjsBody* b);
int mjs_detachDefault(mjSpec* s, mjsDefault* d);
mjsBody* mjs_addBody(mjsBody* body, const mjsDefault* def);
mjsSite* mjs_addSite(mjsBody* body, const mjsDefault* def);
mjsJoint* mjs_addJoint(mjsBody* body, const mjsDefault* def);
@@ -3652,7 +3655,7 @@ mjsBody* mjs_getParent(mjsElement* element);
mjsFrame* mjs_getFrame(mjsElement* element);
mjsFrame* mjs_findFrame(mjSpec* s, const char* name);
mjsDefault* mjs_getDefault(mjsElement* element);
const mjsDefault* mjs_findDefault(mjSpec* s, const char* classname);
mjsDefault* mjs_findDefault(mjSpec* s, const char* classname);
mjsDefault* mjs_getSpecDefault(mjSpec* s);
int mjs_getId(mjsElement* element);
mjsElement* mjs_firstChild(mjsBody* body, mjtObj type, int recurse);