Commit Graph

910 Commits

Author SHA1 Message Date
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
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 9d646e6548 Extend rangefinder sensor to support cameras.
PiperOrigin-RevId: 848255889
Change-Id: I6e1a9ed13d29d2242558625a47e24e47ad6e87db
2025-12-23 12:04:49 -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 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
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
Yuval Tassa 45b0153067 Refactor sparse Cholesky factorization into symbolic and numeric phases.
The new symbolic function is a generalization of the function it replaces. In this CL it takes two unused temp arrays. The actual change in behavior happens in the followup.

New benchmark test output below ("L" is 2 humanoids and 100 free objects, "XL" is 100 humanoids). Note that `symbolic` is only ever called once per Newton iteration, while `numeric` is sometimes called multiple times (when the rank-1 update fails), hence timing them separately is valuable.

```
Benchmark               Time(ns)        CPU(ns)     Iterations
--------------------------------------------------------------
BM_old_L_mean              84382          84703          19547  11.807k items/s
BM_symbolic_L_mean         16345          16381          88414  61.055k items/s
BM_numeric_L_mean          10986          10994         120000  90.999k items/s
BM_old_XL_mean           1241208        1244212           1200  803.924 items/s
BM_symbolic_XL_mean       130917         131042          12720  7.631k items/s
BM_numeric_XL_mean         77004          76767          21116  13.029k items/s
```

PiperOrigin-RevId: 846704054
Change-Id: Ib0c365724d63bf2b81606ca5353756a6496c3a26
2025-12-19 06:11:55 -08:00
Sam Haves 05e1c452c7 Add VFS parameter to mjpDecoder decoding function.
PiperOrigin-RevId: 846242734
Change-Id: I317e11e6fcd965f66416abcf690a3a65d043e9ee
2025-12-18 06:38:40 -08:00
Yuval Tassa 47e35e632f Add a test for equivalence of different solvers.
PiperOrigin-RevId: 845777469
Change-Id: I76a162b71bea349cca3472001360181654a5d571
2025-12-17 08:21:52 -08:00
Yuval Tassa 08b4b4144d Add tests for mju_cholUpdate and mju_cholUpdateSparse.
PiperOrigin-RevId: 845229292
Change-Id: Ide1406f85e49fe5a5b339bedff7ff6dd8099e5e8
2025-12-16 05:59:40 -08:00
Sam Haves eef71832db Remove usage of usdImaging tokens to avoid needing to build imaging.
PiperOrigin-RevId: 844768270
Change-Id: Iba0a03646e56d9be5accf754f97ec37db8055425
2025-12-15 07:44:18 -08:00
Haroon Qureshi 52ca07e210 Decoder decode function should take a non-const pointer to mjResource.
This is because mjcReadResource requires a non-const pointer.

PiperOrigin-RevId: 844737328
Change-Id: I88d217aa85a66023f6b222437403c136448cabfe
2025-12-15 06:04:05 -08:00
Yuval Tassa 1ff74ba810 Change the type of state signature arguments from unsigned int to int
PiperOrigin-RevId: 843162492
Change-Id: I51d3324f088e8055898e115bdd32267c5950a412
2025-12-11 04:34:36 -08:00
Yuval Tassa f06aa45ea6 Consolidate ray normal functions.
PiperOrigin-RevId: 842300829
Change-Id: Ic5e921084710cb044a4f49ea9b566d277838aaa1
2025-12-09 10:36:10 -08:00
Yuval Tassa 5b1fa666fb Add mj_rayHfieldNormal (not exposed in public header)
PiperOrigin-RevId: 842259581
Change-Id: I27d6c46024d55addbc22eed276331e2ef5acfa7d
2025-12-09 08:53:47 -08:00
Yuval Tassa c064abc3da Change row-flipping logic for heightfields.
Move row-flipping logic from `mjCModel::CopyBack` to `mjXWriter`.

PiperOrigin-RevId: 842220322
Change-Id: I6fb09db6c9e8689f6e435f82f58dd3e7c4314478
2025-12-09 07:02:21 -08:00
Yuval Tassa f65c1cdfd1 Add mj_raySdfNormal (not exposed in public header)
PiperOrigin-RevId: 842178540
Change-Id: I5d2db555e9b6c0fa0daaa8bc14c7781663e4c94e
2025-12-09 04:43:39 -08:00
Yuval Tassa ad24889bb9 Add mj_rayMeshNormal (not exposed in public header)
PiperOrigin-RevId: 838707353
Change-Id: If31d2454e0668f750bcba21ee42f81ef962e9097
2025-12-01 04:13:52 -08:00
Yuval Tassa 7caa3d6703 Add names to some sensors in sleep test XML.
PiperOrigin-RevId: 837611931
Change-Id: Ib077765d795037bdd0d32d19e1c7d5bf9b256d51
2025-11-27 14:09:21 -08:00
Yuval Tassa 888d3a7b07 Add mj_copyState
PiperOrigin-RevId: 836588419
Change-Id: I7609e121dc0ac697d4d015d4244bdd5962650def
2025-11-25 03:10:30 -08:00
Yuval Tassa f8b92410d4 Add test explaining body_rootid and body_weldid semantics
PiperOrigin-RevId: 835197910
Change-Id: If85ca80d3b576e2469cf0d9900441ddb9fd64462
2025-11-21 06:25:22 -08:00
Yuval Tassa d1317fd1a5 Add ray normal computation for primitives (currently private)
PiperOrigin-RevId: 834294539
Change-Id: I176f13a8f91dede589338fc44e099a16bac0b580
2025-11-19 08:01:02 -08:00
Yuval Tassa e18e35f967 Fix normal only for libccd during hfield collisions.
PiperOrigin-RevId: 833933161
Change-Id: I3a4ff044276d9c7305154da09b440168f0f22305
2025-11-18 12:55:56 -08:00
Kyle Bayes 8b9fa2674c Use std::vector instead of array in MJCF schema.
PiperOrigin-RevId: 831787681
Change-Id: I8093b8b10260daecb830e49319eda798e2dd2da5
2025-11-13 03:41:54 -08:00
Yuval Tassa b8512b9d1f Fix bug related to sleeping static children of mocap bodies.
PiperOrigin-RevId: 831376685
Change-Id: I8891a1d7dc6efc037e9ade5c7e8dd5c35c7e455e
2025-11-12 07:20:03 -08:00
Yuval Tassa 22c0b68903 Improve logic and documentation for sleeping sensors
PiperOrigin-RevId: 830891115
Change-Id: Ife8309b165c085b54c9f668d825d69ed12a9a8f0
2025-11-11 06:45:56 -08:00
Kyle Bayes 39f0321a68 Clean up NativeCCD testing models.
PiperOrigin-RevId: 830733959
Change-Id: Ie7f71c36d2efafd37aecef54ca4897cebd6d091f
2025-11-10 21:31:02 -08:00
Taylor Howell 883836848a Fix box-box distance computation.
PiperOrigin-RevId: 829431553
Change-Id: I9e28bc8eb7687c3c83e5ff68c65e93d8a07378a9
2025-11-07 07:37:03 -08:00
Yuval Tassa 769f37b653 Implement sleeping in engine
PiperOrigin-RevId: 829361787
Change-Id: I6f64d8e25c4248cf32c18cd94d37ff5def78946e
2025-11-07 03:33:07 -08:00
Yuval Tassa 252a0d73df Add sleep related data structures
PiperOrigin-RevId: 829055431
Change-Id: I1ccbd77a57044a754ae7db611b4c2c0010fbda53
2025-11-06 12:10:55 -08:00
Sam Haves 8051f40817 During mj_parse, if mju_openResource fails pass a resource with only the filename to decoders.
This enables decoders to leverage their own file resolution systems. For example: USD can compose a stage (scene) from memory, via a file on disk, or via custom asset resolver.

Passing it through to the decoder reduces the need for custom resource providers that wrap these other resolution systems.

This will also enable a fun, but likely niche usecase where the decoder does procedural generation and does not have to be backed by a resource. See the tests for an example of this.

PiperOrigin-RevId: 828939899
Change-Id: Ic319a685332d91198a4ae926867c834bf7f7f724
2025-11-06 07:06:06 -08:00
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
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 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
Sam Haves 09682ade4b Fix mjcPhysics island flag default.
PiperOrigin-RevId: 822088739
Change-Id: If3a87976dd319502160fd886a1823c12d72bebf1
2025-10-21 06:27:28 -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
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
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
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
Yuval Tassa ab9575d8a6 Refactor and speed up mj_crb and add a benchmark.
This is a no-op "prefactor" of `mj_crb` to reduce the number of lines changed in the upcoming sleeping CL. The main change here is that `mj_crb` now avoids accessing the model and data pointer repeatedly, but instead has the input and output pointers explicitly declared as local variables. A benchmark test found a healthy **14% perf bump** due to two changes:
- Adding `restrict` to `mju_mulInertVec`
- The function-local pointers.

Adding `restrict` to the local pointers had no effect. Note that `mj_crb` is not a particularly expensive function so these speed bumps are not significant per se, but rather indicative of possible future gains with these techniques.

```
Benchmark                Time(ns)        CPU(ns)     Iterations
---------------------------------------------------------------

ORGINAL BASELINE
BM_CRB_BASELINE_mean         4325           4348         993200  230.052k items/s

BASELINE + RESTRICT
BM_CRB_BASELINE_mean         4057           4090        1186150  244.573k items/s

LOCAL POINTERS + RESTRICT
BM_CRB_mean                  3772           3800        1001750  263.209k items/s
```

PiperOrigin-RevId: 815798225
Change-Id: Iffdf57b544e8e10562807c617f73ca4ccd1c614f
2025-10-06 10:54:01 -07:00
Yuval Tassa 431f96572e Remove unused mjOption.apirate.
PiperOrigin-RevId: 815633571
Change-Id: Ib98f3eb2df47f96fa1fe6e987a3a0cd23a9479f6
2025-10-06 02:51:17 -07:00
Sam Haves 6320b95957 Add mju_getXMLDependencies that given an MJCF file returns filepaths to all of it's dependencies.
PiperOrigin-RevId: 814203235
Change-Id: Ib5c2e2f4dd42224a768c88d76473544190c72bc0
2025-10-02 06:14:48 -07:00
Kyle Bayes 91257896c0 Implement faster mju_isZeroByte.
PiperOrigin-RevId: 814148714
Change-Id: Iaf5ed9d3502eaaaee8d46a986f2db00811ae0707
2025-10-02 02:53:53 -07:00
Sam Haves 2dc533b63b Allow flipping textures with any number of channels and user provided pixel data.
PiperOrigin-RevId: 813256285
Change-Id: I0d49885dc483ab8f093b2566ec4bef355575505e
2025-09-30 07:28:13 -07:00
Kyle Bayes bdccbcc60a Add multiccd fields to MJX and add simplex box-mesh model.
PiperOrigin-RevId: 813190617
Change-Id: Idc450da59d6420825077a642719525750f6551ec
2025-09-30 03:40:29 -07:00