Add spec lookup in the attached spec array using the compiler option pointer.

This enables to find the spec associated with the compiler option stored in the objects, which do not necessarily belong to the model that owns them.

PiperOrigin-RevId: 713259419
Change-Id: I579c770147ff07ed2a5edd20e7a795ee7cc27147
This commit is contained in:
Alessio Quaglino
2025-01-08 05:42:59 -08:00
committed by Copybara-Service
parent 8a5f092081
commit 6654d63438
6 changed files with 161 additions and 39 deletions
+7
View File
@@ -117,6 +117,8 @@ to :ref:`attach a body to a site<mjs_attachToSite>`:
mjSpec* parent = mj_makeSpec();
mjSpec* child = mj_makeSpec();
parent->compiler.degree = 0;
child->compiler.degree = 1;
mjsFrame* frame = mjs_addFrame(mjs_findBody(parent, "world"), NULL);
mjsSite* site = mjs_addSite(mjs_findBody(parent, "world"), NULL);
mjsBody* body = mjs_addBody(mjs_findBody(child, "world"), NULL);
@@ -133,6 +135,11 @@ or :ref:`attach a frame to a body<mjs_attachFrame>`:
mjsFrame* frame = mjs_addFrame(mjs_findBody(child, "world"), NULL);
mjsFrame* attached_frame = mjs_attachFrame(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
interperted. Compiler options are carried over during attachment, so the child model will be compiled using X, while the
parent will be compiled using Y.
.. _meDefault:
Default classes