Commit Graph

942 Commits

Author SHA1 Message Date
Yuval Tassa 7f74487a26 Fix implicit integrator derivatives for actearly actuators.
The derivative calculation for actuator velocity in implicit integrators now correctly accounts for the `actearly` flag, using the next activation value when `actearly` is true.

PiperOrigin-RevId: 868598722
Change-Id: Ia180afb15b31a718170aeaf9d4ac514bb9e6073b
2026-02-11 04:03:46 -08:00
Alessio Quaglino 419b96cb91 Reduce simulation steps in MjCollisionTest.PinchingSucceeds.
PiperOrigin-RevId: 868229821
Change-Id: I781955a8f06ca2338baa713ff6a3448b4743b35e
2026-02-10 11:05:10 -08:00
Alessio Quaglino e16ee4fcb4 Fix flex-parent coupling in implicit integrator.
The implicit integrator was not correctly accounting for the off-diagonal coupling terms between flex and non-flex (parent) degrees of freedom in the mass matrix. This change extracts these coupling terms during the factorization step and applies a correction to the flex forces before solving for the flex accelerations, ensuring that the parent accelerations influence the flex dynamics. A new test verifies that the implicit integrator now matches Euler for small timesteps in a model with flex-parent coupling.

PiperOrigin-RevId: 868098126
Change-Id: Ia8cccd7dd428cd0c0898e1663a7e41017a2311b2
2026-02-10 05:35:48 -08:00
Alessio Quaglino 0041fdcbb0 Add implicit stiffness for flex_interp to mj_implicitSkip.
PiperOrigin-RevId: 867706885
Change-Id: Ic94c65b618a415609bffe3d69a86f9034f2d2400
2026-02-09 11:54:27 -08:00
Yuval Tassa c1b3b3063e Fix gravcomp being ignored for movable bodies without joints. Fixes #3066
PiperOrigin-RevId: 867679545
Change-Id: I8c16d3a4c93d121fcc30cab5179ba44fe49aaa19
2026-02-09 10:55:07 -08:00
Yuval Tassa d680b3d234 Rename "delay" buffer functions to "history" buffers.
The functions and associated tests related to managing time-stamped data buffers have been renamed from `mju_delay*` to `mju_history*` to better reflect their general purpose beyond just handling delays.

PiperOrigin-RevId: 866978339
Change-Id: I8655e91bce783287ad2adc412d13a1c39aa2c322
2026-02-07 14:10:16 -08:00
Saran Tunyasuvunakool 74d657a777 Add X macros for mjVisual and mjStatistic.
PiperOrigin-RevId: 866502731
Change-Id: I7cfaf3cd96512d93c801b7611eedb71689e21a5b
2026-02-06 09:53:22 -08:00
Yuval Tassa 6419534bad Add actuator and sensor delays. Fixes #1004
PiperOrigin-RevId: 866478839
Change-Id: Id21a6da0f98454c8fa39ea5af8a5e213d6eae497
2026-02-06 08:47:36 -08:00
Yuval Tassa 84fa527723 Add delay buffer utilities to engine_util_misc.
PiperOrigin-RevId: 866450284
Change-Id: I86d6dd6a6f7519640f75ca405fb60a12e8619c86
2026-02-06 07:22:34 -08:00
Alessio Quaglino 6afd742f43 Fix trilinear flexcomp with unused vertices.
Fix a crash and dimension mismatch issue in user_flexcomp when dealing with interpolated="true" meshes that contain unused vertices. Previously, vertbody would correspond only to used vertices while vert included all vertices, leading to assertions or out-of-bounds access. Also enable node pinning for interpolated meshes.

PiperOrigin-RevId: 865881995
Change-Id: Id150f00f22b5f48896ffbffddf03c57b252de8c0
2026-02-05 04:41:02 -08:00
Sam Haves a6a639003f Fix number of textures in BM_CompileManyTextures to 100.
PiperOrigin-RevId: 865475996
Change-Id: I63fd1e8b9aaff9536a9609d8f8390f8c9473785e
2026-02-04 10:35:20 -08:00
Alessio Quaglino a54c9f1d78 Specialized box and capsule collision primitives for stable 2D flex interactions.
PiperOrigin-RevId: 864500749
Change-Id: I52aed6e29569477a8a0b6b5eb55ad483f1077c0e
2026-02-02 13:36:42 -08:00
Sam Haves f0d5ed73b2 Restore cache capacity after BM_CompileManyTextures benchmark.
The BM_CompileManyTextures benchmark temporarily sets the MuJoCo cache capacity to 0. This change ensures that the original cache capacity is restored after the benchmark completes, preventing side effects on other tests.

PiperOrigin-RevId: 864332653
Change-Id: I5f756e30d4922d5e6f9b70d19ba9d0e31cde9259
2026-02-02 06:43:05 -08:00
Sam Haves 683b1b5d38 Create threadpool for src/user and primarily compiler usage.
PiperOrigin-RevId: 864328236
Change-Id: Iffaa9b8e6eacdb038020af9d6ad82d7cb7a6c941
2026-02-02 06:31:00 -08:00
Haroon Qureshi b073cd2ca4 Refactor mjVFS and resource management.
Resource operations (e.g. mju_openResource, mju_readResource, and
mju_closeResource, etc.) are now all handled by a VFS instance. It
is now up to the VFS to determine which provider to use in order to
handle those operations.

This allows us to dynamically add/remove (aka "mount") providers to
a VFS to handle special requests. mj_addFileVFS and mj_addBufferVFS
have been reimplemented as two such use-cases. Moreover, we expose
the mounting behaviour with two new functions: mj_mountVFS and
mj_unmountVFS.

PiperOrigin-RevId: 863248779
Change-Id: I8bcbd5445814ba1e72c6d7b80ad6a054f5f1df57
2026-01-30 08:20:53 -08:00
Haroon Qureshi 2fd9b5e92f Partial roll back VFS refactor due internal breakages
PiperOrigin-RevId: 862210191
Change-Id: Ia15a345a267bcef4b593d507d54f1668da0c0611
2026-01-28 06:40:11 -08:00
Haroon Qureshi 32a4412e2b First-pass implementation of a spec loader for zipped assets.
PiperOrigin-RevId: 861625990
Change-Id: I65cf601cd9aa3aab4915a5a247dda00a6a9aa3db
2026-01-27 03:18:30 -08:00
Haroon Qureshi 0ddbb46fa1 Refactor mjVFS and resource management.
Resource operations (e.g. mju_openResource, mju_readResource, and
mju_closeResource, etc.) are now all handled by a VFS instance. It
is now up to the VFS to determine which provider to use in order to
handle those operations.

This allows us to dynamically add/remove (aka "mount") providers to
a VFS to handle special requests. mj_addFileVFS and mj_addBufferVFS
have been reimplemented as two such use-cases. Moreover, we expose
the mounting behaviour with two new functions: mj_mountVFS and
mj_unmountVFS.

PiperOrigin-RevId: 861550939
Change-Id: I070eb4bcc2982466c8f368f7918005538baa5185
2026-01-26 23:53:29 -08:00
Alessio Quaglino 7da271c687 Add vertex equality option.
PiperOrigin-RevId: 860299454
Change-Id: I7befd8e5f4c8bac6d74684a96a9cc3cee9ae1e29
2026-01-23 16:30:05 -08:00
Yuval Tassa 30b903b6c0 Migrate mjModel size fields from int to mjtSize.
This change updates all size-related members within the `mjModel` struct from `int` to `mjtSize`. This allows MuJoCo to handle models with a larger number of elements. Corresponding changes were made to macros, function signatures, and I/O routines to accommodate the new `mjtSize` type.

PiperOrigin-RevId: 860144595
Change-Id: I701c6d607715d240766b6210a9773cd9e4258c59
2026-01-23 09:41:49 -08:00
Alessio Quaglino 54dd623650 Add vertex-based flex constraints (dim=2).
PiperOrigin-RevId: 859552050
Change-Id: I61d4b9dc40f041c5b930e5f8810a803e8bccb87a
2026-01-22 04:54:53 -08:00
Sam Haves 799f8a300e Add parsing benchmark simulating many textures.
PiperOrigin-RevId: 857883857
Change-Id: Ia428ff8aeba4fbaae67a6337d0856cd2b19af2e6
2026-01-18 11:17:45 -08:00
Alessio Quaglino e56b31e98f Reduce flexedge_J size from nflexedge x nv to the effective sparse size.
PiperOrigin-RevId: 856290141
Change-Id: Ide297d1b6f0e3aa07e3e20bf9ab44b6501097695
2026-01-14 11:18:41 -08:00
Google DeepMind cbc1136502 Roll back VFS refactor due internal breakages
PiperOrigin-RevId: 856273160
Change-Id: I4097e05ed4e48ebee05b4347d0f227d4f39c1b09
2026-01-14 10:38:29 -08:00
Yuval Tassa f3ad0eff2b Fix body category check for mocap body descendants in visualization.
PiperOrigin-RevId: 856179240
Change-Id: I29f4758fee0ff3b16d0b9f452c28e640b5558993
2026-01-14 06:06:55 -08:00
Haroon Qureshi d387578783 Refactor mjVFS and resource management.
Resource operations (e.g. mju_openResource, mju_readResource, and
mju_closeResource, etc.) are now all handled by a VFS instance. It
is now up to the VFS to determine which provider to use in order to
handle those operations.

This allows us to dynamically add/remove (aka "mount") providers to
a VFS to handle special requests. mj_addFileVFS and mj_addBufferVFS
have been reimplemented as two such use-cases. Moreover, we expose
the mounting behaviour with two new functions: mj_mountVFS and
mj_unmountVFS.

PiperOrigin-RevId: 856166919
Change-Id: Id723d612ffc0bff020705cf19ef95fbf24676840
2026-01-14 05:19:57 -08:00
Yuval Tassa 218226fc95 Breaking change: Add surface normal output to MuJoCo raycast functions.
PiperOrigin-RevId: 855781592
Change-Id: Id96b1ca7eaf722e260cc69d7706c28dc51f52d92
2026-01-13 10:22:21 -08:00
Yuval Tassa 1cda1e7a8c Prevent degenerate body inverse weights in constraints.
Fixes #2472

PiperOrigin-RevId: 855223971
Change-Id: I646207f82353b7099aab9e220888fe11a4cd3d6d
2026-01-12 07:43:14 -08:00
Haroon Qureshi cb9a9c159c Remove getdir from mjpResourceProvider.
All known implementations were effectively the same as the default fallback. It was just adding unneeded complexity. Removing this now will help with upcoming improvements to resource providers.

PiperOrigin-RevId: 855163273
Change-Id: I529fc18d0d03a8dc676c909ec9e4b1da1454d414
2026-01-12 04:07:42 -08:00
Sam Haves a5dc57c0c3 Move OpenUSD parsing to usd_decoder
Add usd_decoder to mujoco/plugin.
  - Previously was src/experimental/usd/usd_to_mjspec.cc, now that same spec is returned by the plugin.

PiperOrigin-RevId: 854350962
Change-Id: Ia980190a557c50ce8197980922a2594b613859b4
2026-01-09 14:48:29 -08:00
Haroon Qureshi 45e164bf8f Refactor 'ParseXML' and 'ParseSpecFromString' to use a shared helper function.
This allows us to remove the special "LoadModelFromString" resource provider.

PiperOrigin-RevId: 854207845
Change-Id: I6d00f2ab99b4351866e1d39dbeed96f29aaaf915
2026-01-09 08:40:40 -08:00
Haroon Qureshi 398e3dcf15 Use mj_parseXMLString instead of a test-specific LoadFromModelString.
This removes the need for a custom mjResourceProvider, but does require
reimplementing part of mj_loadXML in the fixture.

PiperOrigin-RevId: 854170820
Change-Id: Ib455cc5cdb5138213eb7e996dc32ac156f22a859
2026-01-09 06:34:27 -08:00
Yuval Tassa 608115ab95 Add output attribute to camera elements.
This attribute allows specifying the intended output types (e.g., RGB, depth, normal) for each camera in the XML. The output types are stored as bit flags in `mjModel`.

PiperOrigin-RevId: 853316261
Change-Id: I1ad2e94102593cf402756f8f4c80509371ca86d2
2026-01-07 10:22:27 -08:00
Yuval Tassa 70bc7be4bc Add additional data fields that can be reported by rangefinder sensors.
PiperOrigin-RevId: 848316991
Change-Id: Idbf7ba81b4da711a22c23302c8782ab2b0b98d82
2025-12-23 15:33:00 -08:00
Yuval Tassa 9d646e6548 Extend rangefinder sensor to support cameras.
PiperOrigin-RevId: 848255889
Change-Id: I6e1a9ed13d29d2242558625a47e24e47ad6e87db
2025-12-23 12:04:49 -08:00
Yuval Tassa b28b5db680 Add mj_multiRayNormal for multi-ray casting with normal computation (not exposed in public header)
PiperOrigin-RevId: 847821078
Change-Id: I616441d3460406a92a10731d1a086af6163e96ad
2025-12-22 11:02:58 -08:00
Yuval Tassa 223ba99ec2 Add mju_rayFlexNormal (not exposed in public header)
PiperOrigin-RevId: 847746174
Change-Id: Ia8f597d296bf6a3eed9bd48b1c39b2ff2b5fcf90
2025-12-22 06:49:22 -08:00
Yuval Tassa c7f5766345 Add frustum visualization for orthographic cameras.
PiperOrigin-RevId: 847698917
Change-Id: I13633e8ba2d4718b127a5838c404ab74c6180e3d
2025-12-22 03:43:54 -08:00
Yuval Tassa 158525269b Refactor camera intrinsic parameter handling.
Move logic from parser to compiler.

PiperOrigin-RevId: 847689906
Change-Id: I844746081973205e1b33a3845add842e8b8c3c07
2025-12-22 03:08:18 -08:00
Yuval Tassa b8a4ac5d48 Refactor camera orthographic attribute to projection enum.
PiperOrigin-RevId: 847069028
Change-Id: I7f686fe654e9b56519cab8bd2f37c9cc40091d3f
2025-12-20 03:28:29 -08:00
Yuval Tassa 849a650143 Refactor mju_cholUpdateSparse to use a dense accumulator, 1.5-2x function speedup.
PiperOrigin-RevId: 846754379
Change-Id: Ie599658db2907a26095072d97d07b99a693050dc
2025-12-19 08:57:45 -08:00
Sam Haves 9e150fe82c Add separate build step for OpenUSD to third_party_deps.
This will fetch and call the build_usd.py build helper for OpenUSD and build within the MuJoCo _deps folder. Simplifying the build process for MuJoCo with USD. Users can still provide their own USD build, but must now do so via pxr_DIR.

PiperOrigin-RevId: 846735578
Change-Id: I0da7eb2da6465e2d518084340e762bf370adb6d5
2025-12-19 08:00:15 -08:00
Yuval Tassa 45b0153067 Refactor sparse Cholesky factorization into symbolic and numeric phases.
The new symbolic function is a generalization of the function it replaces. In this CL it takes two unused temp arrays. The actual change in behavior happens in the followup.

New benchmark test output below ("L" is 2 humanoids and 100 free objects, "XL" is 100 humanoids). Note that `symbolic` is only ever called once per Newton iteration, while `numeric` is sometimes called multiple times (when the rank-1 update fails), hence timing them separately is valuable.

```
Benchmark               Time(ns)        CPU(ns)     Iterations
--------------------------------------------------------------
BM_old_L_mean              84382          84703          19547  11.807k items/s
BM_symbolic_L_mean         16345          16381          88414  61.055k items/s
BM_numeric_L_mean          10986          10994         120000  90.999k items/s
BM_old_XL_mean           1241208        1244212           1200  803.924 items/s
BM_symbolic_XL_mean       130917         131042          12720  7.631k items/s
BM_numeric_XL_mean         77004          76767          21116  13.029k items/s
```

PiperOrigin-RevId: 846704054
Change-Id: Ib0c365724d63bf2b81606ca5353756a6496c3a26
2025-12-19 06:11:55 -08:00
Sam Haves 05e1c452c7 Add VFS parameter to mjpDecoder decoding function.
PiperOrigin-RevId: 846242734
Change-Id: I317e11e6fcd965f66416abcf690a3a65d043e9ee
2025-12-18 06:38:40 -08:00
Yuval Tassa 47e35e632f Add a test for equivalence of different solvers.
PiperOrigin-RevId: 845777469
Change-Id: I76a162b71bea349cca3472001360181654a5d571
2025-12-17 08:21:52 -08:00
Yuval Tassa 08b4b4144d Add tests for mju_cholUpdate and mju_cholUpdateSparse.
PiperOrigin-RevId: 845229292
Change-Id: Ide1406f85e49fe5a5b339bedff7ff6dd8099e5e8
2025-12-16 05:59:40 -08:00
Sam Haves eef71832db Remove usage of usdImaging tokens to avoid needing to build imaging.
PiperOrigin-RevId: 844768270
Change-Id: Iba0a03646e56d9be5accf754f97ec37db8055425
2025-12-15 07:44:18 -08:00
Haroon Qureshi 52ca07e210 Decoder decode function should take a non-const pointer to mjResource.
This is because mjcReadResource requires a non-const pointer.

PiperOrigin-RevId: 844737328
Change-Id: I88d217aa85a66023f6b222437403c136448cabfe
2025-12-15 06:04:05 -08:00
Yuval Tassa 1ff74ba810 Change the type of state signature arguments from unsigned int to int
PiperOrigin-RevId: 843162492
Change-Id: I51d3324f088e8055898e115bdd32267c5950a412
2025-12-11 04:34:36 -08:00
Yuval Tassa f06aa45ea6 Consolidate ray normal functions.
PiperOrigin-RevId: 842300829
Change-Id: Ic5e921084710cb044a4f49ea9b566d277838aaa1
2025-12-09 10:36:10 -08:00