Commit Graph

3962 Commits

Author SHA1 Message Date
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
Haroon Qureshi 071cb83fe7 Strip the prefix correctly.
PiperOrigin-RevId: 855297807
Change-Id: Ic182f64c451077386fdba8bfe34e8da6364b9f60
2026-01-12 10:59:20 -08:00
Sam Haves 7e45bbb51c Add urdf file extension case to mj_parse.
fixes #3004

PiperOrigin-RevId: 855249634
Change-Id: I6c21d0ada4fe482059f64e96d413796f5c1c66ce
2026-01-12 08:59:00 -08:00
Taylor Howell 013268c283 Documentation: Pair-wise colliders.
PiperOrigin-RevId: 855245724
Change-Id: Iffad5dc426350040f730dc1a7b9766f079ef949e
2026-01-12 08:47:45 -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
Yuval Tassa f0e1d8ce2c Fix typo in XML reference: damping -> damper.
PiperOrigin-RevId: 855198029
Change-Id: I2cc2b833e8a7fad8c63d1eb7b3febdd54d0c9056
2026-01-12 06:13:20 -08:00
Google DeepMind a6a9a85007 Implement get_data_into_cpp and make_data_cpp.
PiperOrigin-RevId: 855192298
Change-Id: I9f9fd07094c40b9df1b645c2c893bb2605941e32
2026-01-12 05:54:29 -08:00
Yuval Tassa 5979c5aa03 Fix link in changelog.
PiperOrigin-RevId: 855183695
Change-Id: I9ef63fe03f3b68707ff7eec1813403a08b0a8074
2026-01-12 05:22: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
Yuval Tassa d7e4038be8 Expose mj_copyData in Python bindings.
This allows calling `mujoco.mj_copyData(dest, model, src)` to copy data between existing `mjData` instances.

PiperOrigin-RevId: 855150139
Change-Id: If122cb7acf590846e25ee15f9770c3c087147169
2026-01-12 03:21:15 -08:00
Taylor Howell 1d482047d1 MuJoCo Warp documentation: How to fix simulation runtime warnings?
PiperOrigin-RevId: 855149274
Change-Id: Iccfb85f1ec836cb06235d21d23e913f77a816487
2026-01-12 03:17:13 -08:00
Yuval Tassa a26f09accf Standardize function docstring style in MuJoCo API.
Updates function comments to consistently use a semicolon (`;`) before describing the return value and to use the imperative form "return" instead of "returns".

Also fix error in docstring of `mjp_registerResourceProvider`

PiperOrigin-RevId: 854888532
Change-Id: I311239a2770ded5febece9958ae4e94c1e522600
2026-01-11 09:00:35 -08:00
Sam Haves 8abedf263e Add checks for nullptr content_type and extension in mjpDecoder registration.
PiperOrigin-RevId: 854365689
Change-Id: I025f5ab844dd4cf19f7d5f223430e27fd23a0924
2026-01-09 15:32:23 -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
Sam Haves 64a2345c07 Fix usethread check to enable multithreaded mesh compilation.
PiperOrigin-RevId: 854260636
Change-Id: I18d1f47a1ef7f8abcce14e0351b9523fbbac8be6
2026-01-09 11:00:17 -08:00
Haroon Qureshi 9e9314a4a4 Ensure parsing always has a valid VFS.
Explicitly free allocated memory for local resources. (Upcoming
changes to `mju_closeResource` will not work for local resources.)

PiperOrigin-RevId: 854254013
Change-Id: I5cbb8264b590327767d5500f0c2a32ebe036bc4f
2026-01-09 10:45:48 -08:00
Sam Haves e37c2268a6 Release gil when compiling spec.
When compiling with threading, we will block the main thread anyways waiting for all threads to complete.

PiperOrigin-RevId: 854230560
Change-Id: Ief689d381afaa3aacc5d712a8df0cb4b6762251c
2026-01-09 09:50:15 -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
Haroon Qureshi 2c4f710cf4 Ensure resource providers are correctly initialized.
PiperOrigin-RevId: 854095105
Change-Id: I028265d7f51e6ab178f4f3a1d801ba773093214f
2026-01-09 02:07:24 -08:00
Sam Haves ce74475c39 Delete VFS created from assets dict before throwing error.
PiperOrigin-RevId: 853838173
Change-Id: Id0dd33b69657813275d1f42db54fae222c337791
2026-01-08 12:13:55 -08:00
Taylor Howell 310ac0c5ac MuJoCo Warp documentation: When To Use MJWarp?
PiperOrigin-RevId: 853830564
Change-Id: I9208e9a2f2781efbedc7846f5c13036ef83d5770
2026-01-08 11:54:57 -08:00
Taylor Howell 166fa17a1c MuJoCo Warp documentation: inertia matrix automatic sparsity.
PiperOrigin-RevId: 853805011
Change-Id: I8c0040f3b2b08d8615f1fbf559cdc9841e33438a
2026-01-08 10:47:27 -08:00
Sam Haves 2f2f9a30ba When loading models use mj_parse instead of mj_parseXML, and allow non-xml file types.
PiperOrigin-RevId: 853730923
Change-Id: I1c107daafd558bedb99338779c8174ee3e4d07e2
2026-01-08 07:22:51 -08:00
Yuval Tassa 1f4bb39b53 Fix typo in comment.
PiperOrigin-RevId: 853703158
Change-Id: Ic123f9273b99eeede1d76d3da20b5b5e9f898dcd
2026-01-08 05:56:29 -08:00
Taylor Howell ab939683bc MuJoCo Warp documentation: Why are numerical results from MJWarp and MuJoCo different?.
PiperOrigin-RevId: 853696967
Change-Id: I0cf8539e341d2aa1cfd07ac75de18128ce9beb3b
2026-01-08 05:34:23 -08:00
Haroon Qureshi 765bd54c7c Move GlobalModel class and functionality into its own file.
We'll need some of this functionality for tests.

PiperOrigin-RevId: 853652149
Change-Id: Ib924d886b73784a0f370285e0b82b2ed833e3e77
2026-01-08 03:08:12 -08:00
Yuval Tassa 8f5eb1e4f4 Improve bounds checking in engine_util_solve.c.
Add checks to ensure `snprintf` does not write beyond the allocated log buffer size, preventing buffer overflows.

Fixes #2661, #2673

PiperOrigin-RevId: 853643867
Change-Id: Ibdc47810158466dc961767284ac297df98916dac
2026-01-08 02:44:38 -08:00