Commit Graph

3604 Commits

Author SHA1 Message Date
Yuval Tassa abc02b736e Minor fixes to viewer diagnostics
- When `mjData.nefc` was 0 (solver not run at all), we were plotting the stale diagnostics from the last run; now fixed.
- In the case where islands were used, the semantic of the plotted diagnostic `sqrt_nnz` (square root of Hessian nonzeros) is changed. It used to be the sum of square roots of solver nonzeros per island, it is now the square root of the sum of all nonzeros in all islands. The semantic `sqrt(sum(nnz_i))` was found to be more consistent than `sum(sqrt(nnz_i))`, in the sense that switching islanding on/off leads to smaller changes and is more in line with the interpretation of islanding as [block-diagonalization](https://mujoco.readthedocs.io/en/3.3.7/computation/#constraint-islands).

PiperOrigin-RevId: 827624908
Change-Id: I5fc86364ead585a4752a6d44823fb75cf6c7c318
2025-11-03 13:23:05 -08:00
Baruch Tabanpour 501e561563 Import NVIDIA/warp from GitHub.
PiperOrigin-RevId: 827602811
Change-Id: I42f96098df4665de60065409b454688f92e976d1
2025-11-03 12:24:28 -08:00
Sam Haves 9319956a16 Modify mujoco_to_usd to operate on SdfLayer intead of SdfAbstractData.
Since we don't do any on demand data loading for USD and always convert everything it should be safe to use the SdfLayer API instead of the SdfAbstractData API. This enables other codepaths such as the USD writer class to reuse the same logic to generate USD specification from an mjSpec.

PiperOrigin-RevId: 827431722
Change-Id: I60a581e0c9577164a4a66229ea9dcb8912afcf74
2025-11-03 04:16:37 -08:00
Alessio Quaglino 3a7aa84e53 Add quadratic stiffness to flex.
PiperOrigin-RevId: 827409919
Change-Id: I3dff8ea49fb1726fec4acf5b91138d6d52c4bfba
2025-11-03 03:01:38 -08:00
Taylor Howell d4f13b4abc Update mjwarp/index.rst.
PiperOrigin-RevId: 827397313
Change-Id: I427a0476eb1530b53539d787c0b79aaf45f889d5
2025-11-03 02:18:56 -08:00
Yuval Tassa ad49733db2 Improve error message for insufficient arena memory in _realloc_con_efc.
PiperOrigin-RevId: 826845370
Change-Id: I09467dd44a6f9f01b89ff6c1d74cde493e84eb1c
2025-11-01 05:54:56 -07:00
Taylor Howell f604588a36 Update theme_overrides_mjwarp.css to not render return type information.
PiperOrigin-RevId: 826821680
Change-Id: I2d8a08755631b85f910051ea395ae9081d4e3759
2025-11-01 03:59:42 -07:00
Erik Frey fbb95d5e8c Import NVIDIA/warp from GitHub.
PiperOrigin-RevId: 826571491
Change-Id: I294abc5aa3714345ab295636d12428293ea69285
2025-10-31 11:47:29 -07:00
Matias Manevi 4086261714 Add JavaScript bindings and WASM support
Co-authored-by: Matija Kecman <matijak@google.com>
Co-authored-by: Sebastian Noreña Rendón <sebas.norena@creativa77.com.ar>
Co-authored-by: Kyle Bayes <kylebayes@google.com>
PiperOrigin-RevId: 826479070
Change-Id: I25acf36e6c20b091d8492e10798d028ae66f6733
2025-10-31 07:21:18 -07:00
Sam Haves 57f7145806 Create mjpDecoder, mj_parse, and mju_decodeResource
- plugin system similar to mjpResourceProvider, but instead of loading a resource it converts an existing mjResource into an mjSpec.
  - The returned spec is then composed into the referencing spec.
  - This enables different file types to generate arbitrary specs, and allows us to separate format parsing from compilation code.

Follow up CLs will move some of the logic in src/engine for PNG, USD, KTX, OBJ loading into decoders.

The mj_parse function MjSpec from a given file, it's a more generic version of mj_parseXML.

In it's implementation, mj_parse as opposed to mj_parseXML will look for any registered decoder and
not assume we are striclty dealing with MJCF.

PiperOrigin-RevId: 826149497
Change-Id: I0ece26904280cb94bd5ded6dd5a565c539d60254
2025-10-30 12:54:40 -07:00
Matija Kecman f2badc05ac Add JavaScript bindings and WASM support
Co-authored-by: Matija Kecman <matijak@google.com>
Co-authored-by: Sebastian Noreña Rendón <sebas.norena@creativa77.com.ar>
Co-authored-by: Kyle Bayes <kylebayes@google.com>
PiperOrigin-RevId: 826109484
Change-Id: I327fd54122762bd2e239cc31c602a3eb73051c26
2025-10-30 11:11:52 -07:00
Matias Manevi 76e64d96bb Add JavaScript bindings and WASM support
Co-authored-by: Matija Kecman <matijak@google.com>
Co-authored-by: Sebastian Noreña Rendón <sebas.norena@creativa77.com.ar>
Co-authored-by: Kyle Bayes <kylebayes@google.com>
PiperOrigin-RevId: 826094938
Change-Id: Id2658a187bc078056f4410c71202696753319e64
2025-10-30 10:38:16 -07:00
Taylor Howell 10f4b36fb7 MuJoCo Warp documentation: Beta software.
PiperOrigin-RevId: 825958166
Change-Id: I1e90d78d7413956cfa84711336be26a23a18e5aa
2025-10-30 03:37:22 -07:00
Alessio Quaglino 37563a050e Remove obsolete docs references to convexhull.
Fixes #2912.

PiperOrigin-RevId: 825679563
Change-Id: I8ee14415fb1eb64ece5cf4f3c07d016126025364
2025-10-29 13:17:48 -07:00
Taylor Howell 3df784fc84 Updates for MuJoCo Warp documentation.
PiperOrigin-RevId: 825489001
Change-Id: I6ec4a0433f96da05befeb2b76793763e50a893d8
2025-10-29 04:42:46 -07:00
Google DeepMind d769440924 Store asset keys relative to the MJCF. This CL fixes cases when loading a spec with "from_zip" that fails on zipped folders that contain a root directory.
PiperOrigin-RevId: 825484553
Change-Id: I79c6f542edbd3ffd167d0b5cecc704c32c8d6824
2025-10-29 04:24:09 -07:00
Alessio Quaglino 010d919244 Add __setattr__ to _MjBindModel and _MjBindData.
This allows setting attributes with bind using a list of mjSpec objects as arguments.

PiperOrigin-RevId: 825456920
Change-Id: Ie6af956feab0a805175d7aaecf26e071401fbf05
2025-10-29 02:55:08 -07:00
Haroon Qureshi 80eb511620 Remove dependency on Window, Physics, and Renderer classes.
PiperOrigin-RevId: 825137441
Change-Id: I099a518ca9618698401d0330a6ef08278168f88e
2025-10-28 11:42:17 -07:00
Haroon Qureshi 4620b9f23a Merge HandleMouseEvents and HandleKeyboardEvents back into app.cc.
PiperOrigin-RevId: 825081195
Change-Id: I36445b8c452b15ca26056a52fd1844cf77083c0a
2025-10-28 09:44:42 -07:00
Baruch Tabanpour d001bd6525 Add naconmax, deprecation warning for nconmax.
PiperOrigin-RevId: 825018530
Change-Id: I344b296ac4353592d65a85b826850eaa7df5d39a
2025-10-28 06:59:01 -07:00
Alessio Quaglino 2bdea1a0aa Use "/" as default prefix during attach if not specified.
The user can recover the old behavior by passing prefix="".

This enables to attach children with default and save a valid result to XML.

PiperOrigin-RevId: 825011185
Change-Id: Id20c2589da928bf92b77bdb01cfba73dfc1d2f52
2025-10-28 06:40:34 -07:00
Alessio Quaglino 1bfa8b6fa6 Do not add bodies at mesh points for quadratic flex interpolation.
PiperOrigin-RevId: 825001743
Change-Id: Ica085b947fb1c3f56251bceaa6a228f364535d3e
2025-10-28 06:13:27 -07:00
Haroon Qureshi 3b79d3f14b Set flags directly on Renderer class.
This removes a dependency on mjvScene from the App class.

PiperOrigin-RevId: 824983816
Change-Id: I20dd411e6359ee411f9b0b86d4442c090ba4bd5c
2025-10-28 05:24:05 -07:00
Haroon Qureshi 7ba0d96d77 Use mjvCamera directly for generating camera string.
PiperOrigin-RevId: 824982264
Change-Id: I0d8760bb27153849c8f4dacb10aa3162f29c2f6e
2025-10-28 05:18:58 -07:00
Yuval Tassa e1a73f9c4c Add early exit in mj_xfrcAccumulate using mju_isZeroByte
`xfrc_applied` mostly contains user perturbations which are rare. It is very often identically zero and for large arrays `mju_isZeroByte` is significantly faster than `mju_isZero`.

PiperOrigin-RevId: 824975356
Change-Id: Iadb1d300d68cf12de00c14a0665bd89924a2d7e0
2025-10-28 04:59:14 -07:00
Taylor Howell 017788b9d6 MuJoCo Warp documentation: Parallel Linesearch.
PiperOrigin-RevId: 824937806
Change-Id: I95b416f7b0380099aa6ea4200a27acfc2b2c6bb7
2025-10-28 03:01:07 -07:00
Haroon Qureshi a16805f8ee Add CMakeLists.txt files for new (experimental) code.
This includes the filament, toolbox, and studio projects.

Adds a MUJOCO_BUILD_STUDIO option to enable building of the `studio` app (disabled by default).

Adds a MUJOCO_USE_FILAMENT to allow the studio app to use the filament rendering backend. A separate MUJOCO_USE_FILAMENT_VULKAN flag can be used to enable vulkan rendering.

PiperOrigin-RevId: 824602367
Change-Id: I26d46c16211ae2118f96c163c4194fea5b5a15a9
2025-10-27 11:26:14 -07:00
Taylor Howell be055840b4 Add Batched Model Fields section to MuJoCo Warp documentation.
PiperOrigin-RevId: 824596731
Change-Id: Ic2fc96df6f8d9639286f08ec86c5cdca64fc03d8
2025-10-27 11:12:43 -07:00
Taylor Howell 3b11e31572 MuJoCo Warp documentation: Add nworld, nconmax, and njmax section and update introduction.
PiperOrigin-RevId: 824579564
Change-Id: I2f2b81d95e061168646fce12f7c6f7a1268385e9
2025-10-27 10:33:45 -07:00
Haroon Qureshi dbaf35d42c Add CMake configurations for new third_party dependencies.
Adds targets for dear_imgui, implot, filament, sdl2, and webp. These
targets are not currently used.

PiperOrigin-RevId: 824554405
Change-Id: Ibebdd50752d251852a945b6abc230e2c6e65fae9
2025-10-27 09:36:52 -07:00
Copybara-Service d971e5c2df Merge pull request #2908 from davidhozic:doc/fix-comments
PiperOrigin-RevId: 824546229
Change-Id: I9961e7f39d0549ff8b15a1007fb20832a0014bbd
2025-10-27 09:16:01 -07:00
Copybara-Service 23c3001a4c Merge pull request #2875 from google-deepmind:dependabot/pip/mjx/pip-25.2
PiperOrigin-RevId: 824514263
Change-Id: Ifeb956547e23722ea486e1e6da9a953826038626
2025-10-27 07:42:09 -07:00
Taylor Howell 85e9cff0c1 Update mj_geomDistance: don't flip geoms for nativeccd.
PiperOrigin-RevId: 824463375
Change-Id: Ic9c4cac916129b88575e0366e1b95353ce716ca2
2025-10-27 04:48:36 -07:00
Baruch Tabanpour 8c5154c9a3 Fix testspeed for mjx-warp.
PiperOrigin-RevId: 823691704
Change-Id: If90f6137915de134fdda3c7616bc810555c25d87
2025-10-24 15:47:14 -07:00
Saran Tunyasuvunakool 49a3caf84c Modify SimulationState proto to correspond to mj_getState.
PiperOrigin-RevId: 823494487
Change-Id: Ib284e3165ca691f5b690a376f7b28e51122e1bc4
2025-10-24 05:51:07 -07:00
Alessio Quaglino ec8ad21cb5 Normalize triangle coordinates such that their sum rather their norm is one.
This ensures that at e.g. the barycenter of the triangle each vertex has weight 1/3, as one would expect with barycentric coordinates, rather than 1/sqrt(3). This makes it consistent to the finite element interpolation used in the passive elastic forces.

PiperOrigin-RevId: 823458736
Change-Id: Ia5c02cba186a80612de38402f791695c33e991ab
2025-10-24 03:42:55 -07:00
Google DeepMind 7bf065c75b Implement equivalents to mj_getState, mj_setState and mj_stateSize in mjx
PiperOrigin-RevId: 823158825
Change-Id: I06bbf603f61ef2de8f83f32a211e8d468e0b7c5c
2025-10-23 13:09:51 -07:00
Haroon Qureshi 99c18f07d3 Increase buffer size.
The smaller size is a warning/error on some targets:

```
error: ‘ bytes’ directive output may be truncated writing 6 bytes into a region of size between 0 and 15
```
PiperOrigin-RevId: 823047552
Change-Id: Id66b5828cf84a512dffc452753f1881deb685584
2025-10-23 08:16:54 -07:00
Haroon Qureshi 1fd9b47fea Prefix assets path with "assets/".
PiperOrigin-RevId: 823044312
Change-Id: I0bde4428bd1992d6d4356e107dac471fa7cdecc6
2025-10-23 08:07:33 -07:00
Sam Haves 18e60369f3 If building simulate with USD support remove the no-deprecated warning due to deprecated header usage in USD.
PiperOrigin-RevId: 822807399
Change-Id: I2765f4a7260b5ac8b3ef5894c1c5ce7a3a745baf
2025-10-22 17:56:43 -07:00
Sam Haves febe75d54b Add tendon.cpp to mjcPhysics CMake
PiperOrigin-RevId: 822694422
Change-Id: Ic2f7c7a3b85526d49eb98c19118e6936ccb4e0f7
2025-10-22 12:30:16 -07:00
Sam Haves ae33724de1 Set info string on wrap instead of tendon when wrapping a prim in the path.
PiperOrigin-RevId: 822688877
Change-Id: I04f5f5576cc0ed43e0ec77d5fccb19d2d23d7349
2025-10-22 12:13:53 -07:00
Sam Haves c060385505 Add section in mjcPhysics documentation for MjcTendon.
PiperOrigin-RevId: 822602481
Change-Id: Icf2b3accd323ee9506ca1838c9a2bfc0f0d159c7
2025-10-22 08:35:54 -07:00
Haroon Qureshi f217a8f987 Implement FetchPackage; a simple wrapper around FindOrFetch.
FetchPackage calls FindOrFetch, but sets USE_SYSTEM_PACKAGE to OFF
(i.e. do not find, just fetch). It also sets EXCLUDE_FROM_ALL.

PiperOrigin-RevId: 822565180
Change-Id: I70476f57b8d3371cefd02e840add279423913f3f
2025-10-22 06:43:51 -07:00
Sam Haves 160b9480f9 Add support for tendons to mjcPhysics.
PiperOrigin-RevId: 822230926
Change-Id: I232a9fbfb473186ac742d210458ff0221a561126
2025-10-21 12:30:12 -07:00
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
Kyle Bayes 25f5be82ff Provide option to disable keyboard events for SDL.
PiperOrigin-RevId: 822154396
Change-Id: Ie4c8537de2c4b01437aae00ed6d6af1a8f419a73
2025-10-21 09:36:16 -07:00
Taylor Howell 9e1ed0720b Revert PDF documentation update to .readthedocs.yml.
PiperOrigin-RevId: 822102488
Change-Id: I223757e80c00421c2ea37c3b30718c93b0a3cee8
2025-10-21 07:09:57 -07:00
Alessio Quaglino 056945df20 Enable frames to create the same children as bodies.
PiperOrigin-RevId: 822097998
Change-Id: I8477d8abe2d6f711421126825fd94d39af1a4e07
2025-10-21 06:57:01 -07:00