Yuval Tassa
7e9ac58ff9
Migrate mjd_inverseFD mass Jacobian from qM to M
...
PiperOrigin-RevId: 942268237
Change-Id: I0ecfe161867ce9930cd6366d778077df2cd3197f
2026-07-03 15:35:52 -07:00
Yuval Tassa
5618666a7d
Add body/simple attribute to control simple body optimization.
...
PiperOrigin-RevId: 942164766
Change-Id: I1e83bb99b6a1955917eb9b2e9bed0dc7b8e6a161
2026-07-03 09:09:30 -07:00
Yuval Tassa
14c0b0c92b
Recompute sameframe flags in mj_setConst.
...
The `body_sameframe`, `geom_sameframe`, and `site_sameframe` flags are now recomputed within `mj_setConst` based on the current model geometry. This allows these flags to be updated if the model's body/geom/site frames are modified after the initial compilation. Tests are added to verify the correct recomputation and its effect on forward kinematics. The compiler also checks that its initial computation matches the result of `mj_setConst`.
Fixes #3029 , #1628 .
PiperOrigin-RevId: 941758649
Change-Id: I7b995f8c67ad305bca5b52732436ba578c905d73
2026-07-02 10:49:00 -07:00
Yuval Tassa
f8462a156d
Refine line search convergence criteria.
...
The line search now requires a negative cost (improvement) in addition to a small derivative to declare convergence, preventing premature termination when no actual improvement has been made.
Follows the proposal in github.com/google-deepmind/mujoco_warp/pull/1471
PiperOrigin-RevId: 941579503
Change-Id: I8fcd20f7b959e50d77cd5d6de0a3c6d95f86b9e1
2026-07-02 02:56:24 -07:00
Haroon Qureshi
fb259a5edd
Implement RenderableManager.
...
Similar to LightManager, the RenderableManager manages
renderables based on an mjModel and its mjData.
PiperOrigin-RevId: 941510745
Change-Id: I97b44cc857f136aa7c90ceb85a42e299fc759b73
2026-07-02 00:03:05 -07:00
Georg Ostrovski
bb80b55ae1
Fix data race in mju_getLogConfigPtr lazy init
...
The lazy init of log_config used a single atomic flag (env_checked) with
a load-then-store pattern, allowing two threads to both enter the init
path and concurrently write to the non-atomic log_config.topics field.
Replace with a two-phase atomic init: an atomic exchange on
env_init_claimed ensures exactly one thread enters the init, while
env_init_done (with acquire/release semantics) signals completion and
provides the happens-before edge that makes log_config writes visible to
other threads.
Also adds mj_atomic_exchange_bool to engine_crossplatform.h (both MSVC
and GCC/Clang variants).
PiperOrigin-RevId: 941202181
Change-Id: I59b6801c7b4b8b0e1647d82d2aeb534a90fb66fb
2026-07-01 11:24:36 -07:00
Yuval Tassa
7c706b273a
Report nnz(J) for CG solver.
...
PiperOrigin-RevId: 939806054
Change-Id: Icb2955511e33be046a4665fb39bce2546d6d4e3d
2026-06-29 06:49:23 -07:00
Yuval Tassa
c499f7f2b0
Add Nesterov momentum with O'Donoghue-Candès restarts to PGS solver (~2x speedup)
...
Benchmark on `2humanoid100.xml` (nefc=1785, nv=654):
```
Convergence at fixed iteration count (mean relative error vs Newton):
20 iters: 2.98e-03 vs 1.54e-02 (5.2x better)
40 iters: 8.14e-05 vs 2.60e-03 (32x better)
80 iters: 1.17e-07 vs 1.77e-04 (1500x better)
Pipeline throughput (tolerance=1e-8, islands disabled):
Nesterov: 243 steps/s, 46 iters/step
Baseline: 151 steps/s, 95 iters/step
Solver speedup: 1.8x, overall step speedup: 1.6x
Pipeline throughput (tolerance=1e-8, islands enabled):
Nesterov: 306 steps/s, 442 iters/step
Baseline: 175 steps/s, 966 iters/step
Solver speedup: 2.1x, overall step speedup: 1.7x
```
PiperOrigin-RevId: 936610759
Change-Id: I2978e8bd545971d9151005623967e5cf0ad125cc
2026-06-23 05:52:14 -07:00
Taylor Howell
027cfd1201
simplify camera projection sensor
...
PiperOrigin-RevId: 936571266
Change-Id: I5647e61fcc81ba6eb482dd95d3c40438f478bb18
2026-06-23 04:17:38 -07:00
Yuval Tassa
afccd36dd4
Add threading support to PGS
...
PiperOrigin-RevId: 936252614
Change-Id: I6762245cc2dbdb95568f0a927c26b575dc494b51
2026-06-22 14:29:17 -07:00
Michael Moss
5700829122
Update MuJoCo version to 3.10.1 following the 3.10.0 release
...
PiperOrigin-RevId: 936044969
Change-Id: If0ebcc192419302da01741ebabb2b7dd3d7f7baf
2026-06-22 07:25:02 -07:00
Yuval Tassa
38c3388046
Fix rotation Jacobian offset in mj_jacSum sparse path.
...
PiperOrigin-RevId: 933640368
Change-Id: Ib30acd651b6022b0835e07b3f3b01e648791a511
2026-06-17 04:24:00 -07:00
Kyle Bayes
386b45fb75
Add tolerance to upper > lower bound check on first iteration of EPA.
...
PiperOrigin-RevId: 933615381
Change-Id: I175d3b97fa65f71a8f1cc34da5f6b9a23ab856d2
2026-06-17 03:19:19 -07:00
Kyle Bayes
0eec09dd60
Add runtime assertions to mji functions.
...
PiperOrigin-RevId: 933106771
Change-Id: I523cdceb89c90611f27983731c49fd4887034431
2026-06-16 08:36:32 -07:00
Kyle Bayes
d9b677b49b
Refactor remaining primitive and convex collision code to use mjPreContact instead of mjContact. Introduce internal struct mjcPair in engine_collision_driver.c for readability and extensibility for flex objects. This is a no-op.
...
PiperOrigin-RevId: 933105275
Change-Id: Id862b01774df63dcdb42629a5b7dd12019f12ffd
2026-06-16 08:33:09 -07:00
Kyle Bayes
b469144a81
Modify mjc_FlexSDF to support mjPreContact directly.
...
PiperOrigin-RevId: 933068825
Change-Id: I328d64bb05270067ce146908b0df3ca83f10ed9b
2026-06-16 07:04:16 -07:00
Haroon Qureshi
0ea9c7cb3a
Expose function for determining if tendons should be drawn using a catenary.
...
PiperOrigin-RevId: 931170146
Change-Id: Ia3352a3e2bdc5e4df932e9d476e1e34200b62df1
2026-06-12 08:45:22 -07:00
Yuval Tassa
a070535c65
Fix GCC -Wformat-truncation error in legacy log adapter
...
Widen snprintf buffer from 1024 to 2048 bytes in mju_defaultLogHandler
to avoid truncation warning when formatting "func: subject".
PiperOrigin-RevId: 930823501
Change-Id: I0b2246f23c44e983bea76976b684d2efdfdff29c
2026-06-11 17:23:43 -07:00
Yuval Tassa
58f6d52491
Introduce new logging API, fixes #858
...
PiperOrigin-RevId: 930744288
Change-Id: I6ec1203b55c031390f3eef23192e2337508ce886
2026-06-11 14:36:57 -07:00
Yuval Tassa
a2abaf7aef
Render perturbation box as a wireframe.
...
PiperOrigin-RevId: 930707140
Change-Id: Iab3577c8b45a235870f57001d38b6b1cd8acd170
2026-06-11 13:31:16 -07:00
Kyle Bayes
6957966c7d
Terminate early without contact in EPA if upper < lower on first iteration.
...
PiperOrigin-RevId: 929828707
Change-Id: Ide1106c14ae6eb003a9bbc238609b4bfdde221b0
2026-06-10 07:02:00 -07:00
Kyle Bayes
118baada7c
Remove engine threading fallback.
...
PiperOrigin-RevId: 929825049
Change-Id: Iff959f8d22ed082ff470c3eec426351964c2e89d
2026-06-10 06:54:19 -07:00
Kyle Bayes
2c5b8cae6c
Correct projected origin on face when the magnitude of face->v becomes very small in EPA.
...
PiperOrigin-RevId: 929768876
Change-Id: I5daf0203e998aa1489d9ce4c78cbf0764a8963e3
2026-06-10 04:48:18 -07:00
Adrian Collister
74d1459a4a
Enable contact sensors to work with Flex.
...
The sensor engine now correctly retrieves body IDs for contacts involving Flex elements by using mj_flexBody when a geom ID is -1. This allows contact sensors to detect and report forces/torques on bodies involved in Flex contacts.
PiperOrigin-RevId: 928607416
Change-Id: Ia815e1b3345bcfb393c9c4a829dc98959f2da50c
2026-06-08 09:31:42 -07:00
Yuval Tassa
828052e6f4
CG solver: Replace PRP+ with Hager-Zhang update
...
Replace the Polak-Ribière-Plus (PRP+) conjugate direction update with the Hager-Zhang formula in `mj_solPrimal`.
While this change has negligible effect under float64, it leads to a significant 17.5% throughput speedup over PRP+ under float32 (measured via `engine_cg_convergence_test`). This performance gain is driven by:
* A 9.4% reduction in CG iterations per step.
* A 12.1% reduction in line search evaluations per step.
The full output of the comparison is
```
================================================================
1/4: HZ + float64
================================================================
CG Convergence: 2humanoid100.xml
1000 Newton steps, 100 evaluation points
nv = 654, nq = 756
metric: ||qacc_cg - qacc_newton|| / ||qacc_newton||
Warmstart (tolerance = 0):
Iters | Mean Err | Max Err | Mean Iters | LS evals
-------+-------------+-------------+------------+---------
5 | 3.8532e-01 | 1.4285e+00 | 5.00 | 22368
10 | 2.0809e-01 | 9.9315e-01 | 10.00 | 44591
20 | 6.4977e-02 | 2.3410e-01 | 20.00 | 89417
40 | 5.2839e-03 | 2.1916e-02 | 40.00 | 180984
80 | 3.9709e-05 | 3.0010e-04 | 80.00 | 364241
160 | 3.2498e-09 | 3.5480e-08 | 160.00 | 730131
-------+-------------+-------------+------------+---------
No warmstart (tolerance = 0):
Iters | Mean Err | Max Err | Mean Iters | LS evals
-------+-------------+-------------+------------+---------
5 | 9.0740e-01 | 5.0045e+00 | 5.00 | 22123
10 | 3.9506e-01 | 2.1927e+00 | 10.00 | 44879
20 | 1.2496e-01 | 6.8911e-01 | 20.00 | 90341
40 | 1.2846e-02 | 6.9533e-02 | 40.00 | 182869
80 | 1.0288e-04 | 8.6457e-04 | 80.00 | 368312
160 | 5.9820e-09 | 5.0903e-08 | 160.00 | 738479
-------+-------------+-------------+------------+---------
Tolerance sweep (iterations = 100, warmstart):
Tol | Mean Err | Max Err | Mean Iters | Max Iters | Solver us | LS evals
-----------+-------------+-------------+------------+------------+-------------+---------
1e-04 | 1.1297e-02 | 8.9331e-02 | 34.88 | 51 | 131002.94 | 12052
1e-06 | 1.0907e-03 | 7.7468e-03 | 50.87 | 72 | 184172.44 | 16700
1e-08 | 1.1485e-04 | 1.0085e-03 | 66.82 | 91 | 232189.34 | 20194
1e-10 | 1.1357e-05 | 8.1547e-05 | 81.97 | 100 | 276114.42 | 23264
1e-12 | 3.7695e-06 | 2.8592e-05 | 90.47 | 100 | 299526.58 | 24964
0 | 3.5019e-06 | 2.8592e-05 | 100.00 | 100 | 2062208.36 | 456276
-----------+-------------+-------------+------------+------------+-------------+---------
Total solver time: 3185214.08 us, avg time per iter: 74.9445 us
Pipeline mode (consecutive mj_step, tolerance = 1e-8):
1000 steps, nv = 654
Steps/s : 380
us/step (total) : 2630.0
us/step (constr) : 2103.7 (80.0%)
CG iters/step : 63.28
LS evals/step : 190.75
us/iter : 33.24
================================================================
2/4: PRP+ + float64
================================================================
CG Convergence: 2humanoid100.xml
1000 Newton steps, 100 evaluation points
nv = 654, nq = 756
metric: ||qacc_cg - qacc_newton|| / ||qacc_newton||
Warmstart (tolerance = 0):
Iters | Mean Err | Max Err | Mean Iters | LS evals
-------+-------------+-------------+------------+---------
5 | 3.8533e-01 | 1.4285e+00 | 5.00 | 22228
10 | 2.0808e-01 | 9.9315e-01 | 10.00 | 44873
20 | 6.4978e-02 | 2.3410e-01 | 20.00 | 89349
40 | 5.2895e-03 | 2.1916e-02 | 40.00 | 179827
80 | 4.0188e-05 | 3.0010e-04 | 80.00 | 363740
160 | 3.2891e-09 | 3.5480e-08 | 160.00 | 733905
-------+-------------+-------------+------------+---------
No warmstart (tolerance = 0):
Iters | Mean Err | Max Err | Mean Iters | LS evals
-------+-------------+-------------+------------+---------
5 | 9.0740e-01 | 5.0045e+00 | 5.00 | 22590
10 | 3.9506e-01 | 2.1927e+00 | 10.00 | 45093
20 | 1.2496e-01 | 6.8911e-01 | 20.00 | 90393
40 | 1.2846e-02 | 6.9533e-02 | 40.00 | 182422
80 | 1.0288e-04 | 8.6457e-04 | 80.00 | 367264
160 | 5.9811e-09 | 5.0903e-08 | 160.00 | 739556
-------+-------------+-------------+------------+---------
Tolerance sweep (iterations = 100, warmstart):
Tol | Mean Err | Max Err | Mean Iters | Max Iters | Solver us | LS evals
-----------+-------------+-------------+------------+------------+-------------+---------
1e-04 | 1.1325e-02 | 8.9941e-02 | 34.95 | 52 | 129456.81 | 12060
1e-06 | 1.0910e-03 | 7.7469e-03 | 50.85 | 72 | 181004.51 | 16687
1e-08 | 1.1488e-04 | 1.0085e-03 | 66.83 | 91 | 228183.13 | 20189
1e-10 | 1.1401e-05 | 8.1547e-05 | 81.98 | 100 | 269635.40 | 23259
1e-12 | 3.8040e-06 | 2.8592e-05 | 90.52 | 100 | 293811.25 | 24967
0 | 3.5543e-06 | 2.8592e-05 | 100.00 | 100 | 2051927.47 | 456000
-----------+-------------+-------------+------------+------------+-------------+---------
Total solver time: 3154018.57 us, avg time per iter: 74.1895 us
Pipeline mode (consecutive mj_step, tolerance = 1e-8):
1000 steps, nv = 654
Steps/s : 382
us/step (total) : 2616.6
us/step (constr) : 2091.8 (79.9%)
CG iters/step : 63.57
LS evals/step : 193.35
us/iter : 32.91
================================================================
3/4: HZ + float32
================================================================
CG Convergence: 2humanoid100.xml
1000 Newton steps, 100 evaluation points
nv = 654, nq = 756
metric: ||qacc_cg - qacc_newton|| / ||qacc_newton||
Warmstart (tolerance = 0):
Iters | Mean Err | Max Err | Mean Iters | LS evals
-------+-------------+-------------+------------+---------
5 | 3.6748e-01 | 1.2281e+00 | 5.00 | 19239
10 | 2.0034e-01 | 6.8689e-01 | 10.00 | 39001
20 | 6.1972e-02 | 1.9859e-01 | 20.00 | 80112
40 | 4.0704e-03 | 1.5797e-02 | 40.00 | 168211
80 | 2.4380e-05 | 1.5803e-04 | 79.45 | 347735
160 | 7.7413e-07 | 4.4732e-06 | 157.27 | 704210
-------+-------------+-------------+------------+---------
No warmstart (tolerance = 0):
Iters | Mean Err | Max Err | Mean Iters | LS evals
-------+-------------+-------------+------------+---------
5 | 9.3385e-01 | 4.9648e+00 | 5.00 | 19272
10 | 3.6117e-01 | 1.9618e+00 | 10.00 | 37982
20 | 9.7490e-02 | 5.1451e-01 | 20.00 | 76502
40 | 9.5924e-03 | 5.5088e-02 | 40.00 | 162782
80 | 6.7689e-05 | 5.1113e-04 | 79.91 | 344281
160 | 1.5541e-06 | 7.6955e-06 | 157.30 | 697076
-------+-------------+-------------+------------+---------
Tolerance sweep (iterations = 100, warmstart):
Tol | Mean Err | Max Err | Mean Iters | Max Iters | Solver us | LS evals
-----------+-------------+-------------+------------+------------+-------------+---------
1e-04 | 1.5891e-02 | 1.2929e-01 | 32.56 | 50 | 136254.00 | 10980
1e-06 | 1.5719e-03 | 1.0990e-02 | 47.42 | 68 | 193566.00 | 15418
1e-08 | 1.6260e-04 | 1.0680e-03 | 62.70 | 86 | 252661.00 | 20162
1e-10 | 1.5664e-05 | 1.0999e-04 | 78.10 | 100 | 311535.00 | 24509
1e-12 | 2.8152e-06 | 1.5236e-05 | 90.39 | 100 | 356814.00 | 27902
0 | 2.4989e-06 | 1.5025e-05 | 99.05 | 100 | 1980580.00 | 436825
-----------+-------------+-------------+------------+------------+-------------+---------
Total solver time: 3231410.00 us, avg time per iter: 78.7726 us
Pipeline mode (consecutive mj_step, tolerance = 1e-8):
1000 steps, nv = 654
Steps/s : 349
us/step (total) : 2862.7
us/step (constr) : 2379.3 (83.1%)
CG iters/step : 61.97
LS evals/step : 199.01
us/iter : 38.39
================================================================
4/4: PRP+ + float32
================================================================
CG Convergence: 2humanoid100.xml
1000 Newton steps, 100 evaluation points
nv = 654, nq = 756
metric: ||qacc_cg - qacc_newton|| / ||qacc_newton||
Warmstart (tolerance = 0):
Iters | Mean Err | Max Err | Mean Iters | LS evals
-------+-------------+-------------+------------+---------
5 | 3.6753e-01 | 1.2281e+00 | 5.00 | 19052
10 | 2.0028e-01 | 6.8689e-01 | 10.00 | 38761
20 | 6.1737e-02 | 1.9863e-01 | 20.00 | 79937
40 | 4.0915e-03 | 1.5821e-02 | 39.99 | 168159
80 | 2.4360e-05 | 1.5808e-04 | 79.59 | 348385
160 | 7.8367e-07 | 4.1549e-06 | 157.04 | 700760
-------+-------------+-------------+------------+---------
No warmstart (tolerance = 0):
Iters | Mean Err | Max Err | Mean Iters | LS evals
-------+-------------+-------------+------------+---------
5 | 9.3385e-01 | 4.9648e+00 | 5.00 | 19494
10 | 3.6117e-01 | 1.9618e+00 | 10.00 | 38480
20 | 9.7485e-02 | 5.1451e-01 | 20.00 | 77213
40 | 9.5904e-03 | 5.5078e-02 | 40.00 | 162472
80 | 6.7647e-05 | 5.1087e-04 | 79.87 | 342990
160 | 1.4979e-06 | 7.2291e-06 | 157.92 | 699052
-------+-------------+-------------+------------+---------
Tolerance sweep (iterations = 100, warmstart):
Tol | Mean Err | Max Err | Mean Iters | Max Iters | Solver us | LS evals
-----------+-------------+-------------+------------+------------+-------------+---------
1e-04 | 1.5998e-02 | 1.3172e-01 | 32.49 | 50 | 135111.00 | 10953
1e-06 | 1.5878e-03 | 1.1052e-02 | 47.33 | 67 | 190914.00 | 15418
1e-08 | 1.5901e-04 | 1.0680e-03 | 62.65 | 84 | 250609.00 | 20215
1e-10 | 1.5953e-05 | 1.1116e-04 | 78.01 | 100 | 307067.00 | 24562
1e-12 | 2.8520e-06 | 1.5174e-05 | 90.27 | 100 | 353010.00 | 27931
0 | 2.5161e-06 | 1.5129e-05 | 99.39 | 100 | 1999478.00 | 438790
-----------+-------------+-------------+------------+------------+-------------+---------
Total solver time: 3236189.00 us, avg time per iter: 78.9045 us
Pipeline mode (consecutive mj_step, tolerance = 1e-8):
1000 steps, nv = 654
Steps/s : 298
us/step (total) : 3352.8
us/step (constr) : 2832.0 (84.5%)
CG iters/step : 68.43
LS evals/step : 226.33
us/iter : 41.39
```
PiperOrigin-RevId: 928590104
Change-Id: I1a96730f50f444d6141d8978feb3519009daf320
2026-06-08 08:54:07 -07:00
Kyle Bayes
ac7f198536
Tune constants for nativeccd to perform better with single precision.
...
PiperOrigin-RevId: 928549147
Change-Id: Ic28c60f73e92bb1b9578c56f790b6cda94875907
2026-06-08 07:21:17 -07:00
Kyle Bayes
318880126f
Provide better dedupe logic in multiccd in edge collision case.
...
PiperOrigin-RevId: 928519426
Change-Id: I67531d1c346b1b38c098eaf32c3b13fa7d0c8eaf
2026-06-08 06:07:31 -07:00
Yuval Tassa
6c33e16bf1
Canonicalize mjVisual macros to include type and dimension.
...
PiperOrigin-RevId: 928506110
Change-Id: If5d031f9d87892f13486ae9ccde23c16131212de
2026-06-08 05:30:57 -07:00
Haroon Qureshi
543165a6cc
Expose hsv2rgb as internally public function.
...
PiperOrigin-RevId: 928464175
Change-Id: I57ef75f28663b0da89b9af7bf730d82b965093bf
2026-06-08 03:44:50 -07:00
Haroon Qureshi
b17b5f7918
Expose mjv_flexBodyIdAndPoint as a helper function.
...
Use the above in studio rather than a custom implementation.
PiperOrigin-RevId: 928432476
Change-Id: I99d772c4baf7260abbf9ac8f6d8032704f1ba769
2026-06-08 02:28:39 -07:00
Kyle Bayes
558366f364
Always normalize in planeNormal to reduce rounding errors in single precision.
...
PiperOrigin-RevId: 926002329
Change-Id: I682f3b90249e60838c2432231b3181e57c565c28
2026-06-03 07:04:12 -07:00
Yuval Tassa
7b9b88060e
Refactor mj_fullM. This change is part of the deprecation of mjData.qM.
...
PiperOrigin-RevId: 925669464
Change-Id: I4889c66591bc1df4c31135a13776052aad491f7a
2026-06-02 17:22:55 -07:00
Kyle Bayes
3a5626bc27
Align GJK internal memory to avoid misalignment segfaults when compiled as single precision. This is effectively a no-op under double precision.
...
PiperOrigin-RevId: 925389982
Change-Id: I7117779669965ebf72cb77ccbece419acf9b1b96
2026-06-02 09:15:26 -07:00
Yuval Tassa
062b0f1ea6
Remove deprecated mju_{error,warning}_{i,s} functions.
...
PiperOrigin-RevId: 925204136
Change-Id: Ia877d08a135092db8037d04e6a237e81325a1d7c
2026-06-02 01:59:05 -07:00
Alessio Quaglino
91c92279d2
Enable interior nodes for interpolated flex shell mode.
...
Previously shell mode required cellcount=1 along at least one axis. This CL
adds support for cellcount > 1 in all three axes by pinning interior grid nodes
to the parent body and reconstructing their positions from boundary nodes via
Transfinite Interpolation (TFI).
PiperOrigin-RevId: 924314800
Change-Id: I8c2438f4866dd4133feed65f535a1ab69f0c9188
2026-05-31 10:36:01 -07:00
Yuval Tassa
4548e81e4d
Rename efc_diagApprox -> efc_diagA.
...
The field now stores either an approximate or exact diagonal of the constraint matrix A, so the name is made more general.
PiperOrigin-RevId: 924244954
Change-Id: I62b2f76531fb88b7b3bf96e6769940197596702b
2026-05-31 04:54:11 -07:00
Yuval Tassa
cd6db9ebe2
Improve CG solver precision and stability under float32 via line search refactor
...
Fixes #2313
This CL combines two complementary improvements to the Conjugate Gradient (CG) solver, significantly improving numerical precision, stability, and efficiency, particularly in single precision (float32).
1. Line Search Cost Evaluation Refactor: Previously, solver improvement was calculated by subtracting absolute costs: cost(alpha) - cost(0). In highly converged states or single precision, this is susceptible to catastrophic cancellation. We refactor PrimalSearch to compute the cost delta directly, dramatically improving precision.
2. Improved Solver Termination Condition: Near the float32 precision limit, line search deltas can occasionally be slightly negative due to numerical noise. Previously, any value below m->opt.tolerance (including negative values) triggered termination, halting the solver and locking in destabilizing steps. We update the termination condition to require positive improvement (0 < improvement < m->opt.tolerance), allowing the solver to continue iterating and recover stability.
Together, these changes yield substantial improvements, see reduced tolerances herein.
PiperOrigin-RevId: 924229669
Change-Id: Ic0bbefaed090f3a8b1e79ab8d45422c3e86fb56c
2026-05-31 04:00:09 -07:00
Yuval Tassa
3a6e0ee9b3
Reduce effect of infinite planes on center and extent statistics
...
PiperOrigin-RevId: 923868757
Change-Id: I3630d29f05a19e0767549284abbe8a8d9386894b
2026-05-30 04:12:07 -07:00
Yuval Tassa
96bf8aea81
Move island-specific sparse matrices from arena to stack.
...
PiperOrigin-RevId: 923850345
Change-Id: I9683d7554b15b7cd8c45a8dce7814640aa266452
2026-05-30 03:09:46 -07:00
Yuval Tassa
5d782a2bb8
Fix memory overallocation in sparse primal solvers.
...
PiperOrigin-RevId: 923586079
Change-Id: I8d484b840063c0a7a8a79c5bdc9074a57d2ee55f
2026-05-29 13:51:47 -07:00
Kyle Bayes
c7d340be4f
Cap box<->box collisions.
...
PiperOrigin-RevId: 923312868
Change-Id: I801d76cf1d1d7b9ed1535d3e3c723a5e8af4162a
2026-05-29 03:52:57 -07:00
Copybara-Service
46d2405b42
Merge pull request #3288 from davidhozic:fix/strchr-const-char
...
PiperOrigin-RevId: 923297843
Change-Id: I13b07c6cf0f611a8b3ee797dac94b35ce8d9deb4
2026-05-29 03:16:33 -07:00
Copybara-Service
9af965f241
Merge pull request #3120 from Ashutosh0x:fix/safe-overflow-msvc
...
PiperOrigin-RevId: 923296001
Change-Id: I037dcc55c91d6eb68b3e63b34a0e059c796b5116
2026-05-29 03:12:40 -07:00
Kyle Bayes
b612d352d4
Fix GitHub Actions for threading.
...
PiperOrigin-RevId: 922926969
Change-Id: I968e6b130b6125dbc0ec65ba913d04292270b563
2026-05-28 12:57:16 -07:00
Kyle Bayes
b935d4153c
Add new mju_threadpool API function, and delete old threading API.
...
PiperOrigin-RevId: 922838541
Change-Id: Id9f7e0fb298ffde61fcc49a802dc78971858ce51
2026-05-28 10:11:44 -07:00
Kyle Bayes
4035c66428
Fix multiccd edge bug that occurs in certain situations.
...
PiperOrigin-RevId: 922251109
Change-Id: I74c08ae49d5dfd2a41b2dcd28eb9f2b5ba113216
2026-05-27 11:32:45 -07:00
Alessio Quaglino
f6c85287bf
Optimize mj_flex performance.
...
Two performance optimizations for interpolated flex objects:
1. Hoist loop-invariant stride calculations in `mju_cellLookup` out of nested loops.
This reduces multiplications from 16 to 6 (linear) and 54 to 12 (quadratic)
per vertex.
2. Extract and consolidate optimized 3D interpolation logic into a new
reusable utility `mju_evalBasisArray` in `engine_util_misc.c`. This function
uses nested loops and precomputed 1D shape functions to avoid expensive
dynamic `phi` calls and branching, and leverages stack-buffered outputs to
eliminate compiler pointer-aliasing barriers. We propagate this optimization
to both kinematics (`mju_interpolate3D`) and constraint setup
(`engine_core_constraint.c`).
Together these changes yield a ~50% overall speedup in `mj_fwdKinematics` for interpolated flexes with ~10k vertices in the collision meshes and ~10 nodes in the deformation grid.
PiperOrigin-RevId: 922198093
Change-Id: I9c804e65cd532e2f9ac6e9a71d01c30cd64186fa
2026-05-27 10:05:30 -07:00
Ashutosh0x
0607dc450c
security: fix integer overflow in safeAddToBufferSize on MSVC
...
The MSVC fallback path in safeAddToBufferSize() performed unchecked
arithmetic (type_size*nr*nc) on attacker-controlled values read from
.mjb binary model files. This could cause integer overflow, leading
to an undersized heap allocation followed by a heap buffer overflow
when data is copied into the buffer.
The fix adds manual overflow detection using SIZE_MAX/INTPTR_MAX
comparisons, matching the behavior of the existing __builtin_*_overflow
path used on GCC/Clang.
Also adds a regression test that crafts a binary model buffer with
overflow-inducing size fields and asserts safe rejection.
2026-05-27 17:01:01 +05:30
Michael Moss
79aeceeaa3
Update MuJoCo version to 3.10.0 following the 3.9.0 release
...
PiperOrigin-RevId: 922027849
Change-Id: I52dd7fb5eeb962c2670ab5dbbe7ce192ac9332c5
2026-05-27 03:50:22 -07:00
Alessio Quaglino
f6cd0234fd
Change tactile sensor normal component to report penetration depth.
...
The normal component of the tactile sensor now reports the maximum penetration depth at each taxel, instead of a derived normal force. The depth is negated so that positive values indicate penetration.
PiperOrigin-RevId: 921980899
Change-Id: Ide4103c0aff465e25a81cfdda650f6a0e2da9e0b
2026-05-27 02:00:34 -07:00