Commit Graph

2309 Commits

Author SHA1 Message Date
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
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
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
Kyle Bayes b612d352d4 Fix GitHub Actions for threading.
PiperOrigin-RevId: 922926969
Change-Id: I968e6b130b6125dbc0ec65ba913d04292270b563
2026-05-28 12:57:16 -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
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
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
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
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 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
David Hozic 57e27f94f3 Fix compilation error 2026-05-26 14:50:11 +02:00
Yuval Tassa 393c1e4217 Migrate mjtByte to mjtBool for boolean-valued fields.
PiperOrigin-RevId: 921408093
Change-Id: Icb00457836359779f0f72fc02d6a7c0dc9f6bd23
2026-05-26 05:35:49 -07:00
Baruch Tabanpour 466d068089 MuJoCo Studio: Support Ctrl+Option+Left Click Drag for perturbation
Support Ctrl+Option+Left Click Drag (maps to Ctrl+Alt+Left Click Drag in the application) to apply point force perturbations (translation) on the robot in the WebGL live viewer. This matches the Mac experience in the native MuJoCo simulate app and provides a fallback for Mac users where Right Click is difficult to trigger.

PiperOrigin-RevId: 919767954
Change-Id: I4a1d1c05784a8257d13f64f738af5b4841a615b3
2026-05-22 11:14:46 -07:00
Saran Tunyasuvunakool 5c21c8d28b Minor restyling of the loading screen.
PiperOrigin-RevId: 919744412
Change-Id: I3e4aa0b59d100ac85e8f915d7d733b2b3ea1ecea
2026-05-22 10:26:04 -07:00
Yuval Tassa ab0e0091d5 Standardize "DO NOT EDIT" comments in generated files.
PiperOrigin-RevId: 919718422
Change-Id: I2cba07d75d37d45f3f30b23d049c944b080248ad
2026-05-22 09:34:45 -07:00
Haroon Qureshi 8ae51e104d Move DrawTextAt from imgui_bridge to imgui_widgets.
PiperOrigin-RevId: 919508805
Change-Id: Ie311b88164d8c2ff7a8452ec2f1b8be7e7d9770e
2026-05-22 00:52:54 -07:00
Haroon Qureshi 3499adacae Store skin and flex meshes separately.
PiperOrigin-RevId: 919490079
Change-Id: I45473ee59e22465732fb4b470a94c2944fed9c37
2026-05-22 00:09:49 -07:00
Haroon Qureshi 88b8b58429 Add support for transparent PBR materials.
PiperOrigin-RevId: 919477028
Change-Id: I75cc311fc73dd5fe26b72ba8d49fd421fda455e3
2026-05-21 23:35:53 -07:00
Baruch Tabanpour 5b73846a1e Upgrade MuJoCo Live loading screen
PiperOrigin-RevId: 919112273
Change-Id: I0ffdf908e32d4197e007ebcc2d9f5136b59cf6b3
2026-05-21 10:03:40 -07:00
Matija Kecman 585be6cee5 Fix wireframe rendering
PiperOrigin-RevId: 919100432
Change-Id: I2931d793ab9639bdaaad11f6d77a77aa14e43b8a
2026-05-21 09:41:59 -07:00
Yuval Tassa 2810edd27a Rename mjtnum.h to mjtype.h, move enum types to mjtype.h
PiperOrigin-RevId: 919020039
Change-Id: I441295c0baa0b7456f78239fbd5478d32ffc07c1
2026-05-21 06:43:29 -07:00
Kyle Bayes ad96acfb16 Add internal mj_narrowphase for batch processing of potential geom pair collisions.
PiperOrigin-RevId: 918988042
Change-Id: I871dcdf42f8105e2c8a57e275a3775ea46c69e65
2026-05-21 05:16:35 -07:00
Saran Tunyasuvunakool 7c47a89cd0 Add asset file download indicator to the loading screen.
This provides visual feedback to the user while loading large models.

PiperOrigin-RevId: 918708877
Change-Id: I77ea475cce6d9718e6cf8b33cb72b3f524a6ee63
2026-05-20 16:26:40 -07:00
Kyle Bayes 7174d33f08 Introduce mjPreContact, a minimal struct passed into the collision functions.
PiperOrigin-RevId: 918533795
Change-Id: I2b5af05c1479b25d5c2cfdc690321a26fce6ede6
2026-05-20 10:47:46 -07:00
Haroon Qureshi 53b3137a12 Separate Light management into a separate class.
PiperOrigin-RevId: 918508291
Change-Id: I9cadc1b612006a0450f8a2fd9088d56cc2e610a3
2026-05-20 10:01:15 -07:00
Sam Haves fa8ac7a516 Implement mjz encoder.
PiperOrigin-RevId: 918493808
Change-Id: I150d182ff27801d829537a8001a0b3a04c1a0499
2026-05-20 09:32:51 -07:00
Haroon Qureshi 57d2c49316 Track size/scale separately for renderables.
PiperOrigin-RevId: 918476985
Change-Id: I414b1abe2f9b3a3a7549ab5195971127d5598c36
2026-05-20 08:54:28 -07:00
Matija Kecman dd37ae16fc Fix studio python samples when running on CRD
* Changed window.cc to not pass `SDL_WINDOW_OPENGL` for headless opengl graphics modes since this requests a [GLX visual](https://tronche.com/gui/x/xlib/window/visual-types.html#Visual) but CRD's virtual X11 display has no GLX visuals causing window creation to fail with "Couldn't find matching GLX visual".

* Changed `TryLoadEgl` so it fails if `eglBindAPI(EGL_OPENGL_API)` does not return true, causing `CreateFilamentPlatform` to fallback to OSMesa on CRD.

PiperOrigin-RevId: 918029935
Change-Id: Id88338811949b1402578de19bc4d31f4ee1783c1
2026-05-19 14:28:09 -07:00
Yuval Tassa bdf00966f9 Add compiler timing diagnostics to mjsCompiler, printed by compile.cc
For example, `compile mujoco_menagerie/robotis_op3/scene.xml` now outputs

```
Compile 1 (cold cache):
  total:      317.2 ms
  assets:     284.8 ms (wall clock)
    load:     616.1 ms
    hull:      26.4 ms
    poly:     137.8 ms
    inert:    177.8 ms
    bvh:      568.2 ms
    octr:       1.6 ms
    tex:       25.3 ms
  other:       32.4 ms

Compile 2 (warm cache):
  total:       79.9 ms
  assets:      54.5 ms (wall clock)
    load:     888.5 ms
    hull:       0.0 ms
    poly:       0.0 ms
    inert:      0.0 ms
    bvh:        0.0 ms
    octr:       0.0 ms
    tex:       21.4 ms
  other:       25.3 ms
```

PiperOrigin-RevId: 917850214
Change-Id: Iaec86230bec0faf2e47820e20cbff61de5b2621e
2026-05-19 08:28:47 -07:00
Yuval Tassa f712eed4ce Allow flex sleeping
PiperOrigin-RevId: 917817500
Change-Id: Ia3bd5e52e7c2eaa3f70c81352d82c130b1d357f6
2026-05-19 07:15:27 -07:00
Haroon Qureshi ddc4c54d16 Update CMakeLists.txt
PiperOrigin-RevId: 917775846
Change-Id: Iebc63a3c7a1956f6d37771319ae0f2817f5edcc5
2026-05-19 05:24:13 -07:00
Haroon Qureshi a205b7afdb Move ImguiBridge from filament compat library to platform ux.
PiperOrigin-RevId: 917751897
Change-Id: I6578c35d49cdd9627fa8b3fa7956d56da7e2c678
2026-05-19 04:17:43 -07:00
Haroon Qureshi 303c1bd0aa Make MjrFilamentRenderer an internal detail of compat library.
Renames MjrFilamentRenderer to CompatContext and makes it an
internal detail of the compatibility layer.  This allows us to
remove all legacy functions from the mjrf namespace, making
them available only in the compatibility layer.

Update studio to use non-legacy mjrf APIs. This requires it to
use some of the compat helper classes. These will be refactored
in the future to make them reusable components.

PiperOrigin-RevId: 917730783
Change-Id: Ic8f68e6e75059f7d394ea3266a346cbd6c1fcaed
2026-05-19 03:26:04 -07:00
Copybara-Service a1056676a0 Merge pull request #3276 from dparikh79:fix/3275-boxqp-symmetric-lower-matvec
PiperOrigin-RevId: 917279467
Change-Id: If4117b1e2147679336becb558e0f87621555dfc7
2026-05-18 09:36:01 -07:00
Yuval Tassa 71d1014e70 Add mjENBL_DIAGEXACT for exact constraint diagonal. Fixes #2472
PiperOrigin-RevId: 916932908
Change-Id: Id23ac39b5cd996afc52990719a4e07c0cc7de600
2026-05-17 16:47:54 -07:00
Alessio Quaglino 66d764a116 Scale flex warp constraint by thickness^3.
Warp is not a true stretch mode but a parasitic shear mode so it should be scaled like bending (~thickness^3) rather than stretching (~thickness). The thickness parameter can therefore be used to set the stretch to warp stiffness ratio of the strain constraints.

PiperOrigin-RevId: 916900311
Change-Id: I52e54210fbb2a6d309abc1f084934830adce3423
2026-05-17 14:33:12 -07:00
Alessio Quaglino 8a20ce24d3 Refactor shell stiffness computation to use pure membrane modes plus an explicit warp mode.
PiperOrigin-RevId: 916879634
Change-Id: Ib706909521b4f503b13904a34b0e29aefd4fa433
2026-05-17 13:00:08 -07:00
Yuval Tassa 04042d8bf3 Move square root of Delassus matrix from stack to arena
PiperOrigin-RevId: 916852244
Change-Id: I4379553f808d0b238a1421606f806ea2d0a33d7c
2026-05-17 11:21:55 -07:00