Commit Graph

862 Commits

Author SHA1 Message Date
Sam Haves f5d3ce3451 Introduce mjpEncoder plugin architecture
Add a new mjpEncoder plugin type mirroring the existing mjpDecoder pattern.
Encoders serialize an mjSpec + mjModel to an mjResource for a given format.

New API functions:
- mjp_registerEncoder: globally register an encoder
- mjp_defaultEncoder: zero-initialize an encoder struct
- mjp_findEncoder: look up an encoder by filename extension or content type

The mjfEncode callback takes (mjSpec*, mjModel*, mjVFS*, mjResource*) and
returns 0 on success. Writing to mjResource keeps symmetry with the decoder
reading from mjResource and leaves the door open for writable resource providers.

PiperOrigin-RevId: 889187898
Change-Id: I180771b2255b91dea188ac5e2cdc3a8f0fb85364
2026-03-25 05:35:39 -07:00
Alessio Quaglino f4e3469239 Add test for geom and mesh plugin attributes.
This test verifies that geom.plugin and mesh.plugin are accessible and can be assigned a plugin instance.

PiperOrigin-RevId: 888576511
Change-Id: Id17885de5fdf1f4543ac195a8b04bb01139d1bfa
2026-03-24 03:59:35 -07:00
Michael Moss 5664b9e89e Update pybind to 3.0.2.
PiperOrigin-RevId: 887980078
Change-Id: I2eb5284e878180293553e20c94dae853c380805c
2026-03-23 02:44:19 -07:00
Yuval Tassa 510d75f4cf Allow actuators to add damping and armature to joint and tendon transmissions.
PiperOrigin-RevId: 886899849
Change-Id: I02200ee0d4f7c96096d8188b95f823b566562a30
2026-03-20 11:41:15 -07:00
Michael Moss 02d1d3d503 Fix call_guard usage inside .def_property calls.
See also [PR #5533](https://github.com/pybind/pybind11/pull/5533).

PiperOrigin-RevId: 886714838
Change-Id: I8c98461098ccf4958fb18bdcb5acc293c988c258
2026-03-20 04:50:50 -07:00
Alessio Quaglino e57d95e68f Remove vertcollide attribute from flex contact.
The `vertcollide` attribute in flex and flexcomp contact specifications has been removed since the next mjWarp release will support flex collisions. This attribute was previously used to enable vertex-based collisions by adding sphere geoms at flex vertices. The functionality associated with this attribute has been deprecated and removed from the XML parser, documentation, and internal data structures. Affected example XML files have also been updated.

PiperOrigin-RevId: 885595503
Change-Id: I6a78975f1bc540c09ea8b5306ff3be0962b7ab24
2026-03-18 07:59:57 -07:00
Tom Erez 60be42e83c Replace autowrap C# binding generator with introspect-based codegen.
This CL replaces the header-parsing autowrap system for generating
MuJoCo C# bindings (MjBindings.cs) with a new generator that uses
the mujoco.introspect module. The new generator reads pre-parsed
API data from introspect's enums, functions, and structs modules
instead of parsing C headers directly.

Changes:
- New: generate_cs_bindings.py in third_party/py/mujoco/codegen/
- Updated: genrule in unity/mujoco/BUILD to use codegen
- Updated: MjBindings.cs regenerated from codegen
- Removed: entire autowrap/ directory (9 files)
- Removed: transitional validate_codegen.py

The validate test continues to verify that the genrule output
matches the checked-in MjBindings.cs.

PiperOrigin-RevId: 885206129
Change-Id: Ib9fb883a2242dd2c039033eadee7a4a6ac91ed55
2026-03-17 14:19:49 -07:00
Yuval Tassa efae9157a7 Polynomial stiffness and damping https://youtu.be/aKa3ZlEF9_Y
PiperOrigin-RevId: 884607673
Change-Id: If8088dbf37fed1055304778a7eb84dec52cba920
2026-03-16 13:25:25 -07:00
Yuval Tassa 50dfc255b8 Fix pybind11 v3.0 compatibility in callbacks.cc
PiperOrigin-RevId: 884074529
Change-Id: I20e7a8d6f6069895afbc3e18d0612f3b2edfaeb7
2026-03-15 12:46:11 -07:00
Copybara-Service 910fbbb111 Merge pull request #3141 from ocadotechnology:recompile-release-gil
PiperOrigin-RevId: 883109831
Change-Id: I75c22ec071aae8f78b8354de40d8f58e8e952a50
2026-03-13 05:25:45 -07:00
Haroon Qureshi 7f437810fd Move MjrRect pybind11 definition to structs.cc.
mjrRect is a common type that will be re-used across different
rendering APIs, not just mjr_ APIs.

PiperOrigin-RevId: 882620060
Change-Id: I7f77ac9298c52c454d94c46379ff5270fd833f26
2026-03-12 09:00:39 -07:00
Michael Moss 6d70e66810 Update MuJoCo version from 3.6.0 to 3.7.0 following the 3.6.0 release
PiperOrigin-RevId: 881995135
Change-Id: I0c1a3b4a22c4c7cfada580b49a2cacde64cc84f3
2026-03-11 07:09:24 -07:00
Kyle Bayes acf7f030a6 Remove const qualifier from mjData in mj_geomDistance. The function mj_geomDistance will require data stack space as nativeccd memory is determined from opt.ccd_iterations.
PiperOrigin-RevId: 881946592
Change-Id: I524b9fa41018a581e58647d44de6ca3db4c6608b
2026-03-11 04:55:44 -07:00
Sam Haves 6890e133c0 Add mjs_getCompiler C API and compiler property to Python spec elements.
PiperOrigin-RevId: 881488083
Change-Id: I3aa1c0562bf2fd27057b8056048e3156fc1b067c
2026-03-10 09:57:36 -07:00
robin.moss 0c9083723c fix: release the gil when calling compile in spec.recompile
The pybind for recompile was not releasing the GIL when it called mj_recompile, this can caused deadlocks with the
asset loading threads. For example if a resource provider was trying to call Python.

To resolve this the GIL is release just for the mj_recompile.

Addresses: https://github.com/google-deepmind/mujoco/issues/3118
2026-03-10 15:44:01 +00:00
Michael Moss 955d6c0b02 Update MuJoCo version from 3.5.1 to 3.6.0 prior to next release.
The next release will include breaking changes, so this bumps the major
version to reflect that.

PiperOrigin-RevId: 881351265
Change-Id: I970c68a0211651c07fcb8109ebd0b138196cf50a
2026-03-10 04:30:07 -07:00
Alessio Quaglino 713b5524bc Introduces a new "strain" equality mode (flex_edgeequality = 3) for flexcomps with trilinear interpolation. This mode enforces constraints on the three invariants of the Green-Lagrange strain tensor at 8 Gauss quadrature points within each flex element, resulting in 24 equality constraints per flexcomp.
Also fixes a bug when attaching a flex with constraints.

PiperOrigin-RevId: 881349765
Change-Id: I8e6df8239488bfdc87d7e5b473568975e38c737e
2026-03-10 04:26:07 -07:00
Haroon Qureshi fe6c81ed93 Internal changes.
PiperOrigin-RevId: 881291880
Change-Id: I9b43470802651b823507ee2691ba5216126d72ab
2026-03-10 01:56:10 -07:00
Copybara-Service b129248be4 Merge pull request #3142 from kevinzakka:simulate-fix
PiperOrigin-RevId: 878575288
Change-Id: Ib3f820d84b0b9bfa25141e4360ddc339abbf0d50
2026-03-04 11:09:19 -08:00
Sam Haves 91d3565cd5 Move OBJ handling to a mjpDecoder.
PiperOrigin-RevId: 878041994
Change-Id: I6e7f6876e65fd2184ff5637d4268644cefcabecf
2026-03-03 11:22:02 -08:00
Kevin Zakka 327f05a567 Fix macOS crash on viewer close (NSScreen main-thread assertion)
Hiding the dock icon after the viewer window closes triggers an
asynchronous screen/dock reconfiguration via SkyLight. Without
draining the main run loop, the resulting NSScreen invalidation
notification is dispatched to a GCD worker thread, which hits
NSScreen's main-thread assertion and crashes the process.

Drain the main NSRunLoop briefly after setActivationPolicy: so the
reconfiguration is processed on the main thread.
2026-03-02 12:48:38 -08:00
Kevin Zakka 6f52631a2a Fix process hang on viewer close in launch_passive
WaitForAtomicNoGil spins until the render loop consumes a pending
set_texts/set_figures/set_images request (atomic == expected). If the
user closes the viewer window after a request is submitted but before
the render loop consumes it, the render loop exits and the atomic is
never updated. The calling thread spins forever, preventing the
process from terminating.

Check exitrequest inside the spin loop so the wait bails out once the
viewer is shutting down.
2026-03-02 12:21:34 -08:00
Sam Haves 0ec836b281 Rollback of Move OBJ handling to a mjpDecoder.
PiperOrigin-RevId: 875705083
Change-Id: I21403d84abd56ef72de915bddc724fe3efa506e6
2026-02-26 07:04:39 -08:00
Sam Haves b907ffedaa Move OBJ handling to a mjpDecoder.
PiperOrigin-RevId: 875194599
Change-Id: I2cccc683d69a217f1817e70d16bc1815e366d00c
2026-02-25 09:13:09 -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
Michael Moss a043df6bdf Update supported Python versions and remove obsolete 3.9 references.
PiperOrigin-RevId: 874063785
Change-Id: Ia4b2956b632aae5f0211fa766b6d413edcba8fe2
2026-02-23 07:29:47 -08:00
Copybara-Service 7d3e1abb21 Merge pull request #3083 from Ashutosh0x:fix/mingw-linker-stack
PiperOrigin-RevId: 871828475
Change-Id: I8abe526a81b9c1f51307729b5dde01aad809ff97
2026-02-18 05:59:41 -08:00
ashutosh0x 50349dc685 Fix MinGW stack flag syntax and Python binding crashes
- Detect linker type (lld-link vs ld) and use the appropriate stack flag: /STACK:16777216 for lld-link, --stack,16777216 for MinGW ld

- Filter out stack-related flags from Python binding modules to prevent crashes when loading MuJoCo as a DLL in Python

Fixes #3011
2026-02-18 14:22:59 +05:30
Sam Haves 448e221690 Raise ValueError if adding a spec results in a duplicate name.
PiperOrigin-RevId: 871397807
Change-Id: I50742efe7ba194ed3b1fe916f05e35b7fb2d7ec0
2026-02-17 10:54:47 -08:00
Haroon Qureshi 8f2799a34b Move renderer.py and gl_context.py into a submodule.
PiperOrigin-RevId: 870789311
Change-Id: Iaa0fcc764a770eeb4570a6a189a5ad032d41d64c
2026-02-16 02:41:35 -08:00
Saran Tunyasuvunakool 2efca34f58 Fix mjpython after breakage from 496f6b47fc.
PiperOrigin-RevId: 870253531
Change-Id: Icfbfaed41d4cdd3f8472c37a254cb7b1f2a32d7b
2026-02-14 14:32:42 -08:00
Saran Tunyasuvunakool 5274e5f720 Clean up X macros and usages for mjOption, mjStatistic, and mjVisual.
* Replace various MJOPTION_ macros with a single MJOPTION_FIELDS.
* Use XVEC macro to denote vector members where there is a mixture of
  vector and scalar members in a given struct type.
* Split up MJVISUAL_FIELDS into separate macros for each substruct.
* Modify engine_print.c and Python bindings struct.h/cc to use the
  new X macros.

PiperOrigin-RevId: 869760513
Change-Id: Idac4fe9aa99f0258e7c79802ca9023a0d4486e2d
2026-02-13 09:10:36 -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
Michael Moss 42958aab81 Update MuJoCo version from 3.5.0 to 3.5.1 following the 3.5.0 release
PiperOrigin-RevId: 869654894
Change-Id: I9cacaf4cbb70ad17faa24c3c30ec38ffe91b5deb
2026-02-13 03:54:25 -08:00
Saran Tunyasuvunakool 496f6b47fc In mjpython, check the result of Py_InitializeFromConfig.
This is to properly handle the case where the interpreter wants to exit immediately, e.g. when `mjpython --version` is run.

Currently, we call `PyGILState_Ensure` regardless of the result of `Py_InitializeFromConfig` resulting in a segfault, as in issue #2870.

PiperOrigin-RevId: 869652555
Change-Id: I3a898279eb8aa25afbaece904cfdcc4fdcc92972
2026-02-13 03:44:58 -08:00
Michael Moss 716ae107c6 Update dependencies and changelog ahead of the 3.5.0 release.
PiperOrigin-RevId: 869221912
Change-Id: I77aa1f898009c5d24218434863d0588ddf8a058b
2026-02-12 08:08:14 -08:00
Yuval Tassa a8cf4e012d Add Colab link for System Identification toolbox.
PiperOrigin-RevId: 869091889
Change-Id: Ib5ec2e451c7037cc92b4cb1a9c58d05f0049b298
2026-02-12 01:41:40 -08:00
Kevin Zakka 2396a2541c Copybara import of the project:
--
4cabc9c52dc07ea2d64a3de6dbd58e47a2ad023c by Kevin Zakka <kevinarmandzakka@gmail.com>:

Add system identification tutorial and fix template packaging

- Add sysid tutorial notebook (sysid.ipynb)
- Include HTML templates in package-data to fix TemplateNotFound errors
  when pip installing mujoco[sysid]

COPYBARA_INTEGRATE_REVIEW=https://github.com/google-deepmind/mujoco/pull/3092 from kevinzakka:sysid-notebook 4cabc9c52dc07ea2d64a3de6dbd58e47a2ad023c
PiperOrigin-RevId: 868900119
Change-Id: I53c4cc94b5fb6f864c5cee589af9dfad9bfc8744
2026-02-11 16:43:08 -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
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
Adrian Collister d881e9e374 Change tex_adr type to mjtSize.
Adds a test which verifies that we can index into the texture buffer at offsets larger than can be represented by a 32-bit signed int.

PiperOrigin-RevId: 868756646
Change-Id: Ibc1a2b269fce41aec370611b0aab77803837e7a8
2026-02-11 11:09:36 -08:00
Google DeepMind cc5d544d15 Update typos in sysid/README.md
PiperOrigin-RevId: 868690171
Change-Id: Iffc71fb7bad73e18be767429600936014095ed9e
2026-02-11 08:25:56 -08:00
Copybara-Service 91751a506b Merge pull request #3082 from aftersomemath:sysid-pr2
PiperOrigin-RevId: 868599752
Change-Id: Ifb57f34857d542b542b8ac9f047397c651f8008b
2026-02-11 04:06:44 -08:00
Levi Burner e89dae359e sysid: named ic construction, bug fixes, docstrings, README, more tests
Co-authored-by: Kevin Zakka <kevinarmandzakka@gmail.com>
2026-02-11 00:22:56 -05:00
Sam Haves 6715a0ceaa Expose mju resource functions to public header.
Many of these functions are useful when writing a custom decoder.

PiperOrigin-RevId: 868321921
Change-Id: I7e0dd285e0559b6f486acf8cbf4376ff8d91943d
2026-02-10 14:31:41 -08:00
Copybara-Service 3ec09f7296 Merge pull request #3079 from aftersomemath:sysid-pr
PiperOrigin-RevId: 868229512
Change-Id: I790bc08fc8b0745583a2f92d9ee2c5a19ba558ea
2026-02-10 11:04:12 -08:00
Yuval Tassa 4fa062c7e5 Update unreleased MuJoCo version from 3.4.1 to 3.5.0.
PiperOrigin-RevId: 868169291
Change-Id: I8041842811f5f664c80116993315f50d549b5575
2026-02-10 08:52:04 -08:00
Kevin Zakka 146a5c08f7 System identification toolbox for MuJoCo.
This resulted from a lengthy collaboration with @kevinzakka, @jonathanembleyriches, @nimrod-gileadi, @gizemozd, @quagla, and @yuval.
2026-02-09 12:12:24 -05: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
Taylor Howell 1381e8adee Add mjMINAWAKE to constants.cc
PiperOrigin-RevId: 862784740
Change-Id: I309fca497027cd8cb7cee6c998fc34d0cb5e94fd
2026-01-29 10:04:43 -08:00