Commit Graph

454 Commits

Author SHA1 Message Date
Kyle Bayes 490c1f4126 Refactor mj_collideGeoms.
PiperOrigin-RevId: 878091736
Change-Id: I738c2e5a21036d859b7b163cb000dc516b63a878
2026-03-03 13:11:14 -08:00
Alessio Quaglino bf74d01d93 Add collisions between flexes and SDF geoms.
The flex-SDF algorithm uses the same logic as mesh-SDF. Previous to this change, the flex was instead colliding with the convex hull of the mesh generated automatically with marching cubes from the SDF.

PiperOrigin-RevId: 876420302
Change-Id: I3bf6552b6b8e108ba4c4209bbcf10fe5f2b2fd90
2026-02-27 14:35:27 -08:00
Kevin Zakka 43cde9716c Fix mj_sensorAcc returning zero after mj_step1 by clearing flg_rnepost in mj_step2.
Fixes #3133.
2026-02-25 14:04:33 -08:00
Taylor Howell 52ed96bc3a Move tendon sparsity fields from mjData to mjModel
PiperOrigin-RevId: 875087590
Change-Id: I1a5489d2d2011795ee38b09d547e68acd72e3cc7
2026-02-25 04:32:11 -08:00
Kyle Bayes cd8bfb90c3 Improve polygon creation logic in compiler.
PiperOrigin-RevId: 875070301
Change-Id: I06e851f3450035fff68b99997406d6ea471ce3b8
2026-02-25 03:40:07 -08:00
Sam Haves 82e92cbcaa Remove PluginTest and make MujocoTest load plugins.
MujocoTest now loads plugins from MUJOCO_PLUGIN_DIR if set.
PluginTest is removed; all tests use MujocoTest directly.
testspeed binary loads plugins from MUJOCO_PLUGIN_DIR.

This is in preparation for moving common asset format parsing (obj, msh, stl, etc.) where we will always want to load those plugins.

PiperOrigin-RevId: 874194428
Change-Id: Id90805a9ba5de4627911b56d8b9c4ab4e1b29310
2026-02-23 12:15:22 -08:00
Alessio Quaglino f9a39413cf Fix: Include ancestor DOFs in flex interpolation factorization.
The reduced dense factorization for flex interpolation now considers all DOFs in the kinematic chain of the body containing the flex, using mj_bodyChain, instead of only the DOFs directly associated with that body. This is necessary for correctly handling pinned flexes when their parent body is part of a larger kinematic structure.

PiperOrigin-RevId: 872854468
Change-Id: Idbe9fb459084dde9e8eb1076c70dbb685c1b0bdb
2026-02-20 05:30:54 -08:00
Taylor Howell 9efe41c0c1 Remove dense code path for tendon Jacobian
PiperOrigin-RevId: 872444531
Change-Id: I6180101abc49469a72aee8bec5726e1e94f142ec
2026-02-19 09:53:49 -08:00
Taylor Howell 5903d4826f Sparse ten_J and ten_J_colind
PiperOrigin-RevId: 869712136
Change-Id: Id2979684aa0c39552cb8453852483cbac55f0ea3
2026-02-13 06:57:22 -08:00
Yuval Tassa 6af0d4c823 Replace margin/gap max with sum.
PiperOrigin-RevId: 868842521
Change-Id: Ia4a4ca5c6821c5a7b3ba7b0af7f71d981c2866c1
2026-02-11 14:22:27 -08:00
Google DeepMind 336e1026a4 Sparse ten_J and ten_J_colind memory
PiperOrigin-RevId: 868834376
Change-Id: Iec92d9e09e3134666895e54a78cb02439d74a4de
2026-02-11 14:05:43 -08:00
Yuval Tassa b466829482 Fix implicit integrator derivatives when actuator force is clamped.
The derivatives of actuator velocity with respect to generalized velocities were incorrectly computed when the actuator force was limited by `forcerange`. This CL adds a check to zero out these derivatives when the actuator force is at its upper or lower limit, as the force is no longer a function of velocity in this clamped state.

PiperOrigin-RevId: 868818281
Change-Id: I89742a3f04989dd11f9cfada107200015b1472a7
2026-02-11 13:31:07 -08:00
Taylor Howell d011285380 Sparse ten_J and ten_J_colind memory
PiperOrigin-RevId: 868800229
Change-Id: Id83f9fd40dd9bece06fd99753e4202eea17ca884
2026-02-11 12:45:50 -08:00
Yuval Tassa 2b5afce4aa Fix island graph construction for multi-tree constraints, fixes #3073
Replace dynamically-sized edge list with a dense ntree×ntree adjacency matrix for deduplication and a flat CSR representation.

PiperOrigin-RevId: 868728432
Change-Id: Iebe97a0870740e5465549b967bbde0c81e658269
2026-02-11 10:05:32 -08:00
Yuval Tassa 7f74487a26 Fix implicit integrator derivatives for actearly actuators.
The derivative calculation for actuator velocity in implicit integrators now correctly accounts for the `actearly` flag, using the next activation value when `actearly` is true.

PiperOrigin-RevId: 868598722
Change-Id: Ia180afb15b31a718170aeaf9d4ac514bb9e6073b
2026-02-11 04:03:46 -08:00
Alessio Quaglino 419b96cb91 Reduce simulation steps in MjCollisionTest.PinchingSucceeds.
PiperOrigin-RevId: 868229821
Change-Id: I781955a8f06ca2338baa713ff6a3448b4743b35e
2026-02-10 11:05:10 -08:00
Alessio Quaglino e16ee4fcb4 Fix flex-parent coupling in implicit integrator.
The implicit integrator was not correctly accounting for the off-diagonal coupling terms between flex and non-flex (parent) degrees of freedom in the mass matrix. This change extracts these coupling terms during the factorization step and applies a correction to the flex forces before solving for the flex accelerations, ensuring that the parent accelerations influence the flex dynamics. A new test verifies that the implicit integrator now matches Euler for small timesteps in a model with flex-parent coupling.

PiperOrigin-RevId: 868098126
Change-Id: Ia8cccd7dd428cd0c0898e1663a7e41017a2311b2
2026-02-10 05:35:48 -08:00
Alessio Quaglino 0041fdcbb0 Add implicit stiffness for flex_interp to mj_implicitSkip.
PiperOrigin-RevId: 867706885
Change-Id: Ic94c65b618a415609bffe3d69a86f9034f2d2400
2026-02-09 11:54:27 -08:00
Yuval Tassa c1b3b3063e Fix gravcomp being ignored for movable bodies without joints. Fixes #3066
PiperOrigin-RevId: 867679545
Change-Id: I8c16d3a4c93d121fcc30cab5179ba44fe49aaa19
2026-02-09 10:55:07 -08:00
Yuval Tassa d680b3d234 Rename "delay" buffer functions to "history" buffers.
The functions and associated tests related to managing time-stamped data buffers have been renamed from `mju_delay*` to `mju_history*` to better reflect their general purpose beyond just handling delays.

PiperOrigin-RevId: 866978339
Change-Id: I8655e91bce783287ad2adc412d13a1c39aa2c322
2026-02-07 14:10:16 -08:00
Yuval Tassa 6419534bad Add actuator and sensor delays. Fixes #1004
PiperOrigin-RevId: 866478839
Change-Id: Id21a6da0f98454c8fa39ea5af8a5e213d6eae497
2026-02-06 08:47:36 -08:00
Yuval Tassa 84fa527723 Add delay buffer utilities to engine_util_misc.
PiperOrigin-RevId: 866450284
Change-Id: I86d6dd6a6f7519640f75ca405fb60a12e8619c86
2026-02-06 07:22:34 -08:00
Alessio Quaglino a54c9f1d78 Specialized box and capsule collision primitives for stable 2D flex interactions.
PiperOrigin-RevId: 864500749
Change-Id: I52aed6e29569477a8a0b6b5eb55ad483f1077c0e
2026-02-02 13:36:42 -08:00
Alessio Quaglino 7da271c687 Add vertex equality option.
PiperOrigin-RevId: 860299454
Change-Id: I7befd8e5f4c8bac6d74684a96a9cc3cee9ae1e29
2026-01-23 16:30:05 -08:00
Alessio Quaglino 54dd623650 Add vertex-based flex constraints (dim=2).
PiperOrigin-RevId: 859552050
Change-Id: I61d4b9dc40f041c5b930e5f8810a803e8bccb87a
2026-01-22 04:54:53 -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
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
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
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 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 b8a4ac5d48 Refactor camera orthographic attribute to projection enum.
PiperOrigin-RevId: 847069028
Change-Id: I7f686fe654e9b56519cab8bd2f37c9cc40091d3f
2025-12-20 03:28:29 -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
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
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 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
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