Commit Graph

3951 Commits

Author SHA1 Message Date
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
ShanningZhuang a92574837e Fix XML loading in wasm demo app. Fixes #2960
PiperOrigin-RevId: 853635752
Change-Id: I20226de32f3141d40ec56956451f91ec7299e727
2026-01-08 02:18:42 -08:00
Copybara-Service 07deca990a Merge pull request #3006 from thowell:mujoco_warp_docs_modifying_fields
PiperOrigin-RevId: 853619026
Change-Id: I5a5348e1cdbee22e40b516cf8ed649645f54bf6f
2026-01-08 01:32:50 -08:00
Copybara-Service f4beb95212 Merge pull request #2990 from google-deepmind:mjwarp_doc_batched_model_field_warning
PiperOrigin-RevId: 853420667
Change-Id: I540b36611485054851e497c8f74302ac0fbedd36
2026-01-07 14:46:36 -08:00
Taylor Howell f703a0e023 Import google-deepmind/mujoco_warp from GitHub.
PiperOrigin-RevId: 853350801
Change-Id: Idb19c2865b94f4740daf8bc52ed3e7665a109d51
2026-01-07 11:42:11 -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
Sam Haves 3c93d6b979 Move cache creation into lambda initializer to avoid data race.
PiperOrigin-RevId: 853295269
Change-Id: Ic1c8f3d2fec876070da432f8b709b341f3c6cc0a
2026-01-07 09:29:54 -08:00
Matija Kecman e1261ba5f1 Fix perturbation rendering in webdemo
PiperOrigin-RevId: 853290958
Change-Id: Ifcea1091633597171c5268d5ee091bea3ddee45b
2026-01-07 09:18:45 -08:00
Yuval Tassa 775c0698c3 MJCF schema: use responsive grids for attributes
PiperOrigin-RevId: 853263519
Change-Id: I79cb6e6208061d9546f0dca7a941838caa6b1a91
2026-01-07 08:00:16 -08:00
Alessio Quaglino 5febca9eeb Remove gainprm trailing dimension in test_actuator_shortname.
PiperOrigin-RevId: 853243753
Change-Id: Ia46df64a2308ef0bbc94a396f0732e221e174ea0
2026-01-07 06:59:50 -08:00
Yuval Tassa 5be6f262b2 Fix legend call in MuJoCo tutorial notebook. Fixes #2447
PiperOrigin-RevId: 853220360
Change-Id: I1920af5fd01bcf654c7d9d11d8dd1c2f637ef748
2026-01-07 05:42:45 -08:00
Haroon Qureshi 9743c2d385 Use mjResourceProvider instead of custom LoadAsset callbacks.
PiperOrigin-RevId: 853172824
Change-Id: I60ef1207611c4da119cc3f0a7819088cffca6e4f
2026-01-07 03:03:23 -08:00