Commit Graph

133 Commits

Author SHA1 Message Date
Sam Haves 1f1bfa9e4e Documentation pass for model editing, model encoding, and mjz.
PiperOrigin-RevId: 951665744
Change-Id: I1dfe3b40f451cca686431c263815039a9c38efc8
2026-07-21 13:27:00 -07:00
Yuval Tassa a04b0c5b97 Add boolean flags for gravity compensation and surface velocity in mjModel.
These fields (`flg_gravcomp` and `flg_surfacevel`) replace the fast-path checks originally guarded by `ngravcomp` and (recently) `nsurfacevel`. Since the engine uses these integers only as flags (zero vs non-zero), migrating them to actual booleans makes them writeable from the Python bindings at runtime without violating size/dimension constraints.

The legacy integer field `ngravcomp` is marked as deprecated and will be removed in a future release.

PiperOrigin-RevId: 949779204
Change-Id: Ifab1f026063a4239302e6ad689663b611b59dda8
2026-07-17 15:05:26 -07:00
Yuval Tassa 4787c8094c Add geom surfacevel: zero-dof conveyors, treadmills and turntables.
https://www.youtube.com/watch?v=PdSdrqhSiZA

The new geom attribute surfacevel (6 numbers: linear and angular velocity in the geom's local frame, angular about the geom frame origin) specifies the velocity of the geom's surface material relative to the geom frame. The relative surface velocity of the two geoms is added to the tangential contact rows of efc_vel in mj_referenceConstraint, so friction drives touching bodies toward the motion of the surface: objects on a conveyor are transported at belt speed, turntables impart omega x r with torsional spin-up for condim >= 4, and surface velocities compose with each other and with body motion. The component along the contact normal is projected out: probe experiments showed that velocity-space emission chatters mass-independently and ingestion merely deepens penetration; normal-direction effects belong to force-space features.

surfacevel is interpreted in the geom frame as authored: for mesh geoms, whose compiled frame absorbs the mesh centering and principal-axes transform, the compiler re-expresses the authored value in the compiled frame.

No special interaction with sleeping: objects being transported do not fall asleep because they are moving; objects at rest on an active surface may sleep like any other resting object.

Includes showcase models (model/surfacevel/): a luggage carousel whose ring is a spinning square-profile supertorus fed by a cascade of belts with matched spinning end rollers, bags dropping in and circulating indefinitely; and a treadmill with a passive humanoid.

PiperOrigin-RevId: 948647785
Change-Id: I0c6559a91cc7ece1237eb8ac2e51986e7342d962
2026-07-15 17:58:17 -07:00
Copybara-Service 97eb1e5d0c Merge pull request #3403 from rkothari3:docs-simulate-shortcuts
PiperOrigin-RevId: 948571230
Change-Id: Ibbd151e9f2143c3e41cda1b6ee4873f088595084
2026-07-15 15:14:29 -07:00
Haroon Qureshi 1e85ce176f Migrate filament header documentation to docs.
PiperOrigin-RevId: 948294877
Change-Id: I6e110bbdc4d2e329a243f1b96d560698174de26b
2026-07-15 06:14:40 -07:00
Yuval Tassa c69ef03083 Add zero-iteration early exit to the primal solvers, certified by the duality gap.
The primal cost has curvature of at least M in every zone, making it strongly
convex in the M-norm and bounding the suboptimality of any point by the
Fenchel duality gap at its constraint forces:

  cost(qacc) - cost* <= 0.5*grad'*M^-1*grad

Since M's factorization always exists, this certificate is evaluable before
the solver does any work: one triangular solve and one dot product. When the
warmstarted solution is already certified to satisfy the tolerance, CG and
Newton now return with zero iterations; for Newton this skips building and
factorizing the Hessian. If the certificate declines, Newton gets a second
exit after factorization: the Newton decrement, checked before the first
line search.

Because the gap bounds cost suboptimality, stiff constraints can convert it
into force errors of order sqrt(2*gap*stiffness). Newton solutions are
characteristically force-accurate, so Newton zero-iteration exits also
require the gradient criterion, preserving constraint-force accuracy at
rest; CG solutions are characteristically cost-accurate and exit on the gap
alone.

On a settling pile of 50 boxes (300 dofs, ~200 contacts), end-to-end time
per step drops 13% over a settle-then-rest run and 27% in the quiescent
limit, with Newton iterations falling from 0.98 to 0.40 per step.

Tests: WarmstartZeroIterations sweeps solver/cone/jacobian on a settled box,
asserting zero iterations, forward/inverse consistency, and agreement with a
tolerance=0 control solve from the same state. WarmstartZeroIterationsIslands
checks per-island exits with a kicked box next to a settled one.
RefsiteConservesMomentum now requests an exact solve (tolerance=0), since it
asserts momentum conservation tighter than the solver tolerance contract.
PiperOrigin-RevId: 947993735
Change-Id: I2fd855774bff619709b2c386f1ba2714286e0821
2026-07-14 17:24:08 -07:00
rkothari3 2fe87a4833 docs: add full keyboard and mouse shortcut reference for simulate
The F1 overlay lists only the most common commands, and there was no
complete shortcut list anywhere in the docs. Add one to the simulate
section, derived from the shortcut declarations in simulate.cc,
simulate.h, mjVISSTRING and mjRNDSTRING.

Fixes #3306
2026-07-14 14:01:25 -04:00
Yuval Tassa e6452e2c88 Rename testspeed argument npoolthread to nenginethread.
PiperOrigin-RevId: 945698744
Change-Id: Ida6d5ab24c88441fb05c778e8507d6369eb74f1c
2026-07-10 07:19:21 -07:00
Yuval Tassa 38f0ff3caa Improvements to testspeed
Support named CLI flags, physics overrides, and refactor global state.

  - **Named CLI Flags**: Replaced standard positional arguments with named flags (`--nstep`, `--nthread`, `--noisestd`, `--noiserate`, `--npoolthread`) and preserved Google-wide flags compatibility (via custom argv compacting and InitGoogle).
  - **Physics Option Overrides**: Added support for configuring loaded model settings directly from the command line (`--solver`, `--cone`, `--jacobian`, `--integrator`, `--iterations`, `--tolerance`, `--sleep_tolerance`, `--noslip_iterations`).
  - **Encapsulated Thread State**: Consolidated loose global variables and per-thread rollout statistics arrays into a single data structure, `RolloutRunner runner`, simplifying mutli-threaded data boundaries.
  - **Readable Physics Options Printing**: Logged configured non-default options dynamically prior to rollout. Enums and active bitmask flags (e.g. disableflags/enableflags) are decoded into friendly strings (e.g., `Sleep : Enabled`).
  - **Tests & Docs**: Added testspeed_test.sh running testspeed over dominos.xml to check all overrides, registered shell test target in BUILD and CMakeLists.txt, and updated samples.rst documentation.

PiperOrigin-RevId: 942285912
Change-Id: Idb966fadfa0ccba0f1862f9d62bf83458b61939a
2026-07-03 16:52:40 -07:00
Haroon Qureshi d93c102190 Move mjrfilament.h to mujoco/include.
PiperOrigin-RevId: 934931460
Change-Id: I63bf34b3a7197b277ea7a5caf3d84d840f6210a1
2026-06-19 08:01:05 -07:00
Yuval Tassa 410c73168c Add policies for global attribute conflict resolution upon attach
For example when loading parent_merge.xml:

```
WARNING: Attach conflict when attaching 'child' to 'parent_merge', policy is 'merge'
timestep: parent has 0.005, child has 0.002, taking the minimum
iterations: parent has 50, child has 100, taking the maximum
flag 'Damper': added from child
```

When loading parent_error.xml:

```
XML Error: Attach conflict when attaching 'child' to 'parent_error', policy is 'error'
timestep: parent has 0.005, child has 0.002
iterations: parent has 50, child has 100
Element 'attach', line 10
```
PiperOrigin-RevId: 933620810
Change-Id: Ib477863b5ef763474d27fb4be5a4148be1d5d500
2026-06-17 03:36:10 -07:00
Yuval Tassa 55d7ff49ec Fix broken link in docs.
PiperOrigin-RevId: 933054777
Change-Id: Ic862992051200bff1b742025926961a7c2087ffa
2026-06-16 06:24:16 -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
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
Google DeepMind af4be63cd8 Add xmacros for MjSpec.
PiperOrigin-RevId: 922169069
Change-Id: I01426596e49196996dfa324d5ab3849a90de2e3a
2026-05-27 09:12:35 -07:00
Yuval Tassa 7667e7110e Introduce mjtBool for boolean types.
PiperOrigin-RevId: 920201340
Change-Id: I3b19c11a00357e06a1df08b8819832955c37f9ff
2026-05-23 09:13:54 -07:00
Yuval Tassa 15d27b363f Compile-time size assertions for MuJoCo basic types
PiperOrigin-RevId: 919107499
Change-Id: I07fcba4f33c77a2a1e68528dba6d399af94d0220
2026-05-21 09:55:04 -07:00
Yuval Tassa 88a293b5e4 Update docs to correctly reference mjtype.h
PiperOrigin-RevId: 919071817
Change-Id: I829de7a22a49e6df604b0acf601a13f67ef5fbab
2026-05-21 08:44:11 -07:00
Yuval Tassa 2810edd27a Rename mjtnum.h to mjtype.h, move enum types to mjtype.h
PiperOrigin-RevId: 919020039
Change-Id: I441295c0baa0b7456f78239fbd5478d32ffc07c1
2026-05-21 06:43:29 -07:00
Yuval Tassa bdf00966f9 Add compiler timing diagnostics to mjsCompiler, printed by compile.cc
For example, `compile mujoco_menagerie/robotis_op3/scene.xml` now outputs

```
Compile 1 (cold cache):
  total:      317.2 ms
  assets:     284.8 ms (wall clock)
    load:     616.1 ms
    hull:      26.4 ms
    poly:     137.8 ms
    inert:    177.8 ms
    bvh:      568.2 ms
    octr:       1.6 ms
    tex:       25.3 ms
  other:       32.4 ms

Compile 2 (warm cache):
  total:       79.9 ms
  assets:      54.5 ms (wall clock)
    load:     888.5 ms
    hull:       0.0 ms
    poly:       0.0 ms
    inert:      0.0 ms
    bvh:        0.0 ms
    octr:       0.0 ms
    tex:       21.4 ms
  other:       25.3 ms
```

PiperOrigin-RevId: 917850214
Change-Id: Iaec86230bec0faf2e47820e20cbff61de5b2621e
2026-05-19 08:28:47 -07:00
Yuval Tassa f712eed4ce Allow flex sleeping
PiperOrigin-RevId: 917817500
Change-Id: Ia3bd5e52e7c2eaa3f70c81352d82c130b1d357f6
2026-05-19 07:15:27 -07:00
Michael Moss 2f5e5d3da1 Add documentation for mjpDecoder.
PiperOrigin-RevId: 905048609
Change-Id: I6342673cdc53b80406ad77fc95cb8bb5790a5df6
2026-04-24 08:38:31 -07:00
Yuval Tassa 6bf31cf68a Update Windows build notes.
PiperOrigin-RevId: 902480947
Change-Id: I69f099b3d7eabd6513a62e74e5ef697a5062e7b5
2026-04-20 01:13:17 -07:00
Yuval Tassa 239aa1f856 Minor updates to documentation across multiple sections.
PiperOrigin-RevId: 898652783
Change-Id: Idb671910c18ed3406722b8a1307f97ae9a194139
2026-04-13 10:54:28 -07:00
Sam Haves f2461f9ce6 Modify mj_PLUGIN_LIB_INIT to support multiple plugins in the same compilation unit.
Previously on MSVC we used DllMain to register plugins, you cannot have multiple definitions of DllMain in a single unit so you would get errors if you tried to register two plugins. This modifies the implementation to insert a function pointer into the C runtime initialization instead.

PiperOrigin-RevId: 896612678
Change-Id: I07732147b955d741c836acff6da986db0e9b9eff
2026-04-08 11:35:16 -07:00
Yuval Tassa 0c66585e39 Fix typos and minor corrections in MuJoCo documentation and comments.
PiperOrigin-RevId: 875163889
Change-Id: Ic604d6235bf9cb999058f191e3ee41e47ec1a567
2026-02-25 07:56:31 -08:00
Yuval Tassa 40e0007849 Restructure numeric constants table in API docs
Break the monolithic numeric constants table into 6 sub-grouped tables:
Version, Engine constants, Array sizes, Visualization, Rendering, UI constants.

Fix stale values: mjMAXUITEXT (500->300), mjMAXUIMULTI (20->35),
mjMAXUIEDIT (5->7), mjMAXUIRECT (15->25).

Add missing constants: mjMAXLIGHT, mjMAXMATERIAL.

Fix placeholder description for mjMAXFLEXNODES.

PiperOrigin-RevId: 875010581
Change-Id: Id47846de4d98b62cb96087b72ecd28358d5db9c7
2026-02-25 00:54:35 -08:00
Yuval Tassa c54f1fe380 Use semantic versioning.
PiperOrigin-RevId: 869102767
Change-Id: I8b01b9343289d4ad7d15bcc3634a28e661308a90
2026-02-12 02:11:20 -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
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
Yuval Tassa 775c0698c3 MJCF schema: use responsive grids for attributes
PiperOrigin-RevId: 853263519
Change-Id: I79cb6e6208061d9546f0dca7a941838caa6b1a91
2026-01-07 08:00:16 -08:00
Yuval Tassa 4830f5a79e Add missing documentation for the asset cache.
Also improve `compile` sample timing logic and documentation.

PiperOrigin-RevId: 852855741
Change-Id: I9b2798208198ca68cf4cee9c968772954ada91c5
2026-01-06 11:07:42 -08:00
Yuval Tassa 3868ed0382 Improve XML schema usability
PiperOrigin-RevId: 852820889
Change-Id: I04eea45161f9e71f9ccf49afad57ff28fd099b35
2026-01-06 09:51:36 -08:00
Yuval Tassa b77977a962 Update Programming/simulation chapter.
PiperOrigin-RevId: 847424298
Change-Id: Icc6efb05dee5e67a5813ed04caa15a5703e59aee
2025-12-21 08:16:39 -08:00
Yuval Tassa 4896e698f6 Update "mjModel changes" section in simulation.rst
PiperOrigin-RevId: 838768328
Change-Id: I5c09186e52115df37e9412495ecc7dceddb2ed8a
2025-12-01 07:40:09 -08:00
Alessio Quaglino a0cb97eb4d Improve attach docs.
PiperOrigin-RevId: 834366494
Change-Id: I9086097990f09e848d0b76d9c22f4fd2bbd70718
2025-11-19 11:08:36 -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
Yuval Tassa 8734cab366 Add sleeping documentation
https://youtu.be/vct493lGQ8Q

PiperOrigin-RevId: 829390353
Change-Id: I92f85a03be0bb585d2d8e29de1ed1a2e848f247f
2025-11-07 05:12:42 -08:00
Taylor Howell 53360f51a9 Update .readthedocs.yml to install MuJoCo Warp in order to generate API documentation. Additionally, mirror mujoco_warp/pyproject.toml in mjx/mujoco/mjx/third_party/mujoco_warp.
PiperOrigin-RevId: 814656860
Change-Id: Ie4c0e9076c90b598dedc65a3e9793ed3d2375c37
2025-10-03 05:39:45 -07:00
Michiel Blokzijl ee777f74d3 Explain how to build Python and C/C++ sources from the same codebase.
The previous instructions use a pre-built binary from MuJoCo and do not cover
the use-case of building C/C++ and Python bindings from the same codebase.

PiperOrigin-RevId: 802060401
Change-Id: I6d0b9c7c2269ff596ac706b716ff6c95b42c5d99
2025-09-02 02:51:49 -07:00
Yuval Tassa 243c011ea0 Add note about performance and release builds.
PiperOrigin-RevId: 781460349
Change-Id: I7defa9bf31376afa31b32f26523e8ebd9da3fc0e
2025-07-10 03:40:25 -07:00
Yuval Tassa 18d5d5d03f Improve documentation related to mjSpec element deletion.
PiperOrigin-RevId: 775677830
Change-Id: I02e51b57956b0b6a20c654326b54e001b498dd96
2025-06-25 07:23:51 -07:00
Taylor Howell de3dc7c234 Update documentation from mjData.solver_iter to mjData.solver_niter.
PiperOrigin-RevId: 763729137
Change-Id: I1266539ead38e083d427614d50b2aa79a68aa09c
2025-05-27 04:25:54 -07:00
Paweł Budzianowski c3e71a3fb1 Update simulation.rst 2025-05-06 16:46:46 -07:00
Alessio Quaglino a02a27d4a4 Combine all mjs_attach functions into one.
PiperOrigin-RevId: 742702092
Change-Id: I89e35c59ada017cd061e2031584eeea71776743d
2025-04-01 08:05:58 -07:00
Alessio Quaglino 019e0a806c Throw an error if a child attached by reference to a parent is compiled.
Fixes #2482.

PiperOrigin-RevId: 735665098
Change-Id: Ia3436fdd2ff572f8f0c1ded434742a4a9186f2f7
2025-03-11 01:24:17 -07:00
Kyle Bayes ed16f2daf2 Set nativeccd as default.
PiperOrigin-RevId: 731343200
Change-Id: I315779017b676f3d118e0d38ee53a515272f50b8
2025-02-26 09:15:15 -08:00
Yuval Tassa f554b38c36 Fix syntax bug in simulation.rst
PiperOrigin-RevId: 729710215
Change-Id: I49899ed50d5e97a2c5ad35e5de2e93186b7c64ec
2025-02-21 17:28:59 -08:00
Yuval Tassa fb07e0d1f7 Convert qLD to CSR format.
PiperOrigin-RevId: 728196818
Change-Id: I31bdf32e251293284426ed345019f27fd051a0e1
2025-02-18 07:14:45 -08:00
Yuval Tassa f73f0e1d0d Fix aspect ratios of embedded videos in docs.
Note that small videos, for some reason, need an aspect ratio that is different  from the actual aspect ratio.

PiperOrigin-RevId: 724879307
Change-Id: I681f071baf4eb09cfda41edeca0d1ee16be4181a
2025-02-09 03:33:10 -08:00