Combine all mjs_attach functions into one.
PiperOrigin-RevId: 742702092 Change-Id: I89e35c59ada017cd061e2031584eeea71776743d
This commit is contained in:
committed by
Copybara-Service
parent
08d22baea1
commit
a02a27d4a4
@@ -3808,41 +3808,14 @@ Free all pointers with ``mju_free()``.
|
||||
|
||||
Attachment
|
||||
^^^^^^^^^^
|
||||
.. _mjs_attachBody:
|
||||
.. _mjs_attach:
|
||||
|
||||
`mjs_attachBody <#mjs_attachBody>`__
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
`mjs_attach <#mjs_attach>`__
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. mujoco-include:: mjs_attachBody
|
||||
.. mujoco-include:: mjs_attach
|
||||
|
||||
Attach child body to a parent frame, return the attached body if success or NULL otherwise.
|
||||
|
||||
.. _mjs_attachFrame:
|
||||
|
||||
`mjs_attachFrame <#mjs_attachFrame>`__
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. mujoco-include:: mjs_attachFrame
|
||||
|
||||
Attach child frame to a parent body, return the attached frame if success or NULL otherwise.
|
||||
|
||||
.. _mjs_attachToSite:
|
||||
|
||||
`mjs_attachToSite <#mjs_attachToSite>`__
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. mujoco-include:: mjs_attachToSite
|
||||
|
||||
Attach child body to a parent site, return the attached body if success or NULL otherwise.
|
||||
|
||||
.. _mjs_attachFrameToSite:
|
||||
|
||||
`mjs_attachFrameToSite <#mjs_attachFrameToSite>`__
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. mujoco-include:: mjs_attachFrameToSite
|
||||
|
||||
Attach child frame to a parent site, return the attached frame if success or NULL otherwise.
|
||||
Attach child to a parent, return the attached element if success or NULL otherwise.
|
||||
|
||||
.. _mjs_detachBody:
|
||||
|
||||
|
||||
@@ -175,11 +175,10 @@ replicating 200 times, suffixes will be ``000, 001, ...`` etc). All referencing
|
||||
and namespaced appropriately. Detailed examples of models using replicate can be found in the
|
||||
`model/replicate/ <https://github.com/google-deepmind/mujoco/tree/main/model/replicate>`__ directory.
|
||||
|
||||
There is a caveat concerning :ref:`keyframes<keyframe>` when using replicate. Since :ref:`mjs_attachFrame` is used to
|
||||
There is a caveat concerning :ref:`keyframes<keyframe>` when using replicate. Since :ref:`mjs_attach` is used to
|
||||
self-attach multiple times the enclosed kinematic tree, if this tree contains further :ref:`attach<body-attach>`
|
||||
elements, keyframes will not be replicated nor namespaced by :ref:`replicate<replicate>`, but they will be attached and
|
||||
namespaced once by the innermost call of :ref:`mjs_attachFrame` or :ref:`mjs_attachBody`. See the limitations discussed
|
||||
in :ref:`attach<body-attach>`.
|
||||
namespaced once by the innermost call of :ref:`mjs_attach`. See the limitations discussed in :ref:`attach<body-attach>`.
|
||||
|
||||
.. _replicate-count:
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@ Upcoming version (not yet released)
|
||||
|
||||
- The default value of the flag for toggling :ref:`internal flex contacts<flex-contact-internal>` was changed from
|
||||
"true" to "false". This feature has proven to be counterintuitive for users.
|
||||
- All of the attach functions (``mjs_attachBody``, ``mjs_attachFrame``, ``mjs_attachToSite``,
|
||||
``mjs_attachFrameToSite``) have been removed and replaced by a single function :ref:`mjs_attach`.
|
||||
|
||||
General
|
||||
^^^^^^^
|
||||
|
||||
@@ -3613,14 +3613,8 @@ void mju_threadPoolEnqueue(mjThreadPool* thread_pool, mjTask* task);
|
||||
void mju_threadPoolDestroy(mjThreadPool* thread_pool);
|
||||
void mju_defaultTask(mjTask* task);
|
||||
void mju_taskJoin(mjTask* task);
|
||||
mjsBody* mjs_attachBody(mjsFrame* parent, const mjsBody* child,
|
||||
const char* prefix, const char* suffix);
|
||||
mjsFrame* mjs_attachFrame(mjsBody* parent, const mjsFrame* child,
|
||||
const char* prefix, const char* suffix);
|
||||
mjsBody* mjs_attachToSite(mjsSite* parent, const mjsBody* child,
|
||||
const char* prefix, const char* suffix);
|
||||
mjsFrame* mjs_attachFrameToSite(mjsSite* parent, const mjsFrame* child,
|
||||
const char* prefix, const char* suffix);
|
||||
mjsElement* mjs_attach(mjsElement* parent, const mjsElement* 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);
|
||||
|
||||
@@ -111,9 +111,10 @@ This framework introduces a powerful new feature: attaching and detaching model
|
||||
to power the :ref:`attach<body-attach>` an :ref:`replicate<replicate>` meta-elements in MJCF. Attachment allows the user
|
||||
to move or copy a subtree from one model into another, while also copying or moving related referenced assets and
|
||||
referencing elements from outside the kinematic tree (e.g., actuators and sensors). Similarly, detaching a subtree will
|
||||
remove all associated elements from the model. The default behavior is to move during attach. The user can select to
|
||||
instead copy by passing the corresponding flag to ``mjs_setDeepCopy``. This flag is temporary set to true while parsing
|
||||
XMLs. It is possible to :ref:`attach a body to a frame<mjs_attachBody>`:
|
||||
remove all associated elements from the model. The default behavior is to move the child into the parent while
|
||||
attaching, so subsequent changes to the child will also change the parent. Alternatively, the user can choose to make an
|
||||
entirely new copy during attach using :ref:`mjs_setDeepCopy`. This flag is temporarily set to true while parsing XMLs.
|
||||
It is possible to :ref:`attach a body to a frame<mjs_attach>`:
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
@@ -121,29 +122,29 @@ XMLs. It is possible to :ref:`attach a body to a frame<mjs_attachBody>`:
|
||||
mjSpec* child = mj_makeSpec();
|
||||
parent->compiler.degree = 0;
|
||||
child->compiler.degree = 1;
|
||||
mjsFrame* frame = mjs_addFrame(mjs_findBody(parent, "world"), NULL);
|
||||
mjsBody* body = mjs_addBody(mjs_findBody(child, "world"), NULL);
|
||||
mjsBody* attached_body_1 = mjs_attachBody(frame, body, "attached-", "-1");
|
||||
mjsElement* frame = mjs_addFrame(mjs_findBody(parent, "world"), NULL)->element;
|
||||
mjsElement* body = mjs_addBody(mjs_findBody(child, "world"), NULL)->element;
|
||||
mjsBody* attached_body_1 = mjs_asBody(mjs_attach(frame, body, "attached-", "-1"));
|
||||
|
||||
or :ref:`attach a body to a site<mjs_attachToSite>`:
|
||||
or :ref:`attach a body to a site<mjs_attach>`:
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
mjSpec* parent = mj_makeSpec();
|
||||
mjSpec* child = mj_makeSpec();
|
||||
mjsSite* site = mjs_addSite(mjs_findBody(parent, "world"), NULL);
|
||||
mjsBody* body = mjs_addBody(mjs_findBody(child, "world"), NULL);
|
||||
mjsBody* attached_body_2 = mjs_attachToSite(site, body, "attached-", "-2");
|
||||
mjsElement* site = mjs_addSite(mjs_findBody(parent, "world"), NULL)->element;
|
||||
mjsElement* body = mjs_addBody(mjs_findBody(child, "world"), NULL)->element;
|
||||
mjsBody* attached_body_2 = mjs_asBody(mjs_attach(site, body, "attached-", "-2"));
|
||||
|
||||
or :ref:`attach a frame to a body<mjs_attachFrame>`:
|
||||
or :ref:`attach a frame to a body<mjs_attach>`:
|
||||
|
||||
.. code-block:: C
|
||||
|
||||
mjSpec* parent = mj_makeSpec();
|
||||
mjSpec* child = mj_makeSpec();
|
||||
mjsBody* body = mjs_addBody(mjs_findBody(parent, "world"), NULL);
|
||||
mjsFrame* frame = mjs_addFrame(mjs_findBody(child, "world"), NULL);
|
||||
mjsFrame* attached_frame = mjs_attachFrame(body, frame, "attached-", "-1");
|
||||
mjsElement* body = mjs_addBody(mjs_findBody(parent, "world"), NULL)->element;
|
||||
mjsElement* frame = mjs_addFrame(mjs_findBody(child, "world"), NULL)->element;
|
||||
mjsFrame* attached_frame = mjs_asFrame(mjs_attach(body, frame, "attached-", "-1"));
|
||||
|
||||
Note that in the above examples, the parent and child models have different values for ``compiler.degree``,
|
||||
corresponding to the :ref:`compiler/angle<compiler-angle>` attribute, specifying the units in which angles are
|
||||
|
||||
Reference in New Issue
Block a user