Commit Graph

141 Commits

Author SHA1 Message Date
Sam Haves ac2cd5dfd6 Add support for querying of MjsTendon path from Python.
Fixes #2670

PiperOrigin-RevId: 822215254
Change-Id: Ice5a264e54f963776093511c6e4ac830aae6d4f8
2025-10-21 11:51:24 -07:00
Saran Tunyasuvunakool 2f65e23779 Add mj_extractState as a public API function.
This function allows the caller to extract a subset of components of a state previously obtained via `mj_getState` without having to first write it back into `mjData`.

PiperOrigin-RevId: 822165077
Change-Id: I6433261f4f5ec2e8d024bb7dee8f7dbf1e62666c
2025-10-21 10:01:22 -07:00
Sam Haves e4704cd28b Create list_dependencies sample to list all dependencies for an MCJF file.
PiperOrigin-RevId: 814816067
Change-Id: Idc6232e5d1ef1ff0318aeacd0e3d4b4a5a303485
2025-10-03 13:47:28 -07:00
Haroon Qureshi 6a7566872a Functions for printing the contents of mjvScene.
PiperOrigin-RevId: 812699642
Change-Id: Iafff53c952c952624129ff01a8c1b0aa5d38eec5
2025-09-29 02:47:17 -07:00
Kyle Bayes ea660f4c13 Expose minimal asset cache API.
PiperOrigin-RevId: 803126923
Change-Id: Iabf63802572f7cb86864b5ece85f44b3f15a4ec0
2025-09-04 12:18:36 -07:00
Yuval Tassa debfdf011e Add some missing Nullable annotations.
PiperOrigin-RevId: 799527319
Change-Id: If84a3b2f19243ea9cf8b114d1421879d8186eb1d
2025-08-26 05:52:01 -07:00
Yuval Tassa a230aa60c5 Improve mj_addM and associated test
- Updated docs to clarify that only the lower triangle is touched
- The function was unnecessarily adding the upper triangle in the sparse case
- The test used an unnecessarily large model and stepping it leading to timeouts under ASAN

PiperOrigin-RevId: 798528736
Change-Id: I592cc17dfb62379bb0cd6b332a8eb7e8b0ef6355
2025-08-23 03:56:47 -07:00
Google DeepMind a64a26c3ae No public description
PiperOrigin-RevId: 798355907
Change-Id: I3a225e3200cbc60ccc3d93f21694a606a7ab296a
2025-08-22 15:04:46 -07:00
Yuval Tassa 93c5665730 Add some missing Nullable annotations.
PiperOrigin-RevId: 798298579
Change-Id: I773eda7deca10c820345a33835716072e0b9af5a
2025-08-22 12:15:02 -07:00
Yuval Tassa 424226b640 Refactor mj_mulM to use CSR structure
PiperOrigin-RevId: 796450207
Change-Id: I2a9d567732614674547c7ae02ff0d3d4bbf1b654
2025-08-18 09:09:29 -07:00
Yuval Tassa 972ffd7b90 Improve mj_fullM documentation, add clarifying test.
PiperOrigin-RevId: 796134559
Change-Id: I85ab3680d3545ccf83d0d3af8a7c21cb36e96d4e
2025-08-17 11:02:14 -07:00
Yuval Tassa 1447711037 Rename spec to sig in state-related API functions.
(to avoid confusion with mjSpec)

PiperOrigin-RevId: 795848898
Change-Id: I0b64eb85f5c7a3ee889a746c751d9f5561650277
2025-08-16 08:38:25 -07:00
Yuval Tassa 32c7d3f085 Tag nullable arguments in main header. Fixes #309
Nullable arguments will be added to the `introspect` datastructures in a future change.

PiperOrigin-RevId: 789350522
Change-Id: I0bfd12fab5121f94b937264570f907593b63cf64
2025-07-31 08:39:16 -07:00
Alessio Quaglino 89f4789085 Add mjs_makeMesh to create a builtin mesh.
PiperOrigin-RevId: 788538127
Change-Id: I999733399a1a0da07b0f915f34d31364ab8b3b52
2025-07-29 11:31:18 -07:00
Yuval Tassa 46dc67b7eb Add function mjs_sensorDim to user API.
Note: change to (unreleased) contact sensor mjSpec API
PiperOrigin-RevId: 788507423
Change-Id: Ie639afb7ed01dc3f7bab43a3e812e8e0b0c67d07
2025-07-29 10:20:27 -07:00
Alessio Quaglino 67f9ffddbd Delete outdated mjs_delete doc.
PiperOrigin-RevId: 778912984
Change-Id: I2c09c67706679e9e85ea29fd63e698cddb0ef6ca
2025-07-03 09:54:52 -07:00
Alessio Quaglino 564c51ddb9 Check for duplicated names when setting element names.
PiperOrigin-RevId: 778827590
Change-Id: I77a208c1571cf735cae80840ea830aa347681f71
2025-07-03 03:20:55 -07:00
Alessio Quaglino 594e17074a Replace name attribute with setters and getters in the C API of mjSpec.
PiperOrigin-RevId: 778816015
Change-Id: Ieffb7a5bce37e887ff009f9a02d2434435e79ca1
2025-07-03 02:30:56 -07:00
Alessio Quaglino a00bfa819c Raise error when binding to a removed element.
PiperOrigin-RevId: 774462737
Change-Id: I820c0e1c010ae9fbf6d9667c3364d4b65bf21002
2025-06-22 10:15:31 -07:00
Yuval Tassa 14dc7c2a60 Add "cameraid" attribute to visual/global specifying the default camera to use at model load.
PiperOrigin-RevId: 773783069
Change-Id: I2fff2abdceedc982d89cee8d14b95abceea1c113
2025-06-20 11:41:27 -07:00
Alessio Quaglino 0488d9f4eb Replace mjs_detachBody and mjs_detachDefault with mjs_detach.
In a follow-up, mjs_detach will be changed to only remove without deleting an element.

PiperOrigin-RevId: 773637351
Change-Id: I9ee4d3584ba88ccc225591337cf036bab806e25c
2025-06-20 04:12:27 -07:00
Alessio Quaglino 84ad22a590 Add mj_copyBack for copying real-valued arrays from mjModel back to mjSpec.
Also add `SaveAndReadXML` function to test fixture using `mjSpec` as input.

PiperOrigin-RevId: 765393821
Change-Id: Ic257addd2fc89678fc11b226c168c077626cc51e
2025-05-30 17:17:14 -07:00
Yuval Tassa 89e39dc0a7 Expose mj_makeM as a sub-component.
PiperOrigin-RevId: 763662068
Change-Id: I55ced456dca751c1de09fb35e2f73c60ffc0d626
2025-05-27 00:35:55 -07:00
Yuval Tassa ced630181d Replace mjv_sceneState and related code with mjv_copy{Model,Data}
PiperOrigin-RevId: 760662776
Change-Id: I512bda9187fbc19ade6924b91d5cb2275078de42
2025-05-19 09:51:58 -07:00
Yuval Tassa 8268c6d1ff Add mjv_copyData
PiperOrigin-RevId: 760642972
Change-Id: I16227fd91bf42618fda684b15b3650758ae29b13
2025-05-19 08:59:43 -07:00
Yuval Tassa dfe22f7ef7 Remove stale reference to uncompressed sparse matrix.
PiperOrigin-RevId: 757775265
Change-Id: Ic18c0c89ab84285a7d93e24c65e50832ebc53c6f
2025-05-12 08:30:43 -07:00
Sam Haves 924ee3070a Modify user values in mujoco to allow users to provide cleanup functions to avoid memory leaks.
For the MJCF -> USD plugin, and I suspect other usecases for user values, it's necessary to give ownership of the object to Mujoco. However since they get type erased, we can't clean up the data automatically for the user. Instead this allows c++ clients to provide a cleanup function with their data.

PiperOrigin-RevId: 756832010
Change-Id: I80b8e7822e1a0e399a0d19dcaa57ee69b3ccc16a
2025-05-09 11:03:06 -07:00
Alessio Quaglino 3e9d130092 Add mjs_getPluginAttributes.
PiperOrigin-RevId: 752691116
Change-Id: Ib503a99f8d10661b8bf92410ccf471420f924986
2025-04-29 05:19:09 -07:00
Alessio Quaglino a02a27d4a4 Combine all mjs_attach functions into one.
PiperOrigin-RevId: 742702092
Change-Id: I89e35c59ada017cd061e2031584eeea71776743d
2025-04-01 08:05:58 -07:00
Alessio Quaglino 86c970bc23 Add error checking in mjs_setFrame.
Also raise error if the frame is not found in the mjCBody copy constructor.

Fixes #2543.

PiperOrigin-RevId: 742624013
Change-Id: I4999b3165c97f8d079412214d027ca7a8dae8cb3
2025-04-01 03:34:48 -07:00
Tom Power be64747166 add mjs_detachDefault to delete a default class from mjSpec
PiperOrigin-RevId: 738452369
Change-Id: I5a53a6dc8f89e1e8136aeefc09d7d9b7b7204e1f
2025-03-19 10:31:04 -07:00
Alessio Quaglino 209d2bd2c5 Added functionality for user payload data in mjSpec.
PiperOrigin-RevId: 738343134
Change-Id: I6217362ced9993afcd5a2914c78718ffe3bf753a
2025-03-19 04:36:00 -07:00
Alessio Quaglino 1bf24e9f67 Do not overwrite existing parent frames for worldbody elements when attaching an mjSpec to a frame or a site.
PiperOrigin-RevId: 737662046
Change-Id: I7028c21c803c01845ae1d53cb476f7b3df172313
2025-03-17 10:21:38 -07:00
Alessio Quaglino da04688071 Automatically compile mjSpec in to_xml().
Also, move mj_compile from MjModelWrapper to MjSpec.

PiperOrigin-RevId: 737640210
Change-Id: I93d2a31c33eb359452b0d966a29939183b4c5198
2025-03-17 09:21:10 -07:00
Yuval Tassa bd9d30adc7 Improve documentation of mj_saveLastXML fixes #2075
PiperOrigin-RevId: 735672207
Change-Id: I951b8be9cf12a2a4965a40bb8db4de4ddda18570
2025-03-11 01:57:46 -07:00
Kyle Bayes ed16f2daf2 Set nativeccd as default.
PiperOrigin-RevId: 731343200
Change-Id: I315779017b676f3d118e0d38ee53a515272f50b8
2025-02-26 09:15:15 -08:00
Alessio Quaglino ce82b63155 Add mjs_attachFrameToSite.
This is required in preparation of changing the spec.attach behavior in the Python bindings.

PiperOrigin-RevId: 730810198
Change-Id: I095808f0afe62b5bbd27201ed5c75804e0e9c4bf
2025-02-25 03:21:05 -08:00
Yuval Tassa fb07e0d1f7 Convert qLD to CSR format.
PiperOrigin-RevId: 728196818
Change-Id: I31bdf32e251293284426ed345019f27fd051a0e1
2025-02-18 07:14:45 -08:00
Yuval Tassa 5ee0654830 Roll back recent change to mjData.qLD until some issues are resolved.
PiperOrigin-RevId: 724389161
Change-Id: I1b30ab0950ab5c5e611b1c6fc3bf3f42f964939c
2025-02-07 10:21:42 -08:00
Yuval Tassa c27d3758c2 Convert qLD to CSR format.
PiperOrigin-RevId: 723955038
Change-Id: I30c3dc7f59739e89ae5fff8841432bc74717ec1b
2025-02-06 08:59:35 -08:00
Alessio Quaglino 7cdf180641 Introduce trilinear flex parametrization.
These flexes use only 24 DOFs (3 per vertex of the bounding box), while colliding with the full high resolution mesh.

On an 8x8x8 cube, the performance using DOFs at all vertices is

```
 Simulation time      : 18.74 s
 Steps per second     : 533
 Realtime factor      : 0.53 x
 Time per step        : 1874.4 µs

 Contacts per step    : 114.88
 Constraints per step : 3322.51
 Degrees of freedom   : 1536
```

With the new implementation, it is the following:

```
 Simulation time      : 1.82 s
 Steps per second     : 5507
 Realtime factor      : 5.51 x
 Time per step        : 181.6 µs

 Contacts per step    : 38.84
 Constraints per step : 155.36
 Degrees of freedom   : 24
```

PiperOrigin-RevId: 721008829
Change-Id: I833df027527db578d86667cc4b24295bcf6f7d22
2025-01-29 09:38:22 -08:00
Yuval Tassa 8c22181156 Fix documentation typos.
PiperOrigin-RevId: 720232771
Change-Id: I176db4d4168c37b2819df14b439c4cde838e2025
2025-01-27 10:58:22 -08:00
Alessio Quaglino c2138c3fb0 Do not copy the spec during attach.
Use a reference count for managing the memory.

PiperOrigin-RevId: 716169486
Change-Id: Id270c4858c17b9250115e9544d5ea143584e2d5f
2025-01-16 03:53:17 -08:00
Alessio Quaglino 05d4c3d670 Add mjs_getParent to retrieve the parent body of an object.
PiperOrigin-RevId: 715794859
Change-Id: Ib9792787cdb966f579938dde3f94ebabca8ef1fc
2025-01-15 07:42:43 -08:00
Alessio Quaglino f607d9554e Check that there are no pending keyframes while writing a spec.
This can happen when a body is detached without compiling or recompiling.

Also added error catching when trying to delete a body instead of detaching it.

Fixes #2327

PiperOrigin-RevId: 712526730
Change-Id: I4b48df83120fca12d475c85b3a54893841449653
2025-01-06 07:50:30 -08:00
Alessio Quaglino e310c23267 Fix return value of mj_saveXML and mj_saveXMLString, fixes #2247
PiperOrigin-RevId: 700269761
Change-Id: Ifb7e9c66c70eac7d681cfcf106712d47291cf9e2
2024-11-26 02:32:50 -08:00
Alessio Quaglino 7e46e21ef3 Add mju_mat2Rot.
This function extracts the 3D rotation from an arbitrary 3x3 matrix by refining the input quaternion. It is based on the paper "A robust method to extract the rotational part of deformations" by Müller, Matthias, Jan Bender, Nuttapong Chentanez, and Miles Macklin.

PiperOrigin-RevId: 700006006
Change-Id: I77550993233dea9cdf68601762a3ae7ded749bdf
2024-11-25 09:19:10 -08:00
Yuval Tassa 1d64362adc Add mjv_copyModel to copy mjModel, skipping large arrays not required for abstract visualization.
This functionality is meant for fast copying of `mjModel` when synchronizing the visualization state, as in the Python passive viewer.

PiperOrigin-RevId: 699199743
Change-Id: I13a5160063eb09139ec1aee9c4969bc1c6f547f1
2024-11-22 09:38:08 -08:00
Kyle Bayes 1d58576d28 Fetch source code line links for API functions on docs client side.
PiperOrigin-RevId: 692115441
Change-Id: Ifbedf6a4998000f99e2275cb43293b3050daf0ee
2024-11-01 03:28:53 -07:00
Taylor Howell f47840e57c Add mju_dense2sparse to public API.
PiperOrigin-RevId: 691125900
Change-Id: Id9b7c739ee14bff2317168da258b1a3acbdafdbe
2024-10-29 12:47:48 -07:00