Commit Graph

1804 Commits

Author SHA1 Message Date
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
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
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 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
Alessio Quaglino a49576e469 Move flexedge sparse Jacobian indices to mjModel.
PiperOrigin-RevId: 855718305
Change-Id: Ic136f4efa6735b934288f65c332d71ee8b0f6da5
2026-01-13 07:33: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
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
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
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
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 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
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
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
Haroon Qureshi 9743c2d385 Use mjResourceProvider instead of custom LoadAsset callbacks.
PiperOrigin-RevId: 853172824
Change-Id: I60ef1207611c4da119cc3f0a7819088cffca6e4f
2026-01-07 03:03:23 -08:00
Yuval Tassa fa044fe0e5 Use the word "primal" for things that relate to both Newton and CG.
PiperOrigin-RevId: 852634373
Change-Id: I2c7641bb92d9c01252f861b9c36e72ef6ddc6e98
2026-01-05 23:56:57 -08:00
Haroon Qureshi e3ddb126f5 Fix target name; should be PLATFORM not STUDIO.
(This was caused by a bad merge on my end.)

PiperOrigin-RevId: 851315742
Change-Id: Ifd5afa7f6cbd566ef2c15603e91a7360ea65c86a
2026-01-02 06:03:13 -08:00
Haroon Qureshi b9fa8ee6e9 Move all specialized rendering logic into Renderer class.
(We may consider splitting this class up into specialized subclasses at a later date.)

PiperOrigin-RevId: 851290789
Change-Id: Iee00b8e906eeb911de5799f784475ac6916ab55b
2026-01-02 04:25:07 -08:00
Matija Kecman 9f674b04a9 Fix ground plane rendering when using filament backend
PiperOrigin-RevId: 848473849
Change-Id: I096b20c6a5538ff95396bdf09f84ed5f2d3015ed
2025-12-24 01:25:51 -08:00
Yuval Tassa 70bc7be4bc Add additional data fields that can be reported by rangefinder sensors.
PiperOrigin-RevId: 848316991
Change-Id: Idbf7ba81b4da711a22c23302c8782ab2b0b98d82
2025-12-23 15:33:00 -08:00
Yuval Tassa f2e9097ed6 Change mjsCamera.resolution type from float to int.
Resolution is inherently an integer quantity (pixels).

PiperOrigin-RevId: 848276456
Change-Id: I92ee1aa88fd552fd42cb3871442f020f26d6fa6a
2025-12-23 13:14:32 -08:00
Yuval Tassa 9d646e6548 Extend rangefinder sensor to support cameras.
PiperOrigin-RevId: 848255889
Change-Id: I6e1a9ed13d29d2242558625a47e24e47ad6e87db
2025-12-23 12:04:49 -08:00
Yuval Tassa 4a871990e9 Fix mismatched signature in engine_ray.c
PiperOrigin-RevId: 847834144
Change-Id: Ib42008880f495cf7f3b9e0fd2394a4df64c66ad4
2025-12-22 11:41:23 -08:00
Yuval Tassa b28b5db680 Add mj_multiRayNormal for multi-ray casting with normal computation (not exposed in public header)
PiperOrigin-RevId: 847821078
Change-Id: I616441d3460406a92a10731d1a086af6163e96ad
2025-12-22 11:02:58 -08:00
Yuval Tassa 7fddeeaff6 Minor fixes to mj_multiRay
PiperOrigin-RevId: 847780959
Change-Id: I3588415f215bd5f1592bec6678a5bae45d5f0980
2025-12-22 08:52:36 -08:00
Haroon Qureshi a3e66cd5df Combine performance charts; add fullscreen mode.
PiperOrigin-RevId: 847751915
Change-Id: I819eb8d36224ddba38ef8532a038a2ef350890c8
2025-12-22 07:08:20 -08:00
Yuval Tassa 223ba99ec2 Add mju_rayFlexNormal (not exposed in public header)
PiperOrigin-RevId: 847746174
Change-Id: Ia8f597d296bf6a3eed9bd48b1c39b2ff2b5fcf90
2025-12-22 06:49:22 -08:00
Yuval Tassa c7f5766345 Add frustum visualization for orthographic cameras.
PiperOrigin-RevId: 847698917
Change-Id: I13633e8ba2d4718b127a5838c404ab74c6180e3d
2025-12-22 03:43:54 -08:00
Yuval Tassa 158525269b Refactor camera intrinsic parameter handling.
Move logic from parser to compiler.

PiperOrigin-RevId: 847689906
Change-Id: I844746081973205e1b33a3845add842e8b8c3c07
2025-12-22 03:08:18 -08:00
Yuval Tassa b8a4ac5d48 Refactor camera orthographic attribute to projection enum.
PiperOrigin-RevId: 847069028
Change-Id: I7f686fe654e9b56519cab8bd2f37c9cc40091d3f
2025-12-20 03:28:29 -08:00
Sam Haves 44c8ef890d When building with USD enabled, add functionality that automatically registers the mujoco USD plugins.
PiperOrigin-RevId: 846767370
Change-Id: Ieedbe127353623c11150551c1409d340dbc57421
2025-12-19 09:39:03 -08:00
Sam Haves 3d9c195e3c Fix rpath for usd target shared libs.
PiperOrigin-RevId: 846759676
Change-Id: I5b2a73b3f997d4d0d447e051c43069ae7418a7ec
2025-12-19 09:14:45 -08:00
Yuval Tassa 849a650143 Refactor mju_cholUpdateSparse to use a dense accumulator, 1.5-2x function speedup.
PiperOrigin-RevId: 846754379
Change-Id: Ie599658db2907a26095072d97d07b99a693050dc
2025-12-19 08:57:45 -08:00
Sam Haves 9e150fe82c Add separate build step for OpenUSD to third_party_deps.
This will fetch and call the build_usd.py build helper for OpenUSD and build within the MuJoCo _deps folder. Simplifying the build process for MuJoCo with USD. Users can still provide their own USD build, but must now do so via pxr_DIR.

PiperOrigin-RevId: 846735578
Change-Id: I0da7eb2da6465e2d518084340e762bf370adb6d5
2025-12-19 08:00:15 -08:00