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
6f8bb5ef55
Refactor compiler warning handling.
...
Compiler warnings are now accumulated in a vector of strings within the mjSpec object. New API functions `mjs_numWarnings` and `mjs_getWarning` are added to access these warnings. The compiler's log handler now chains warnings to the global log handler, ensuring they are still displayed immediately. Call sites in `mj_loadXML`, `mj_compile`, and the Python and WASM bindings have been updated to use the new warning API.
PiperOrigin-RevId: 933361650
Change-Id: I47cab98a460c57b0898c0a1a43fce2a5b9648eb1
2026-06-16 16:28:33 -07:00
Yuval Tassa
4e10f20be6
Fix set_to_muscle() to accept tuple arguments.
...
Correct argument types for timeconst and range parameters in pybind11
python bindings from C arrays to std::array.
Fixes #3282 , #3282 , #3318
Thanks to @Abzaek for original PRs
PiperOrigin-RevId: 932423401
Change-Id: Ic30ba076913693f5c0e545789690e8b0fa444390
2026-06-15 06:29:43 -07:00
Yuval Tassa
67a1ea6dca
Track authored flags for global attributes
...
PiperOrigin-RevId: 931585539
Change-Id: Ifdc8c59de6c5a553daf6e0af09d8192aff6b0610
2026-06-13 02:58:32 -07:00
Alessio Quaglino
4c381635e1
Add mjs_makeFlex to the MuJoCo C and Python APIs.
...
- Add mjs_makeFlex C API that wraps mjCFlexcomp::Make(), creating
a flex with auto-generated bodies, joints, and equality constraints
from parameters (type, dim, dof, count, cellcount, spacing, scale,
radius, mass, inertiabox, equality, rigid, flatskin, elastic2d,
pos, quat, origin, file, vfs).
- Add Python binding body.make_flex() in specs.cc with keyword args.
- Refactor flex_spec_provision.py to use make_flex() instead of XML
string templating + separate spec + attach. Eliminates textwrap
dependency.
- Merge user_flexcomp into user_model BUILD target to resolve
circular dependency.
PiperOrigin-RevId: 922725304
Change-Id: Ice13787c45f3173407fec659f9590a6453bc65dd
2026-05-28 05:59:20 -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
Sam Haves
d92fe0810c
Add MjSpec.encode method.
...
PiperOrigin-RevId: 907177387
Change-Id: I65800298798037c4a0c0cd79ec86706be67db51e
2026-04-28 14:22:41 -07:00
Alessio Quaglino
6b724616c0
Prevent deletion from an attached mjSpec.
...
This change disallows calling `mjs_delete` on an mjSpec that has been attached to another mjSpec via `mjs_attach`. Attempting to delete an element from an attached spec will now result in an error. The Python bindings for `mjSpec.delete` have been updated to raise a ValueError when this occurs.
PiperOrigin-RevId: 897266695
Change-Id: Ic0670125a3028191ec50eca890f02b5910ec8b03
2026-04-09 13:14:00 -07:00
Yuval Tassa
70a7647ad9
Add <dcmotor> actuator and related docs and tests.
...
PiperOrigin-RevId: 892927987
Change-Id: I38ed6412801341ba03ddf5fe7b93a6081df24d37
2026-04-01 07:50:23 -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
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
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
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
Alessio Quaglino
54ace777c1
Add convenient plugin assignment in Python bindings.
...
PiperOrigin-RevId: 861168536
Change-Id: I274fbf3460d475434f837ab58bf5e2b0988369fd
2026-01-26 06:37:31 -08:00
Taylor Howell
5ae6b5fe31
Fix MjSpec.add_texture gridlayout argument to accept strings and character lists
...
PiperOrigin-RevId: 859599919
Change-Id: If785f36010a7437b354ec0ce7db30c2b7ec69fe6
2026-01-22 07:28:16 -08:00
Taylor Howell
23c56ec4bb
mjSpec python bindings for add functions: accept size with 1, 2, or 3 parameters
...
PiperOrigin-RevId: 858494291
Change-Id: I8a02dcac1d2419fbc728607907425b401cf66da4
2026-01-20 02:39:04 -08:00
Google DeepMind
09a6fb7d4d
#mjspec Enforce that material textures array is always of length mjNTEXROLE.
...
PiperOrigin-RevId: 855684213
Change-Id: Id8a3734c75841dfb91bd2252114249f08461b7f2
2026-01-13 05:55:09 -08:00
Sam Haves
7e45bbb51c
Add urdf file extension case to mj_parse.
...
fixes #3004
PiperOrigin-RevId: 855249634
Change-Id: I6c21d0ada4fe482059f64e96d413796f5c1c66ce
2026-01-12 08:59:00 -08:00
Alessio Quaglino
5febca9eeb
Remove gainprm trailing dimension in test_actuator_shortname.
...
PiperOrigin-RevId: 853243753
Change-Id: Ia46df64a2308ef0bbc94a396f0732e221e174ea0
2026-01-07 06:59:50 -08:00
Taylor Howell
90449f7521
Update codegen for mjSpec add functions to add typed arguments and docstring.
...
PiperOrigin-RevId: 852351892
Change-Id: If785accdf8c9e48dd9924c54942856c1e00fd031
2026-01-05 10:14:49 -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
b8a4ac5d48
Refactor camera orthographic attribute to projection enum.
...
PiperOrigin-RevId: 847069028
Change-Id: I7f686fe654e9b56519cab8bd2f37c9cc40091d3f
2025-12-20 03:28:29 -08:00
Matija Kecman
3c19b63ed3
Refactor texture.data to be handled using py::bytes
...
PiperOrigin-RevId: 843226742
Change-Id: I7ab920da3c387467b1fced27f557c6edd1af4bce
2025-12-11 08:06:12 -08:00
Matija Kecman
bf49fe3daa
Enable reading textures from spec in Python
...
PiperOrigin-RevId: 842151742
Change-Id: I477d118cc7e2385d29b395b192fa89e9facb9c3e
2025-12-09 03:08:32 -08:00
Google DeepMind
d769440924
Store asset keys relative to the MJCF. This CL fixes cases when loading a spec with "from_zip" that fails on zipped folders that contain a root directory.
...
PiperOrigin-RevId: 825484553
Change-Id: I79c6f542edbd3ffd167d0b5cecc704c32c8d6824
2025-10-29 04:24:09 -07:00
Alessio Quaglino
010d919244
Add __setattr__ to _MjBindModel and _MjBindData.
...
This allows setting attributes with bind using a list of mjSpec objects as arguments.
PiperOrigin-RevId: 825456920
Change-Id: Ie6af956feab0a805175d7aaecf26e071401fbf05
2025-10-29 02:55:08 -07:00
Alessio Quaglino
2bdea1a0aa
Use "/" as default prefix during attach if not specified.
...
The user can recover the old behavior by passing prefix="".
This enables to attach children with default and save a valid result to XML.
PiperOrigin-RevId: 825011185
Change-Id: Id20c2589da928bf92b77bdb01cfba73dfc1d2f52
2025-10-28 06:40:34 -07:00
Sam Haves
ac2cd5dfd6
Add support for querying of MjsTendon path from Python.
...
Fixes #2670
PiperOrigin-RevId: 822215254
Change-Id: Ice5a264e54f963776093511c6e4ac830aae6d4f8
2025-10-21 11:51:24 -07:00
Alessio Quaglino
056945df20
Enable frames to create the same children as bodies.
...
PiperOrigin-RevId: 822097998
Change-Id: I8477d8abe2d6f711421126825fd94d39af1a4e07
2025-10-21 06:57:01 -07:00
Sam Haves
59f14485e0
Move mjCWrap type to mjsWrap.
...
PiperOrigin-RevId: 821851540
Change-Id: I53382a8a21312a96aea46eec130f43e7cad70f92
2025-10-20 16:28:41 -07:00
Yuval Tassa
7443e685ac
Allow contact sensor subtree1/subtree2 to be any body.
...
PiperOrigin-RevId: 799632590
Change-Id: If9cd6c5a3a5f83d89ae024a8f64232ab1f1d603a
2025-08-26 11:00:39 -07:00
Sam Haves
1fb1810b07
Add ability to specify a material assignment to a mesh asset.
...
This extends both the spec and the XML definition to allow specification of a material name on a mesh. This material acts as a fallback in the case that the referencing geom element does not specify a material of it's own.
PiperOrigin-RevId: 798232378
Change-Id: Iaf300c727732744ea1b613e64334ee505ac6e209
2025-08-22 09:11:31 -07:00
Alessio Quaglino
07e7417d26
Add prefix to asset paths when appending specs.
...
PiperOrigin-RevId: 794966246
Change-Id: I4825a11cc3234e6f403340dd997742cea0e2183b
2025-08-14 03:48:56 -07:00
Alessio Quaglino
eff4dda189
Suffix asset names when attaching specs.
...
PiperOrigin-RevId: 794717786
Change-Id: I02abe06ca3c43138e91e61f4acf87a26b3faf7fc
2025-08-13 13:43:16 -07:00
Yuval Tassa
784c7a419b
Improve builtin hemisphere docs
...
PiperOrigin-RevId: 791271829
Change-Id: I391215b5388f4e9e2a17198dbcdbd0c605fda4b4
2025-08-05 10:25:45 -07:00
Yuval Tassa
705ec6d7fb
Adds built-in superellipsoid mesh.
...
PiperOrigin-RevId: 791196831
Change-Id: I1d864f6e620870f016377a4d9e2e26d1a23fd77e
2025-08-05 07:02:52 -07:00
Yuval Tassa
a5d4d1000e
Add built-in supertoroid mesh.
...
PiperOrigin-RevId: 791180080
Change-Id: I3a70f50ff4a52a1bd4b88fc30334a574895145b4
2025-08-05 06:06:43 -07:00
Yuval Tassa
996f0040fd
Add built-in sphere mesh.
...
PiperOrigin-RevId: 791162850
Change-Id: I573a414727e79f1a495e0f2282b2faff48ab3443
2025-08-05 05:05:05 -07:00
Yuval Tassa
5220767457
Add built-in hemisphere mesh.
...
PiperOrigin-RevId: 791148546
Change-Id: Ic9ff0c9b0f5fa4fd22d5f7f848f150cf74d378ba
2025-08-05 04:16:24 -07:00
Yuval Tassa
a5a6379f83
Add built-in cone mesh type.
...
Also delete `prism` type since it is subsumed by cone.
PiperOrigin-RevId: 790992343
Change-Id: I7a9c6f2a4377489173acd64b23086c748d2cee8e
2025-08-04 19:35:32 -07:00
Alessio Quaglino
51babec9c5
Move tactile sensor to the engine.
...
PiperOrigin-RevId: 788863133
Change-Id: I3172ebb7641fa8146469da25cba7db794760e7b1
2025-07-30 05:27:44 -07:00
Alessio Quaglino
89f4789085
Add mjs_makeMesh to create a builtin mesh.
...
PiperOrigin-RevId: 788538127
Change-Id: I999733399a1a0da07b0f915f34d31364ab8b3b52
2025-07-29 11:31:18 -07:00
Yuval Tassa
46dc67b7eb
Add function mjs_sensorDim to user API.
...
Note: change to (unreleased) contact sensor mjSpec API
PiperOrigin-RevId: 788507423
Change-Id: Ie639afb7ed01dc3f7bab43a3e812e8e0b0c67d07
2025-07-29 10:20:27 -07:00
Yuval Tassa
a771fc6c09
Increase mjNSENS to 3
...
PiperOrigin-RevId: 788468705
Change-Id: Id22f131bebb6accc9a29c9aa285efa75fa8b2c16
2025-07-29 08:38:13 -07:00
Yuval Tassa
9e7979e492
Add checks for contact sensor when constructing with mjSpec Python bindings.
...
PiperOrigin-RevId: 788008233
Change-Id: I14518b8cce1a7dad4fd24933478e0cc1bb75e350
2025-07-28 07:50:56 -07:00
Alessio Quaglino
fc13995dd4
Yield ownership of vector<double>, vector<float>, and vector<int> to mjSpec in Python bindings.
...
Fixes #2756
PiperOrigin-RevId: 785417251
Change-Id: Ib399c46ee59585258ace7d9583c68b7d06d0a9e4
2025-07-21 06:44:17 -07:00
Alessio Quaglino
6e7aaacb85
Do not rely on global object lists in mjCBody::NextChild().
...
PiperOrigin-RevId: 782963753
Change-Id: I0afecbab4b7796f077963ba66eb7140d8f83ad89
2025-07-14 10:47:45 -07:00
Alessio Quaglino
1a4ddca6cf
Make mjs_findElement find meshes by file name.
...
PiperOrigin-RevId: 780150428
Change-Id: Ie500062fa8cca755683b66540e84ede588d7c331
2025-07-07 09:51:33 -07:00
Alessio Quaglino
af7d20c035
Change mjs_nextChild to be DFS to match XML parsing.
...
PiperOrigin-RevId: 778915232
Change-Id: I5e290f47b7d2530597bb6c85b66ff2ae807e5510
2025-07-03 10:07:13 -07:00
Alessio Quaglino
69ce5dbd05
Consolidate tree traversal tests in the C and Python APIs.
...
PiperOrigin-RevId: 778883024
Change-Id: I0d30ed011e60a6da7148cebc1f715895fd0c6fd6
2025-07-03 07:25:23 -07:00