Add support for querying of MjsTendon path from Python.

Fixes #2670

PiperOrigin-RevId: 822215254
Change-Id: Ice5a264e54f963776093511c6e4ac830aae6d4f8
This commit is contained in:
Sam Haves
2025-10-21 11:50:24 -07:00
committed by Copybara-Service
parent 2f65e23779
commit ac2cd5dfd6
9 changed files with 411 additions and 11 deletions
+54
View File
@@ -4388,6 +4388,42 @@ Return spec's first element of selected type.
Return spec's next element; return NULL if element is last.
.. _mjs_getWrapTarget:
`mjs_getWrapTarget <#mjs_getWrapTarget>`__
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. mujoco-include:: mjs_getWrapTarget
Get wrapped element in tendon path.
.. _mjs_getWrapSideSite:
`mjs_getWrapSideSite <#mjs_getWrapSideSite>`__
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. mujoco-include:: mjs_getWrapSideSite
Get wrapped element side site in tendon path if it has one, nullptr otherwise.
.. _mjs_getWrapDivisor:
`mjs_getWrapDivisor <#mjs_getWrapDivisor>`__
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. mujoco-include:: mjs_getWrapDivisor
Get divisor of mjsWrap wrapping a puller.
.. _mjs_getWrapCoef:
`mjs_getWrapCoef <#mjs_getWrapCoef>`__
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. mujoco-include:: mjs_getWrapCoef
Get coefficient of mjsWrap wrapping a joint.
.. _AttributeSetters:
Attribute setters
@@ -4533,6 +4569,24 @@ Get double array contents and optionally its size.
*Nullable:* ``size``
.. _mjs_getWrapNum:
`mjs_getWrapNum <#mjs_getWrapNum>`__
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. mujoco-include:: mjs_getWrapNum
Get number of elements a tendon wraps.
.. _mjs_getWrap:
`mjs_getWrap <#mjs_getWrap>`__
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. mujoco-include:: mjs_getWrap
Get mjsWrap element at position i in the tendon path.
.. _mjs_getPluginAttributes:
`mjs_getPluginAttributes <#mjs_getPluginAttributes>`__
+9
View File
@@ -12,6 +12,15 @@ General
- Increase Windows stack size to 16MB to enable models with deep nested body hierarchies.
- Added a new :ref:`mj_extractState` function that allows a subset of a state that was previously returned by
:ref:`mj_getState` to be extracted without having to be written back into ``mjData`` first.
- Tendon paths can now be queried from Python via ``MjsTendon.path``, the returned object
is iterable and indexing it will give the ``MjsWrap`` at the given index in the path.
- ``MjsWrap`` now exposes:
- ``type -> mujoco.mjtWrap``
- ``target -> MjsSite|MjsJoint|MjsGeom|None``
- ``sidesite -> MjsSite|None``
- ``coef -> real``
- ``divisor -> real``
Version 3.3.7 (October 13, 2025)
-----------------------------------
+6
View File
@@ -3500,6 +3500,10 @@ mjsElement* mjs_firstChild(mjsBody* body, mjtObj type, int recurse);
mjsElement* mjs_nextChild(mjsBody* body, mjsElement* child, int recurse);
mjsElement* mjs_firstElement(mjSpec* s, mjtObj type);
mjsElement* mjs_nextElement(mjSpec* s, mjsElement* element);
mjsElement* mjs_getWrapTarget(mjsWrap* wrap);
mjsSite* mjs_getWrapSideSite(mjsWrap* wrap);
double mjs_getWrapDivisor(mjsWrap* wrap);
double mjs_getWrapCoef(mjsWrap* wrap);
int mjs_setName(mjsElement* element, const char* name);
void mjs_setBuffer(mjByteVec* dest, const void* array, int size);
void mjs_setString(mjString* dest, const char* text);
@@ -3515,6 +3519,8 @@ void mjs_setPluginAttributes(mjsPlugin* plugin, void* attributes);
mjString* mjs_getName(mjsElement* element);
const char* mjs_getString(const mjString* source);
const double* mjs_getDouble(const mjDoubleVec* source, int* size);
int mjs_getWrapNum(const mjsTendon* tendonspec);
mjsWrap* mjs_getWrap(const mjsTendon* tendonspec, int i);
const void* mjs_getPluginAttributes(const mjsPlugin* plugin);
void mjs_setDefault(mjsElement* element, const mjsDefault* def);
int mjs_setFrame(mjsElement* dest, mjsFrame* frame);