Commit Graph

4800 Commits

Author SHA1 Message Date
Tarik Kelestemur c80d8fb35d Stabilize MJX Warp types codegen 2026-06-01 10:45:22 -04:00
Tarik Kelestemur f97b9f6e3b TileSet MJX codegen fix 2026-06-01 10:22:54 -04:00
Copybara-Service e7ed648cac Merge pull request #3278 from tkelestemur:tarik/mjx-light-active-public-api
PiperOrigin-RevId: 924570592
Change-Id: I86d506e9f03d3230eaaca7061f6794ecdbfe164f
2026-06-01 02:15:20 -07:00
Alessio Quaglino 91c92279d2 Enable interior nodes for interpolated flex shell mode.
Previously shell mode required cellcount=1 along at least one axis. This CL
adds support for cellcount > 1 in all three axes by pinning interior grid nodes
to the parent body and reconstructing their positions from boundary nodes via
Transfinite Interpolation (TFI).

PiperOrigin-RevId: 924314800
Change-Id: I8c2438f4866dd4133feed65f535a1ab69f0c9188
2026-05-31 10:36:01 -07:00
Yuval Tassa 4548e81e4d Rename efc_diagApprox -> efc_diagA.
The field now stores either an approximate or exact diagonal of the constraint matrix A, so the name is made more general.

PiperOrigin-RevId: 924244954
Change-Id: I62b2f76531fb88b7b3bf96e6769940197596702b
2026-05-31 04:54:11 -07:00
Yuval Tassa cd6db9ebe2 Improve CG solver precision and stability under float32 via line search refactor
Fixes #2313

This CL combines two complementary improvements to the Conjugate Gradient (CG) solver, significantly improving numerical precision, stability, and efficiency, particularly in single precision (float32).

1. Line Search Cost Evaluation Refactor: Previously, solver improvement was calculated by subtracting absolute costs: cost(alpha) - cost(0). In highly converged states or single precision, this is susceptible to catastrophic cancellation. We refactor PrimalSearch to compute the cost delta directly, dramatically improving precision.

2. Improved Solver Termination Condition: Near the float32 precision limit, line search deltas can occasionally be slightly negative due to numerical noise. Previously, any value below m->opt.tolerance (including negative values) triggered termination, halting the solver and locking in destabilizing steps. We update the termination condition to require positive improvement (0 < improvement < m->opt.tolerance), allowing the solver to continue iterating and recover stability.

Together, these changes yield substantial improvements, see reduced tolerances herein.

PiperOrigin-RevId: 924229669
Change-Id: Ic0bbefaed090f3a8b1e79ab8d45422c3e86fb56c
2026-05-31 04:00:09 -07:00
Yuval Tassa 4358a102cd Add manual test for CG converence
Also add MJTOL_SCALE to fixture to allow tests to be run with zero tolerance. This is useful when assesing the impact of code changes (A/B comparison of failure values)

PiperOrigin-RevId: 924219083
Change-Id: Ifdd09ac850904ca8dd79179930ce738a4b37d284
2026-05-31 03:15:54 -07:00
Tarik Kelestemur 9bd8daf53b Minimize generated WARP types diff 2026-05-30 16:29:27 -04:00
Tarik Kelestemur f8a12a827f Merge origin/main into light_active PR 2026-05-30 16:24:27 -04:00
Taylor Howell 50e823e91c Import google-deepmind/mujoco_warp from GitHub.
PiperOrigin-RevId: 923922783
Change-Id: I0b407347a70a0e2024aae7ed5bab1592dc40a074
2026-05-30 07:44:29 -07:00
Taylor Howell b9c7a4b81a Import NVIDIA/warp 1.13.0 from GitHub.
PiperOrigin-RevId: 923878216
Change-Id: If9df5e0672e956eb62874fb6f4f74ba3a02977b3
2026-05-30 04:48:08 -07:00
Yuval Tassa 3a6e0ee9b3 Reduce effect of infinite planes on center and extent statistics
PiperOrigin-RevId: 923868757
Change-Id: I3630d29f05a19e0767549284abbe8a8d9386894b
2026-05-30 04:12:07 -07:00
Yuval Tassa d7e872b6f9 Add UI control for MuJoCo threadpool size.
PiperOrigin-RevId: 923860258
Change-Id: I11dc5d7904f1c3657d7e1dd2b0e3c7864c0c7ead
2026-05-30 03:41:38 -07:00
Yuval Tassa 96bf8aea81 Move island-specific sparse matrices from arena to stack.
PiperOrigin-RevId: 923850345
Change-Id: I9683d7554b15b7cd8c45a8dce7814640aa266452
2026-05-30 03:09:46 -07:00
Yuval Tassa 5d782a2bb8 Fix memory overallocation in sparse primal solvers.
PiperOrigin-RevId: 923586079
Change-Id: I8d484b840063c0a7a8a79c5bdc9074a57d2ee55f
2026-05-29 13:51:47 -07:00
Copybara-Service ffe1eadd7e Merge pull request #3294 from kevinzakka:mujoco-minimize-x-scale
PiperOrigin-RevId: 923519000
Change-Id: I4a8fa1f031428cf41d194d17ea4c41975f93f745
2026-05-29 11:34:36 -07:00
Haroon Qureshi f63b92da5e Clear draw queue instead of failing if rendering skipped.
PiperOrigin-RevId: 923420183
Change-Id: I34aac76810a7bf0e4a0394ebe27b45a8fc32f110
2026-05-29 08:09:15 -07:00
Yuval Tassa 8eaf174a88 Change "Num threads" UI element to a slider.
PiperOrigin-RevId: 923378753
Change-Id: Ie5f53faf6ad90e0e1a1148f004b1867a57e6fb5e
2026-05-29 06:30:38 -07:00
Kyle Bayes c7d340be4f Cap box<->box collisions.
PiperOrigin-RevId: 923312868
Change-Id: I801d76cf1d1d7b9ed1535d3e3c723a5e8af4162a
2026-05-29 03:52:57 -07:00
Copybara-Service 46d2405b42 Merge pull request #3288 from davidhozic:fix/strchr-const-char
PiperOrigin-RevId: 923297843
Change-Id: I13b07c6cf0f611a8b3ee797dac94b35ce8d9deb4
2026-05-29 03:16:33 -07:00
Copybara-Service 9af965f241 Merge pull request #3120 from Ashutosh0x:fix/safe-overflow-msvc
PiperOrigin-RevId: 923296001
Change-Id: I037dcc55c91d6eb68b3e63b34a0e059c796b5116
2026-05-29 03:12:40 -07:00
Yuval Tassa df6942eb39 Support float32 precision for mjtNum in Python bindings.
PiperOrigin-RevId: 922959317
Change-Id: I384b3bdeabdc4d3f66c71cae41dabfaf51387be7
2026-05-28 13:56:58 -07:00
Kyle Bayes b612d352d4 Fix GitHub Actions for threading.
PiperOrigin-RevId: 922926969
Change-Id: I968e6b130b6125dbc0ec65ba913d04292270b563
2026-05-28 12:57:16 -07:00
Google DeepMind 9436972a22 Import NVIDIA/warp 1.13.0 from GitHub.
PiperOrigin-RevId: 922893824
Change-Id: Ib91ffb03257c614c48feda096822f723323be54d
2026-05-28 11:51:39 -07:00
Kyle Bayes b935d4153c Add new mju_threadpool API function, and delete old threading API.
PiperOrigin-RevId: 922838541
Change-Id: Id9f7e0fb298ffde61fcc49a802dc78971858ce51
2026-05-28 10:11:44 -07:00
Ashutosh0x 50ec8e84de test: intercept mju_warning in overflow regression test 2026-05-28 21:46:15 +05:30
Copybara-Service a22fc2423a Merge pull request #3295 from tkelestemur:tarik/fix-mjx-codegen-python311
PiperOrigin-RevId: 922794565
Change-Id: Ibd42328d739d3882e5c418cf69fc9787572cdb4a
2026-05-28 08:44:28 -07:00
Taylor Howell cae5a608d5 Import NVIDIA/warp 1.13.0 from GitHub.
PiperOrigin-RevId: 922749092
Change-Id: Ide815e4224e64af69e7c3a58102508bc81d22770
2026-05-28 07:00:59 -07:00
Alessio Quaglino 4c381635e1 Add mjs_makeFlex to the MuJoCo C and Python APIs.
- Add mjs_makeFlex C API that wraps mjCFlexcomp::Make(), creating
  a flex with auto-generated bodies, joints, and equality constraints
  from parameters (type, dim, dof, count, cellcount, spacing, scale,
  radius, mass, inertiabox, equality, rigid, flatskin, elastic2d,
  pos, quat, origin, file, vfs).
- Add Python binding body.make_flex() in specs.cc with keyword args.
- Refactor flex_spec_provision.py to use make_flex() instead of XML
  string templating + separate spec + attach. Eliminates textwrap
  dependency.
- Merge user_flexcomp into user_model BUILD target to resolve
  circular dependency.

PiperOrigin-RevId: 922725304
Change-Id: Ice13787c45f3173407fec659f9590a6453bc65dd
2026-05-28 05:59:20 -07:00
Sam Haves b9fb817af8 Lexically normalize resource path in mjz_decoder resource provider.
PiperOrigin-RevId: 922654438
Change-Id: Ieb46230a2aba46a5e711bc5b24aec982f71e56ca
2026-05-28 02:56:45 -07:00
Copybara-Service f755d718d3 Merge pull request #3293 from kevinzakka:studio-live-parallel-prefetch
PiperOrigin-RevId: 922417778
Change-Id: Ia839747c4af0e705962308dc84e9a7c3926fc910
2026-05-27 16:47:18 -07:00
Tarik Kelestemur 106f1c5dbb fix mjx codegen and rerun 2026-05-27 17:50:31 -04:00
Tarik Kelestemur cf1b28d19a address btaba's review 2026-05-27 17:37:33 -04:00
Kevin Zakka aa4a43da17 Address reviewer feedback: default x_scale=None, drop TRF qualifier. 2026-05-27 12:55:14 -07:00
Kyle Bayes 4035c66428 Fix multiccd edge bug that occurs in certain situations.
PiperOrigin-RevId: 922251109
Change-Id: I74c08ae49d5dfd2a41b2dcd28eb9f2b5ba113216
2026-05-27 11:32:45 -07:00
Alessio Quaglino f6c85287bf Optimize mj_flex performance.
Two performance optimizations for interpolated flex objects:

1. Hoist loop-invariant stride calculations in `mju_cellLookup` out of nested loops.
   This reduces multiplications from 16 to 6 (linear) and 54 to 12 (quadratic)
   per vertex.

2. Extract and consolidate optimized 3D interpolation logic into a new
   reusable utility `mju_evalBasisArray` in `engine_util_misc.c`. This function
   uses nested loops and precomputed 1D shape functions to avoid expensive
   dynamic `phi` calls and branching, and leverages stack-buffered outputs to
   eliminate compiler pointer-aliasing barriers. We propagate this optimization
   to both kinematics (`mju_interpolate3D`) and constraint setup
   (`engine_core_constraint.c`).

Together these changes yield a ~50% overall speedup in `mj_fwdKinematics` for interpolated flexes with ~10k vertices in the collision meshes and ~10 nodes in the deformation grid.

PiperOrigin-RevId: 922198093
Change-Id: I9c804e65cd532e2f9ac6e9a71d01c30cd64186fa
2026-05-27 10:05:30 -07:00
Google DeepMind af4be63cd8 Add xmacros for MjSpec.
PiperOrigin-RevId: 922169069
Change-Id: I01426596e49196996dfa324d5ab3849a90de2e3a
2026-05-27 09:12:35 -07:00
Haroon Qureshi 36ea0c466f Support multiscene, multiview rendering.
Update Renderable so that it can switch its own draw states (material
instance, shadow casting, reflection textures, etc.) per render request.
This allows us to use the same Renderable with different effects from
different views within the same frame.

PiperOrigin-RevId: 922102817
Change-Id: I1cf02fddb7a00345a741db1bee88e716517765f4
2026-05-27 06:54:58 -07:00
Matija Kecman c0b8aa9dec Make studio python more like studio C++
- C++ Platform UX: Added a "Copy Camera" button to copy XML camera definitions to clipboard.
  - C++ Platform UX: Extracted `SetSpeedIndex` and `GetExpectedLabelWidth` into reusable platform helpers.
  - C++ Platform UX: Fixed combo box widths and removed auto-hide tab bar flag from dockspace.
  - C++ Studio App: Deduplicated label width and speed index logic by adopting platform helpers.
  - C++ Studio App: Updated the toolbar layout to use a 2-column table.
  - Python Bindings: Added pybind definitions for `set_camera_index`, `set_speed_index`, and `camera_to_string`.
  - Python Studio App: Aligned toolbar UI with C++ using a 2-column table and fixed immediate theme switching.
  - Python Studio App: Added a Help menu displaying the MuJoCo version and Stats toggle.
  - Python Events: Added `-`/`=` shortcuts for simulation speed and `Esc`/`[`/`]` shortcuts for camera selection.

PiperOrigin-RevId: 922097319
Change-Id: Iec74afe37bf5c7a1ebf1cab4141e47fff5fe9274
2026-05-27 06:42:59 -07:00
Ashutosh0x 0607dc450c security: fix integer overflow in safeAddToBufferSize on MSVC
The MSVC fallback path in safeAddToBufferSize() performed unchecked
arithmetic (type_size*nr*nc) on attacker-controlled values read from
.mjb binary model files. This could cause integer overflow, leading
to an undersized heap allocation followed by a heap buffer overflow
when data is copied into the buffer.

The fix adds manual overflow detection using SIZE_MAX/INTPTR_MAX
comparisons, matching the behavior of the existing __builtin_*_overflow
path used on GCC/Clang.

Also adds a regression test that crafts a binary model buffer with
overflow-inducing size fields and asserts safe rejection.
2026-05-27 17:01:01 +05:30
Michael Moss 79aeceeaa3 Update MuJoCo version to 3.10.0 following the 3.9.0 release
PiperOrigin-RevId: 922027849
Change-Id: I52dd7fb5eeb962c2670ab5dbbe7ce192ac9332c5
2026-05-27 03:50:22 -07:00
Michael Moss 237c17e485 Update changelog for the 3.9.0 release.
PiperOrigin-RevId: 922002472
Change-Id: I92489261c59cff10b29def784698868e67aa43da
2026-05-27 02:47:19 -07:00
Alessio Quaglino f6cd0234fd Change tactile sensor normal component to report penetration depth.
The normal component of the tactile sensor now reports the maximum penetration depth at each taxel, instead of a derived normal force. The depth is negated so that positive values indicate penetration.

PiperOrigin-RevId: 921980899
Change-Id: Ide4103c0aff465e25a81cfdda650f6a0e2da9e0b
2026-05-27 02:00:34 -07:00
Kevin Zakka c12dc23852 Add x_scale to mujoco.minimize.least_squares.
Per-parameter scaling via change of variables z = x / D. Supports
'jac' (adaptive D_i = 1/||J(:,i)|| per iteration, matches scipy's TRF),
explicit array, or a positive scalar. Default 1.0 is a no-op.
2026-05-26 17:06:09 -07:00
Kevin Zakka 249e9c08b8 MuJoCo Live: pre-fetch model assets in parallel before compilation.
The prefetcher asks mju_getXMLDependencies for the transitive asset
list, fetches every URL with Promise.all, and primes the bytes into the
WASM-side FetchCache. When the compiler runs, every resource it opens
is already in memory. Cold-load on a typical Menagerie model drops from
~9 s to ~2 s.
2026-05-26 16:01:48 -07:00
Kevin Zakka 6f9725a1da Make mju_getXMLDependencies read XMLs through the resource provider.
The function called tinyxml2's LoadFile directly, which only works on
the OS file system. Reading through mju_openResource lets it work
against any registered backend (VFS, HTTP, github:, ...).
2026-05-26 16:01:48 -07:00
Michael Moss 583aa5ad4f Update dependencies ahead of the 3.9.0 release.
PiperOrigin-RevId: 921512490
Change-Id: Iac2e4e52dde5ca7aeda62f033fcc03aadcaeb904
2026-05-26 09:30:49 -07:00
Taylor Howell d63a89f896 MJX documentation: update feature parity section
PiperOrigin-RevId: 921452813
Change-Id: Ic33c20688b9875e0d2be8563377a1e009da51fa6
2026-05-26 07:23:24 -07:00
Copybara-Service e03bf07134 Merge pull request #3230 from google-deepmind:dependabot/pip/mjx/pytest-9.0.3
PiperOrigin-RevId: 921431196
Change-Id: Ie23587578d88a1d3d909e50b68108a2ee7934d09
2026-05-26 06:32:39 -07:00
David Hozic 998f9960f9 Revert indexer_xmacro.h change 2026-05-26 14:51:48 +02:00