Add mjs_bodyToFrame() to convert a body to a frame.

Also add test for attaching the world body.

PiperOrigin-RevId: 685603933
Change-Id: I3cfe7d226d6f032b5a587e44d0f4f18207977188
This commit is contained in:
Alessio Quaglino
2024-10-14 00:38:26 -07:00
committed by Copybara-Service
parent 52a0149cd1
commit 766cd20273
12 changed files with 169 additions and 6 deletions
+9
View File
@@ -4400,6 +4400,15 @@ mjs_resolveOrientation
Resolve alternative orientations to quat, return error if any.
.. _mjs_bodyToFrame:
mjs_bodyToFrame
~~~~~~~~~~~~~~~
.. mujoco-include:: mjs_bodyToFrame
Transform body into a frame.
.. _ElementInitialization:
Element initialization
+6 -6
View File
@@ -3848,16 +3848,16 @@ defaults and assets) will be copied in to the top-level model. :el:`attach` is a
all attachments will appear in the saved XML file.
.. admonition:: Known issues
:class: attention
:class: note
The :el:`attach` meta-element is new and not well tested. Please report any issues you encounter to the development
team. Additionally, the following known limitations exist, to be addressed in a future release:
The following known limitations exist, to be addressed in a future release:
- The world body cannot be attached.
- An entire model cannot be attached (i.e. including all elements, referenced or not).
- All assets from the child model will be copied in, whether they are referenced or not.
- Self-attach or circular references are not checked for and will lead to infinite loops.
- :ref:`Keyframes<keyframe>` are attached once, so they are not replicated in nested attachments.
- Circular references are not checked for and will lead to infinite loops.
- When attaching a model with :ref:`keyframes<keyframe>`, model compilation is required for the re-indexing to be
finalized. If a second attachment is performed without compilation, the keyframes from the first attachment will be
lost.
.. _body-attach-model:
+1
View File
@@ -3628,6 +3628,7 @@ void mjs_setDefault(mjsElement* element, mjsDefault* def);
void mjs_setFrame(mjsElement* dest, mjsFrame* frame);
const char* mjs_resolveOrientation(double quat[4], mjtByte degree, const char* sequence,
const mjsOrientation* orientation);
mjsFrame* mjs_bodyToFrame(mjsBody** body);
void mjs_defaultSpec(mjSpec* spec);
void mjs_defaultOrientation(mjsOrientation* orient);
void mjs_defaultBody(mjsBody* body);