Commit Graph

3989 Commits

Author SHA1 Message Date
Haroon Qureshi bdb553ff8a Add a ModelPlugin that can be used to load and update models.
PiperOrigin-RevId: 861077626
Change-Id: I3ef4989cfbfff3632c5915c00ebda1e7a48716e8
2026-01-26 01:24:43 -08:00
Alessio Quaglino e933081ff1 Optimize flexvert Jacobian computation.
The dense Jacobian arrays `J0_dense` and `J1_dense` are now zeroed only once before the vertex loop. Inside the loop, only the entries that were actually used are zeroed out after being added to the sparse Jacobian, allowing for efficient reuse of the dense arrays across all vertices.

PiperOrigin-RevId: 860799056
Change-Id: Ia61daae5eeb2f4dbc0c5d8c0064622a881e92b7a
2026-01-25 05:22:44 -08:00
Yuval Tassa e48da1e38c Fix __muloti4 linker error on Clang 13
Add `-rtlib=compiler-rt` linker flags for the Clang 13 CI build.

Clang 13 generates calls to __muloti4 (a 128-bit overflow-checked multiplication intrinsic) for signed 64-bit multiplication with overflow detection. This symbol is provided by LLVM's compiler-rt but is missing from GNU's libgcc, which is the default runtime library on Ubuntu.

Related issues:

- https://github.com/llvm/llvm-project/issues/14841
- https://github.com/abseil/abseil-cpp/issues/841
- https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=244169

PiperOrigin-RevId: 860529686
Change-Id: If58dc0328aa1dd87aef8ea02da555f57ad96b02c
2026-01-24 08:15:56 -08:00
Alessio Quaglino e9c61694e1 Align flex_vert0 to the XY plane during model initialization if dim=2.
PiperOrigin-RevId: 860435368
Change-Id: Ida616e1e69c224f7c0dbad2a10dd59e64cbadf49
2026-01-24 00:50:01 -08:00
Alessio Quaglino 769109630f Move flexvert_J and flexedge_J sparsity pattern to mjModel.
PiperOrigin-RevId: 860392796
Change-Id: Ie1264f2df5bf04b5794a3c7d8ad1a92524a6a567
2026-01-23 22:00:14 -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 a5de40b400 Replace mjtSize with size_t for size calculations in engine.
Use unsigned size_t instead of signed mjtSize for size multiplications to avoid Clang's overflow-checking intrinsic. This is semantically correct as size calculations are inherently unsigned.

PiperOrigin-RevId: 860213177
Change-Id: I837aa6556335478969d4977492d0f231419f020a
2026-01-23 12:35:13 -08:00
Yuval Tassa 68537e1e32 Replace mjtSize with size_t for size calculations.
Use unsigned size_t instead of signed mjtSize for size multiplications to avoid Clang's overflow-checking intrinsic. This is semantically correct as size calculations are inherently unsigned.

PiperOrigin-RevId: 860172221
Change-Id: I3b6cb720db8771b8f266f1927e2980ac7514538b
2026-01-23 10:51:43 -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
Taylor Howell 4a64017a5f Add documentation for MJX API
PiperOrigin-RevId: 860108133
Change-Id: I85469efcfe49d320ef8b89c9d174f33499a22b31
2026-01-23 07:53:17 -08:00
Google DeepMind c55c9a7bf1 Replace printf with mju_error in WASM bindings.
PiperOrigin-RevId: 860099912
Change-Id: Ia6a24da9301099aa976bb7a38beb9da15074a43d
2026-01-23 07:26:13 -08:00
Sam Haves 2582a83ac3 Add equalityJointAPI to mjcPhysics.
PiperOrigin-RevId: 860081702
Change-Id: Ifd961dcb2a8e0f5d885e9e9dadc0153b03cb5f4d
2026-01-23 06:28:29 -08:00
Google DeepMind e1992e62d7 Add mj_loadBinary binding to WASM.
This change adds an Emscripten binding for loading binary MuJoCo models (`.mjb`) from the virtual filesystem. The new binding, `mj_loadBinary`, takes a filename and an `MjVFS` object, enabling the loading of models that reference assets within the VFS.

PiperOrigin-RevId: 859740455
Change-Id: I9f9d8bbba0b57422e2356867e4282a1b04566475
2026-01-22 13:08:00 -08:00
Google DeepMind 61f13cd8f1 Add custom Emscripten binding for mj_saveModel.
Also adds support to unpack nullable string args

PiperOrigin-RevId: 859702186
Change-Id: Ia9e10f447ecf17b1dd74dd64d988790107a438a6
2026-01-22 11:36:13 -08:00
Taylor Howell 5ae6b5fe31 Fix MjSpec.add_texture gridlayout argument to accept strings and character lists
PiperOrigin-RevId: 859599919
Change-Id: If785f36010a7437b354ec0ce7db30c2b7ec69fe6
2026-01-22 07:28:16 -08:00
Haroon Qureshi bab468703c Display error message when requested file does not exist.
PiperOrigin-RevId: 859583121
Change-Id: Id9969e486499a70769e325161c3cd2c204006d9a
2026-01-22 06:34:35 -08:00
Matija Kecman 98593259e7 Internal change
PiperOrigin-RevId: 859578296
Change-Id: If4dd4ca68ab9750693e5f6ff20ea0c78d6b93464
2026-01-22 06:20:47 -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
Haroon Qureshi 2cc2e579f1 Refactor model loading APIs.
There are three ways to load a model: from a file, from a buffer, or an
"empty" model. Instead of overloading a single function to do all three,
provide three separate functions.

Also disable model loading functions that will not work for emscripten.

PiperOrigin-RevId: 859051341
Change-Id: I71557d31d0e7c9c6882895c36116d300f19e255d
2026-01-21 05:25:08 -08:00
Haroon Qureshi e2180ff744 First-pass of a plugin system for GUI elements.
Refactor filament's debug drawing to be one such plugin.

PiperOrigin-RevId: 859002002
Change-Id: Ibe9000dec19fce648eef6d57170ce435b9a8c6ff
2026-01-21 02:47:09 -08:00
Haroon Qureshi bf05bb1885 Make quit button work.
PiperOrigin-RevId: 858624789
Change-Id: Ibdd572b60273424f3b7e9bb6a9d117d2a0538227
2026-01-20 09:28:48 -08:00
Haroon Qureshi a0accc493a Fix camera select logic.
PiperOrigin-RevId: 858599199
Change-Id: I25f1a74ac145c73bb225d6df8e86aa82d88ebb4b
2026-01-20 08:18:29 -08:00
Taylor Howell 23c56ec4bb mjSpec python bindings for add functions: accept size with 1, 2, or 3 parameters
PiperOrigin-RevId: 858494291
Change-Id: I8a02dcac1d2419fbc728607907425b401cf66da4
2026-01-20 02:39:04 -08:00
Haroon Qureshi de47cf0e6f Don't mipmap sRGB textures.
PiperOrigin-RevId: 858148054
Change-Id: Ic115b7431901549e1c636eb20414641c37cf3e8a
2026-01-19 05:26:27 -08:00
Matija Kecman 654b393060 Add a boxing utility which can surround a bunch of UI and render it in a box.
The ImGui table API cell padding variables can be used to adjust the positioning of the UI in the box.

PiperOrigin-RevId: 858137824
Change-Id: I1ce1519c0abd67bc5fafc30f9a18dfcf18c2a313
2026-01-19 04:48:50 -08:00
Taylor Howell d173ee5bee MuJoCo Warp documentation: option-ccd-iterations -> option-ccd_iterations
PiperOrigin-RevId: 858100397
Change-Id: I358875ba56e6769fda75dba72377286c40771716
2026-01-19 02:42:04 -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
Taylor Howell bb4df33adf Import google-deepmind/mujoco_warp from GitHub.
PiperOrigin-RevId: 857298931
Change-Id: Icbaddaea8140198c3673124d5994a01d3c92ed69
2026-01-16 14:11:39 -08:00
Taylor Howell 9ba545b8b0 MuJoCo Warp documentation: Memory.
PiperOrigin-RevId: 857148640
Change-Id: I7f21bebb2186a5dd4287a8d2ee9b430f823b9051
2026-01-16 07:13:38 -08:00
Haroon Qureshi 77d1ac10fe Fix scaling issues on HDPI monitors.
PiperOrigin-RevId: 857024487
Change-Id: I7d3db9ff754374053bcd33ba93c7466253afb58c
2026-01-16 01:17:38 -08:00
Sam Haves c08e1d9e6e Add MjcEqualityAPI as a base class for MuJoCo constraints and MjcEqualityWeldAPI for representing weld constraints.
This change introduces two new USD API schema:
* MjcEqualityAPI - base API for representing MuJoCo equality constraints in USD, this will typically be applied to joints such as UsdPhysicsFixedJoint.
* MjcEqualityWeldAPI - extends MjcEqualityAPI for MuJoCo's weld equality constraints with an attribute for torqueScale.

The usd_decoder is updated to parse UsdPhysicsFixedJoints and convert the new schema attributes into the appropriate mjsEquality data fields.

PiperOrigin-RevId: 856723634
Change-Id: I0982fd3168b643f8e91d87bb5ae5933e526b63a1
2026-01-15 10:44:27 -08:00
Taylor Howell d86acd7e12 MuJoCo Warp documentation: Warmstart.
PiperOrigin-RevId: 856608941
Change-Id: Iae1bd0a3916d98affff4d5dbb442f9d951622e52
2026-01-15 04:50:27 -08:00
Haroon Qureshi c92746641d Implement picture-in-picture mode.
Adds a new window that allows the user to display one or more renders from
the different cameras in the scene.

PiperOrigin-RevId: 856607089
Change-Id: I7268ffd3ef62b9b4d62ce8d004fdbbec92b42af4
2026-01-15 04:42:27 -08:00
Sam Haves d816b38f4c mjcPhysics MjcTendon path now has an indices attribute to allow repeated sites in tendon path.
Since relationships in USD can only contain a single instance of a path, it was previously impossible to have a tendon path that visits the same wrap target more than once. This is a fairly common occurence when dealing with tendons that have pulleys.

With this change, if mjc:path:indices is not defined then the behaviour is as it was and the mjc:path is considered to be ordered. If it is authored then the parser will use the indices into mjc:path as the order. This mirrors other similar concepts in USD such as face vertex indices.

PiperOrigin-RevId: 856339887
Change-Id: I6b9503973de377acdb0689be168c16e4aa19b70b
2026-01-14 13:24:28 -08:00
Haroon Qureshi 42c565d860 Use a dedicated swap chain for offscreen rendering.
PiperOrigin-RevId: 856320260
Change-Id: I3076827baf075282651e4308db74b163a5709935
2026-01-14 12:31:54 -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
Google DeepMind c996f288e1 Add code generation for mjModel named accessors.
Most of it is done leveraging existing X Macros (indexers.h, indexer_xmacro.h) used for python bindings already.

PiperOrigin-RevId: 856205245
Change-Id: Ic72443999065040af3042bbf3f9f68c5b70d309d
2026-01-14 07:31:29 -08:00
Yuval Tassa cc4c2bc398 Improve wording in changelog.
PiperOrigin-RevId: 856204666
Change-Id: I6ccf2ea727210e4695fff8d56ff7de10b9ebd73c
2026-01-14 07:29:10 -08:00
Haroon Qureshi 5a7abfe8a0 Set cleared memory back to nullptr.
PiperOrigin-RevId: 856188793
Change-Id: Iab33171b07f0d2a48d19986e145b832d1037d596
2026-01-14 06:38:45 -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 e50e2e9691 Correct dimensions for constraint-related quantities in documentation.
PiperOrigin-RevId: 856159539
Change-Id: I83f0414a78239cae9c91bb51b16f5e2549891517
2026-01-14 04:54:03 -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
Google DeepMind 37762e3f70 Add support for vfs assets in mj_compile function to MuJoCo WASM.
Regarding mj_compile VFS argument:
I was encountering a memory error when using `std::optional<MjVFS>` with `mj_compile` (because vfs should be an optional argument of the function). This is likely because `MjVFS` doesn't have copy/move constructors, which are required for types used with `std::optional`, causing issues with memory management when std::optional copies the MjVFS object.
To solve this and to make vfs an optional argument to `mj_compile`, I replaced `mj_compile_wrapper` with two overloaded functions. This avoids using `std::optional<MjVFS>` and resolves the memory issue, while still allowing mj_compile to be called with or without the vfs argument from JavaScript.

But what if we instead add those copy/move constructors so it works with `std::optional`?:
While making `MjVFS` copyable or movable would theoretically allow it to work with std::optional, it's not a feasible approach in this case.
The MjVFS struct manages file data in memory, allocating buffers when files are added and freeing them when `mj_deleteVFS` is called in its destructor. A copy would require a deep copy of the entire virtual filesystem, but MuJoCo does not provide a public API function (like a  "mj_copyVFS") to do this. Implementing a deep copy manually would be complex and fragile. A shallow copy would result in multiple MjVFS objects pointing to the same memory, leading to double-free errors when their destructors run.
Given these constraints, MjVFS cannot safely be made copyable. The approach of providing two overloaded C++ functions is better.

PiperOrigin-RevId: 855740541
Change-Id: Ia08b6db8868ad245f07145db3fb0322cb9f737cb
2026-01-13 08:36:48 -08:00
Yuval Tassa 7e21f18fd3 Document compiler/usethread fix.
PiperOrigin-RevId: 855735924
Change-Id: I5b638ccf2a74194b363cf7c6436f78c1c3d9b0e1
2026-01-13 08:21:27 -08:00
Alessio Quaglino a49576e469 Move flexedge sparse Jacobian indices to mjModel.
PiperOrigin-RevId: 855718305
Change-Id: Ic136f4efa6735b934288f65c332d71ee8b0f6da5
2026-01-13 07:33:17 -08:00
Google DeepMind 09a6fb7d4d #mjspec Enforce that material textures array is always of length mjNTEXROLE.
PiperOrigin-RevId: 855684213
Change-Id: Id8a3734c75841dfb91bd2252114249f08461b7f2
2026-01-13 05:55:09 -08:00
Copybara-Service a93db89d43 Merge pull request #2945 from hartikainen:instsance-typo
PiperOrigin-RevId: 855677085
Change-Id: Ifc1efc4163f1ef475b687436064026f0924841bf
2026-01-13 05:34:00 -08:00
Baruch Tabanpour 1f83bbf69d Import NVIDIA/warp from GitHub.
PiperOrigin-RevId: 855445232
Change-Id: I34c9337378c8e0c0e6f92252b1af4cfac4524018
2026-01-12 17:08:17 -08:00