Commit Graph

1605 Commits

Author SHA1 Message Date
Sam Haves 57f7145806 Create mjpDecoder, mj_parse, and mju_decodeResource
- plugin system similar to mjpResourceProvider, but instead of loading a resource it converts an existing mjResource into an mjSpec.
  - The returned spec is then composed into the referencing spec.
  - This enables different file types to generate arbitrary specs, and allows us to separate format parsing from compilation code.

Follow up CLs will move some of the logic in src/engine for PNG, USD, KTX, OBJ loading into decoders.

The mj_parse function MjSpec from a given file, it's a more generic version of mj_parseXML.

In it's implementation, mj_parse as opposed to mj_parseXML will look for any registered decoder and
not assume we are striclty dealing with MJCF.

PiperOrigin-RevId: 826149497
Change-Id: I0ece26904280cb94bd5ded6dd5a565c539d60254
2025-10-30 12:54:40 -07:00
Haroon Qureshi 80eb511620 Remove dependency on Window, Physics, and Renderer classes.
PiperOrigin-RevId: 825137441
Change-Id: I099a518ca9618698401d0330a6ef08278168f88e
2025-10-28 11:42:17 -07:00
Haroon Qureshi 4620b9f23a Merge HandleMouseEvents and HandleKeyboardEvents back into app.cc.
PiperOrigin-RevId: 825081195
Change-Id: I36445b8c452b15ca26056a52fd1844cf77083c0a
2025-10-28 09:44:42 -07:00
Alessio Quaglino 1bfa8b6fa6 Do not add bodies at mesh points for quadratic flex interpolation.
PiperOrigin-RevId: 825001743
Change-Id: Ica085b947fb1c3f56251bceaa6a228f364535d3e
2025-10-28 06:13:27 -07:00
Haroon Qureshi 3b79d3f14b Set flags directly on Renderer class.
This removes a dependency on mjvScene from the App class.

PiperOrigin-RevId: 824983816
Change-Id: I20dd411e6359ee411f9b0b86d4442c090ba4bd5c
2025-10-28 05:24:05 -07:00
Haroon Qureshi 7ba0d96d77 Use mjvCamera directly for generating camera string.
PiperOrigin-RevId: 824982264
Change-Id: I0d8760bb27153849c8f4dacb10aa3162f29c2f6e
2025-10-28 05:18:58 -07:00
Yuval Tassa e1a73f9c4c Add early exit in mj_xfrcAccumulate using mju_isZeroByte
`xfrc_applied` mostly contains user perturbations which are rare. It is very often identically zero and for large arrays `mju_isZeroByte` is significantly faster than `mju_isZero`.

PiperOrigin-RevId: 824975356
Change-Id: Iadb1d300d68cf12de00c14a0665bd89924a2d7e0
2025-10-28 04:59:14 -07:00
Haroon Qureshi a16805f8ee Add CMakeLists.txt files for new (experimental) code.
This includes the filament, toolbox, and studio projects.

Adds a MUJOCO_BUILD_STUDIO option to enable building of the `studio` app (disabled by default).

Adds a MUJOCO_USE_FILAMENT to allow the studio app to use the filament rendering backend. A separate MUJOCO_USE_FILAMENT_VULKAN flag can be used to enable vulkan rendering.

PiperOrigin-RevId: 824602367
Change-Id: I26d46c16211ae2118f96c163c4194fea5b5a15a9
2025-10-27 11:26:14 -07:00
Taylor Howell 85e9cff0c1 Update mj_geomDistance: don't flip geoms for nativeccd.
PiperOrigin-RevId: 824463375
Change-Id: Ic9c4cac916129b88575e0366e1b95353ce716ca2
2025-10-27 04:48:36 -07:00
Saran Tunyasuvunakool 49a3caf84c Modify SimulationState proto to correspond to mj_getState.
PiperOrigin-RevId: 823494487
Change-Id: Ib284e3165ca691f5b690a376f7b28e51122e1bc4
2025-10-24 05:51:07 -07:00
Alessio Quaglino ec8ad21cb5 Normalize triangle coordinates such that their sum rather their norm is one.
This ensures that at e.g. the barycenter of the triangle each vertex has weight 1/3, as one would expect with barycentric coordinates, rather than 1/sqrt(3). This makes it consistent to the finite element interpolation used in the passive elastic forces.

PiperOrigin-RevId: 823458736
Change-Id: Ia5c02cba186a80612de38402f791695c33e991ab
2025-10-24 03:42:55 -07:00
Haroon Qureshi 99c18f07d3 Increase buffer size.
The smaller size is a warning/error on some targets:

```
error: ‘ bytes’ directive output may be truncated writing 6 bytes into a region of size between 0 and 15
```
PiperOrigin-RevId: 823047552
Change-Id: Id66b5828cf84a512dffc452753f1881deb685584
2025-10-23 08:16:54 -07:00
Haroon Qureshi 1fd9b47fea Prefix assets path with "assets/".
PiperOrigin-RevId: 823044312
Change-Id: I0bde4428bd1992d6d4356e107dac471fa7cdecc6
2025-10-23 08:07:33 -07:00
Sam Haves febe75d54b Add tendon.cpp to mjcPhysics CMake
PiperOrigin-RevId: 822694422
Change-Id: Ic2f7c7a3b85526d49eb98c19118e6936ccb4e0f7
2025-10-22 12:30:16 -07:00
Sam Haves ae33724de1 Set info string on wrap instead of tendon when wrapping a prim in the path.
PiperOrigin-RevId: 822688877
Change-Id: I04f5f5576cc0ed43e0ec77d5fccb19d2d23d7349
2025-10-22 12:13:53 -07:00
Sam Haves 160b9480f9 Add support for tendons to mjcPhysics.
PiperOrigin-RevId: 822230926
Change-Id: I232a9fbfb473186ac742d210458ff0221a561126
2025-10-21 12:30:12 -07:00
Sam Haves ac2cd5dfd6 Add support for querying of MjsTendon path from Python.
Fixes #2670

PiperOrigin-RevId: 822215254
Change-Id: Ice5a264e54f963776093511c6e4ac830aae6d4f8
2025-10-21 11:51:24 -07:00
Saran Tunyasuvunakool 2f65e23779 Add mj_extractState as a public API function.
This function allows the caller to extract a subset of components of a state previously obtained via `mj_getState` without having to first write it back into `mjData`.

PiperOrigin-RevId: 822165077
Change-Id: I6433261f4f5ec2e8d024bb7dee8f7dbf1e62666c
2025-10-21 10:01:22 -07:00
Kyle Bayes 25f5be82ff Provide option to disable keyboard events for SDL.
PiperOrigin-RevId: 822154396
Change-Id: Ie4c8537de2c4b01437aae00ed6d6af1a8f419a73
2025-10-21 09:36:16 -07:00
Sam Haves 09682ade4b Fix mjcPhysics island flag default.
PiperOrigin-RevId: 822088739
Change-Id: If3a87976dd319502160fd886a1823c12d72bebf1
2025-10-21 06:27:28 -07:00
Alessio Quaglino 01d1ac34e0 Add quadratic interpolation to flex.
PiperOrigin-RevId: 822055781
Change-Id: Ibc252ac560de666b0b28f868e46b88d3ed92f67d
2025-10-21 04:36:36 -07:00
Sam Haves 59f14485e0 Move mjCWrap type to mjsWrap.
PiperOrigin-RevId: 821851540
Change-Id: I53382a8a21312a96aea46eec130f43e7cad70f92
2025-10-20 16:28:41 -07:00
Matija Kecman 88ac02dad3 Add UI to visualize the State
PiperOrigin-RevId: 821641514
Change-Id: I41fd5602d0d52162b374149fb0080f6c387d7847
2025-10-20 07:32:41 -07:00
Haroon Qureshi e75c5aa83c Fix various include paths.
PiperOrigin-RevId: 821564663
Change-Id: Ic84489b7f3e1ba97810f60049dcf2f4a4d31edcf
2025-10-20 02:55:22 -07:00
Alessio Quaglino ff7c94de8a Add quadratic interpolation to mju_interpolate3D.
PiperOrigin-RevId: 820252349
Change-Id: I983175eb51d7e1a81da06c0911326fcb8f5fe764
2025-10-16 08:48:20 -07:00
Haroon Qureshi 87adb7e5d6 Use the ImGui OpenGL3 backend.
PiperOrigin-RevId: 820249390
Change-Id: I43fc85bf75a2c01b76218a2ff67a1526ee9e2bdb
2025-10-16 08:39:51 -07:00
Alessio Quaglino ffdfe542cf Add mju_interpolate3D.
This is a more general API in preparation of a higher interpolation order

PiperOrigin-RevId: 820174741
Change-Id: I81bd52ab44e0485d72579e21d1c8a48a1b35ec3f
2025-10-16 04:39:24 -07:00
Gabe Oppenheimer 48f10bfcb6 Update MuJoCo to v3.3.8 following the 3.3.7 release.
PiperOrigin-RevId: 819919328
Change-Id: Ib34f959f6f8efd83362d49e784aa8e0594036899
2025-10-15 14:39:05 -07:00
Kyle Bayes 8cbfc42767 Fix issue with zero size cache.
PiperOrigin-RevId: 819773517
Change-Id: Iff1523e17ffbd1dff02bee71db896c64bd8b565c
2025-10-15 08:46:00 -07:00
Yuval Tassa 5715cebbb9 MSAN: Don't clear mjData.sensordata in mj_resetData
This is strictly an out array and should not be read before it is written to. This change improves MSAN coverage of engine code.

PiperOrigin-RevId: 819767673
Change-Id: I57500c8147f4774d326cf87ea3bac5420e4dd54d
2025-10-15 08:31:03 -07:00
Haroon Qureshi 9174c87203 Minor fixes.
PiperOrigin-RevId: 819680566
Change-Id: Ie2480eab3c974227268222190fdb84ed671303f2
2025-10-15 04:07:36 -07:00
Alessio Quaglino b6f25ca623 Check mjs_getName return value in XML parser. Fixes #2898.
PiperOrigin-RevId: 819351410
Change-Id: I0807d71328068f6388991ae15274c7d61b4d3e53
2025-10-14 12:40:28 -07:00
Haroon Qureshi f1d45bd542 Fix minor formatting issues and use nullptr consistently.
PiperOrigin-RevId: 819178621
Change-Id: I3f6bfb6888075188d49e32110af2074b07c6b918
2025-10-14 06:15:57 -07:00
Gabe Oppenheimer ae1febd83f Automated g4 rollback of changelist 818694877.
*** Reason for rollback ***

BEGIN_PUBLIC
Holding off on a minor version bump until the next release.

*** Original change description ***

#mujoco update the version to 3.4.0 ahead of the 3.4.0 release.

Bump the version to 3.4.0 ahead of the next release.

***

PiperOrigin-RevId: 818748143
Change-Id: I722e9beb80c61a48bd997da6a1840777a81d5036
2025-10-13 11:14:42 -07:00
Gabe Oppenheimer 02d2d4d49a Bump the version to 3.4.0 ahead of the next release.
PiperOrigin-RevId: 818694877
Change-Id: I42e261956a0219e549bec6a54cbf330a74f02f9f
2025-10-13 09:22:49 -07:00
Yuval Tassa bbeb0b95a7 Reset contact efc_address in mj_clearEfc, fixes #2869
The truth is that all these solver-related values should be moved out of `mjContact` altogether, but that can be done in a future followup.

PiperOrigin-RevId: 818624976
Change-Id: I5b9e63927098cdf26b9f8acfdd9d86e75d6ce331
2025-10-13 06:18:41 -07:00
Haroon Qureshi 9b7e7e471d Add line and linebox geom primitives.
PiperOrigin-RevId: 818570050
Change-Id: If02873dd878a23b442368ce69bc024e0310e9d02
2025-10-13 02:59:13 -07:00
Haroon Qureshi 66a1c22cae Label all bodies, not just selected bodies, when mjLABEL_BODY is set.
An earlier refactor incorrectly assumed that only selected bodies needed
labels.

PiperOrigin-RevId: 818568645
Change-Id: I7aea07c5342673dd589e1891d0db1f2b0c489fe4
2025-10-13 02:54:34 -07:00
Yuval Tassa a7fe06c717 Further simplification to mj_crb
PiperOrigin-RevId: 818241421
Change-Id: I67dd2a60f415eb17b41f5ee553939118ab124123
2025-10-12 01:43:30 -07:00
Yuval Tassa 12f0e3df9a Quick return for static bodies in mj_object{Velocity,Acceleration}
PiperOrigin-RevId: 818238459
Change-Id: I340a2f61439db2a149cc64a5fee543680fdcad0f
2025-10-12 01:25:05 -07:00
Kyle Bayes 9e0885a4fa Handle exceptions in VFS C API.
PiperOrigin-RevId: 817688877
Change-Id: Ia2e306fe4cd1848eb5731212aa4e959080a9d377
2025-10-10 10:03:36 -07:00
Haroon Qureshi b63252e4bb Render labels for any geom with a label, not just label geoms.
PiperOrigin-RevId: 817686605
Change-Id: I030626dd942e50eef33e0de7e9d0f314fd2f457d
2025-10-10 09:58:21 -07:00
Haroon Qureshi ff7c613c79 Initial implementation of the filament rendering backend for mujoco.
This is intended as a drop-in replacement for mjr_render to enable high
quality, physically-based rendering (PBR) using the filament render engine.

This is a work-in-progress and, as such, some features may be missing. This
is also a code-only drop; build files (including instructions on how to
generate the filament materials) will be provided at a later date.

This library is intended to be run with the experimental studio app.

PiperOrigin-RevId: 817593684
Change-Id: Ib9cd14c1881e4897c1111275bd749aa38ebb5317
2025-10-10 05:01:39 -07:00
Matija Kecman 59a5a7bf5f Improve error messages in LoadMujocoModel
PiperOrigin-RevId: 817565307
Change-Id: I367298cdf77d26b6f8deb5c6a0d5c3cab1e4d065
2025-10-10 03:24:50 -07:00
Haroon Qureshi abe88202d0 Remove redundant flags argument.
PiperOrigin-RevId: 817115667
Change-Id: I4e5096206d7c24f5861e1bb9e8049149803dceeb
2025-10-09 04:07:43 -07:00
Alessio Quaglino 98682ae284 Do not modify mesh position when fitting a geom to the mesh AABB.
Also, unify the meaning of fitting a geom to an AABB: it now means to find the smallest geom such that its AABB contains the mesh AABB.

Fixes #2881.

PiperOrigin-RevId: 817097544
Change-Id: I883c686feffa803bd16ba461db24a474dfec7712
2025-10-09 03:05:00 -07:00
Sam Haves 3a299c49ca Remove use of usdaFileFormat from mjcf_file_format.
Previously this was just used for the USDA file format token, which we can confidently just construct ourselves.

Since [this PR in OpenUSD](https://github.com/PixarAnimationStudios/OpenUSD/commit/5bb9ad1fb2a034e1f9b48c7db936f296b5b78e25) the file lives in a different place now and public usage will be deprecated anyways.

PiperOrigin-RevId: 816801204
Change-Id: I42e92d2af52b0f9ff0a679ecb96f3d2dbf623531
2025-10-08 11:54:44 -07:00
Haroon Qureshi 1335ec87e4 Move font assets data targets into toolbox library.
PiperOrigin-RevId: 816654994
Change-Id: Ic56fab2b0af0c8d85682f8b233342a0d088d5cca
2025-10-08 05:09:42 -07:00
Haroon Qureshi 8e4932170a Remove unused params.
PiperOrigin-RevId: 816654011
Change-Id: Ib26bc90dcda167e8acf1feaa3b015acb5aa7aceb
2025-10-08 05:05:59 -07:00
Haroon Qureshi e7e331b11e Update sensor decor elements to be of type mjOBJ_SENSOR.
PiperOrigin-RevId: 816640568
Change-Id: I838608c0482ec1ee499fe9598ddb33aa6c5331e9
2025-10-08 04:17:40 -07:00