Commit Graph

2861 Commits

Author SHA1 Message Date
Yuval Tassa 400a379b70 Update doc requirements.
PiperOrigin-RevId: 742324590
Change-Id: I55d6535190a2281aec04ff16bd3f82f6c85870f9
2025-03-31 11:05:10 -07:00
Yuval Tassa 8bcfe07e14 Fix potential division by zero in mj_tendonDot.
PiperOrigin-RevId: 742246626
Change-Id: I1f897bd0ca28e0efdffc5a93fadca35221eaeb38
2025-03-31 06:41:26 -07:00
Alessio Quaglino 01d4c46753 Store the mjsCompiler -> appended mjSpec map when appending an mjSpec.
Previously, we stored the source `mjSpec` during a copy as a hack for having access to the compiler options, but this is not robust since we cannot guarantee that 1) the source `mjSpec` is not destroyed before we need to look up the compiler options nor 2) that the `mjSpec` was appended without a copy.

While 2) could be solved by simply handling an additional case in `mjCModel::FindSpec`, using a map also solves 1) and it is easier to understand.

PiperOrigin-RevId: 741504264
Change-Id: Iab1bfd9e61299a94fa8caf3a244c067b09d54384
2025-03-28 06:27:22 -07:00
Alessio Quaglino 6e19035aab Add delete and detach docs.
PiperOrigin-RevId: 741444657
Change-Id: I4207eaf74524e8a3ca46130967c6fb0dd62b4d64
2025-03-28 01:58:54 -07:00
Kevin Zakka e272e46770 Rename simulate "copy pose" button to "copy state", also save "qvel', ctrl, mpos and mquat if present. SHIFT-click will save values at full precision.
Example formatting:

```
# default precision
<key
  time="2.99"
  qpos="9.4287e-07 3.02972e-07 1.19963 0.999999 -9.3978e-06 0.00102591 8.06948e-06 -0.000337469 -0.000182994 -0.00282448 -0.000358084 -0.00370829 0.0631084 0.0996347 -0.00161963 0.0260658 -2.09992 -0.00459387 0.0474729 -0.0171906 0.0018216 0.72549 0.00133026 0.724951 0.000816735 0.724389 0.000454671 0.724 -0.00146646 -1.12233e-05 -0.0995942 0.00159877 0.0261695 -2.09993 0.00458912 0.0473279 0.0171317 0.00177837 0.725447 0.00131597 0.724941 0.00081406 0.724393 0.000465918 0.72402 -0.00140271 -1.42355e-05 0.0949171 0.0790632 -0.461397 1.02664 -9.42133e-05 -0.55539 -0.0952333 -0.0790705 -0.460978 1.02899 8.38339e-05 -0.671707 0.401772 0.197427 1.00101 0.999979 0.00125793 -0.00100982 -0.00631542"
  qvel="0.000132784 3.49155e-05 0.000536692 -0.000560519 -0.0242142 0.00693928 0.00119816 -0.000234844 0.00350923 -0.00036047 0.00137217 0.026605 0.000647559 -0.000813737 0.00151335 0.00158296 -0.000628786 0.0184574 -0.000751955 8.75972e-05 0.00017462 9.47749e-05 0.00018949 7.40435e-05 0.000170318 -2.65743e-05 5.67808e-05 0.000256585 -8.77605e-05 -0.00070146 5.90881e-05 0.00186213 0.00150788 0.000645196 0.0183261 -0.00189709 0.000234144 0.000180699 0.00020344 0.000161977 0.000154203 0.000127231 2.28526e-05 -2.85628e-06 0.000232213 2.32483e-05 -0.000415728 0.000285987 0.00873081 0.00361353 5.70155e-05 0.000316513 -0.00778618 0.00404914 -0.0239508 -0.0375704 -0.000528571 4.92965 3.51479e-15 -4.54231e-16 -9.39907e-15 -7.5733e-14 -1.54433e-14 8.71183e-14"
  ctrl="0 0 0 0 0 0 0.106158 0 0 -2.1308 0 0 0 0 0 0 0 0 0 -0.106158 0 0 -2.1308 0 0 0 0 0 0 0 0 0 0.1 0.08 -0.477 1.033 0 -0.556 -0.1 -0.08 -0.477 1.033 0 -0.556"
  mpos="0.5 0 0.5 0.5 0 0.5 0.5 0 0.5"
  mquat="1 0 0 0 1 0 0 0 1 0 0 0"
/>

# full precision
<key
  time="19.78000000000035     "
  qpos="-5.456931939182209e-13 4.210058291674657e-14  1.199596868198444      0.9999997705632744     -1.123107929038176e-05 -0.000677308838908712  -4.574736052563342e-13 4.81467762006399e-06   -0.0001470530836508491 -0.01285126600561344   -0.0003314670141921113 -0.003753266058087929  0.06165064101255623    0.01573179146576803    -3.013291189105153e-05 0.00898818165332332    -0.0005543865919957537 0.001960768693378906   0.003171337599202657   0.05998529721754536    -0.006869809693640725  0.7108455550986151     -2.768022862919269e-05 0.7234287700347743     -2.65358465809282e-05  0.7234305602907817     -2.427451970418236e-05 0.7234340023869628     0.0001444026830625057  0.004779116304496144   -0.01556918200171751   2.367030531882565e-05  0.00887857821391661    -0.0005393749458389281 -0.002002170464405725  0.004065365245773832   -0.059404381452836     -0.006700853036263364  0.7112073591870905     -2.793780628594305e-05 0.7234283783336887     -2.67570932686378e-05  0.7234302250735107     -2.446320244250625e-05 0.7234337167312712     0.0001441442525519209  0.004776981844081063   0.001964241516442131   -0.001279289930183057  0.0009901921906584617  0.005102724602622095   -0.0001969944416873799 0.0006055390861509305  -0.001981889349334628  0.001289775046291938   0.0009924227912350586  0.005084179458414934   0.0001970337430004949  0.0006055492125132441  0.4000059982468001     0.2000006330421453     1.001005166968155      0.9999986986616857     0.001264259603338192   -0.00100188514175821   -2.342548568520312e-05"
  qvel="8.028421913635349e-14  -7.933623204015651e-15 -1.766955416585763e-09 -1.242788325114248e-10 1.380680257623891e-08  4.072776622758517e-13  -2.152263214542579e-08 -3.878177040643757e-09 -7.698904695669224e-07 1.032750347898222e-09  -1.203279562630678e-09 -7.551458300921444e-08 2.469496246057255e-06  8.917880101195273e-08  -6.756803792056489e-06 -2.872076666906819e-06 1.785650772865195e-06  -5.01959632083366e-06  -5.599940213931672e-06 8.890181416091634e-07  1.64456042549838e-06   -1.371426840474208e-09 -2.120678515220117e-09 -2.024654983099582e-09 -3.146661587304676e-09 -2.584650818327909e-09 -4.007447393764789e-09 3.46515937628953e-09   1.271775029987075e-08  -2.488928508740539e-06 -8.746797042033161e-08 -6.8499144406484e-06   -2.901446048768352e-06 -1.790798673741401e-06 -5.013863339758384e-06 5.931327072492727e-06  9.379458926032098e-07  1.728266244061688e-06  -1.546731198107214e-09 -2.391411625987869e-09 -2.205072839286403e-09 -3.425520861505272e-09 -2.768770278332858e-09 -4.29204657928239e-09  3.77970711367913e-09   1.210836106515995e-08  2.48779855243758e-07   1.794262457563144e-08  2.425338558609319e-07  -4.490996387632652e-09 1.5470867213074e-10    -1.056275279772894e-10 -2.528203830071622e-07 -1.984360361016969e-08 2.432485190492325e-07  -4.490126811319184e-09 -1.553085076375719e-10 -1.050844929338509e-10 -5.03087850573677e-15  -3.069973955284326e-15 1.263049899085103e-14  -2.132657422360499e-13 1.240631051776082e-14  7.346260313161907e-14 "
  ctrl="0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                     "
  mpos="0.5                    0                      0.5                    0.5                    0                      0.5                    0.5                    0                      0.5                   "
  mquat="1                      0                      0                      0                      1                      0                      0                      0                      1                      0                      0                      0                     "
/>
```

PiperOrigin-RevId: 741427042
Change-Id: Ib33f3e6215b7933d9267fc4c222d7a0abc75dbb4
2025-03-28 00:38:19 -07:00
Taylor Howell 0abf184d49 Align comment in mjmodel.h.
PiperOrigin-RevId: 741214316
Change-Id: I449c4a6e1c70b30d60636e11f26fb0bc8653f2a5
2025-03-27 11:05:46 -07:00
Alessio Quaglino e8c67ca586 Allow orientation for user composite.
PiperOrigin-RevId: 740909723
Change-Id: Id38a55114d4257a461bbced57d35d6bb42a2597d
2025-03-26 14:44:51 -07:00
Google DeepMind 644b42bee3 Add mujoco/experimental and move USD work there.
PiperOrigin-RevId: 740730698
Change-Id: If9c68798cda502d6d7632906a034437e2557802e
2025-03-26 05:37:45 -07:00
Alessio Quaglino 5c955b8fe2 Add frame support to the cable composite.
Also cleanup user_composite.cc includes.

PiperOrigin-RevId: 740730596
Change-Id: I05df59926d8e61de45fd6b2a3a63121b7a390448
2025-03-26 05:36:36 -07:00
Kyle Bayes d6943731b2 Fix bug in nativeccd multiccd.
PiperOrigin-RevId: 740495321
Change-Id: I7eaa0da8514e27c233d49567c276d1d238808d1f
2025-03-25 14:56:21 -07:00
Alessio Quaglino 69f8349203 Add signature error checking at the end of compilation.
Fixed some edge cases that caused the new error to be triggered.

PiperOrigin-RevId: 740483759
Change-Id: I6ced3ba55476d5c18103e205151ecace94f2b29b
2025-03-25 14:22:58 -07:00
Alessio Quaglino 157b074116 Add signature to mjSpec and mjModel and use it to perform safe bind to mjModel and mjData.
PiperOrigin-RevId: 740378879
Change-Id: If14b326942529494f172e7aedcae30195798b458
2025-03-25 09:37:49 -07:00
Yuval Tassa c931565fdc Add internal functionmj_tendonDot: time derivative of tendon Jacobian for one tendon.
Notes:
- Currently always uses dense math, even for sparse models. This should be easy to change in the future.
- Does not support geom wrapping. This is possible but harder, requires derivatives of mju_wrap.
PiperOrigin-RevId: 740378741
Change-Id: Id39ef2c4bfbb7ee11ec33c97d7d83140441cdab2
2025-03-25 09:36:30 -07:00
Alessio Quaglino 4e206c29c1 Keep tree lists updated at all times.
This simplifies the compiler logic since an updated tree list was necessary at many stages (e.g. attach and keyframes resizing) and it will be anyway required when computing the mjSpec signature.

PiperOrigin-RevId: 740356447
Change-Id: I7f2ec25b27b8d4ca4364801c9a401c40c6d84569
2025-03-25 08:21:22 -07:00
Kyle Bayes 12b40b948e Remove MuJoCo stack calls in nativeccd.
1. There is now thread local static memory for use with a conservative max number of iterations needed for contact.
2. For possible needs of high precision contact recovery with large iteration numbers (i.e. ellipsoid-ellipsoid collisions), there are callbacks to allocate memory when needed.

PiperOrigin-RevId: 739187134
Change-Id: I3d210f75218922d969c78465da3fe50da4fe3080
2025-03-21 08:20:51 -07:00
Alessio Quaglino dc96ed6bdb Remove plugins that are not referenced after detaching a body.
Fixes #2497.

Also, use `Release()` instead of `delete` for removing elements when detaching a body in order to preserve correct reference count.

PiperOrigin-RevId: 739133888
Change-Id: I7ccfad84446fb15259bad30c4ba1e6f7fa601518
2025-03-21 04:34:05 -07:00
Tom Power 8d92a0fbe6 Clear body subtreedofs when compiling. Fixes issue when attaching previously compiled model.
PiperOrigin-RevId: 738906593
Change-Id: I74875b4d07c422e397358dff5daf6682ec1bd655
2025-03-20 12:52:36 -07:00
Saran Tunyasuvunakool 2e11afa2de Fix a bug in the handling of efc_J in put_data.
PiperOrigin-RevId: 738877177
Change-Id: Ie469af0e1c31843e8c59cd2cf6fc0befb1ed4956
2025-03-20 11:26:14 -07:00
Kyle Bayes 467a63d203 Add BoxBox to ccd benchmarks.
PiperOrigin-RevId: 738761460
Change-Id: If59d306748d64e9e30abe65daa746a4f8e9ec78c
2025-03-20 05:16:33 -07:00
Alessio Quaglino 1f1d5287fb Fix bind.set when using a single joint instead of a list.
PiperOrigin-RevId: 738546056
Change-Id: I26ae045be9e983cb0760132b9d47eac018ca33cd
2025-03-19 14:44:22 -07:00
Tom Power be64747166 add mjs_detachDefault to delete a default class from mjSpec
PiperOrigin-RevId: 738452369
Change-Id: I5a53a6dc8f89e1e8136aeefc09d7d9b7b7204e1f
2025-03-19 10:31:04 -07:00
Kyle Bayes a1b9ffd124 Fix memory over-allocation in nativeccd.
PiperOrigin-RevId: 738383181
Change-Id: Ibf9e2b146da671e8d3a48339c8f4c6813f537456
2025-03-19 07:08:21 -07:00
Alessio Quaglino 209d2bd2c5 Added functionality for user payload data in mjSpec.
PiperOrigin-RevId: 738343134
Change-Id: I6217362ced9993afcd5a2914c78718ffe3bf753a
2025-03-19 04:36:00 -07:00
Kyle Bayes dc50fbbb9b Add safeguard if n is invalid in GJK.
PiperOrigin-RevId: 738340065
Change-Id: I2288eb731621e5b84dcc0f078d8dbd84dca94cd4
2025-03-19 04:21:11 -07:00
Yuval Tassa efe213a7b3 Cosmetic improvements to src/xml/ source files.
PiperOrigin-RevId: 738010419
Change-Id: Idb90a42a374682450737684e67388329c184c777
2025-03-18 08:12:29 -07:00
Yuval Tassa 205599ac1a Cosmetic improvements to src/user/ source files.
PiperOrigin-RevId: 737930914
Change-Id: I1cc254d420fcdf0c42ec3d2f601e5a02d925d958
2025-03-18 02:59:12 -07:00
Alessio Quaglino bae5175cf2 Accumulate rotation after updating pos and quat in replicate.
Fixes #2501.

PiperOrigin-RevId: 737929158
Change-Id: I0cad2de37190f1d30d427ae646acbde335b5be56
2025-03-18 02:51:05 -07:00
Alessio Quaglino 1bf24e9f67 Do not overwrite existing parent frames for worldbody elements when attaching an mjSpec to a frame or a site.
PiperOrigin-RevId: 737662046
Change-Id: I7028c21c803c01845ae1d53cb476f7b3df172313
2025-03-17 10:21:38 -07:00
Alessio Quaglino da04688071 Automatically compile mjSpec in to_xml().
Also, move mj_compile from MjModelWrapper to MjSpec.

PiperOrigin-RevId: 737640210
Change-Id: I93d2a31c33eb359452b0d966a29939183b4c5198
2025-03-17 09:21:10 -07:00
Alessio Quaglino 35774706ee Set parent frame of new frames after copying all frames.
PiperOrigin-RevId: 737620918
Change-Id: I8f49570cab39bd84b2da908d3683dddc3b29cb3c
2025-03-17 08:19:04 -07:00
Kyle Bayes b10b0b7055 Cache all processed mesh data.
PiperOrigin-RevId: 737576455
Change-Id: I87628ce7842d0d7d0e7fe02eb9afb2ddefa68ff8
2025-03-17 05:20:41 -07:00
Yuval Tassa fa1b01360a Delete reference to nonexistent flag in docs.
PiperOrigin-RevId: 737434746
Change-Id: I277b9d910f050315b4f5c855d1955989e668c46f
2025-03-16 17:34:29 -07:00
Alessio Quaglino f480a9e985 Add MjSpec.from_zip() constructor.
PiperOrigin-RevId: 736871864
Change-Id: Ib6cc189d5912a57e5c505c744a4a1d6ad61d1c84
2025-03-14 08:31:14 -07:00
Kyle Bayes 1a67aaf1b7 Remove pointers from BVH for caching in mjCMesh.
PiperOrigin-RevId: 736849392
Change-Id: I684cca918c65718b29a1bcb41ecd6bad8d88f8f9
2025-03-14 07:01:18 -07:00
Alessio Quaglino f25fc63f0f Default flex internal contacts to "false".
This function is unusual in the context of soft body simulations and has been a common gotcha for users, see e.g. #2500, #2079, #1900, and #1433. It should be used only if element inversion cannot be prevented otherwise.

PiperOrigin-RevId: 736822983
Change-Id: I76b0965c91c94dd88123826d218d7544ec37a88c
2025-03-14 04:55:09 -07:00
Yuval Tassa 40891eeadc Time both first and second compilation in sample/compile.cpp.
PiperOrigin-RevId: 736482658
Change-Id: I3caeff5abafb69998e56ccd792f5d02e7e04e430
2025-03-13 06:27:05 -07:00
Copybara-Service a7a8a68be5 Merge pull request #2496 from jjyyxx:patch-1
PiperOrigin-RevId: 736457846
Change-Id: I3b4b1554dd15e9ca73abee5c31d4758f694f5b44
2025-03-13 04:33:45 -07:00
Alessio Quaglino 8e300eb628 Update list ids immediately during body detach.
Fixes #2499.

PiperOrigin-RevId: 736449320
Change-Id: Ieeae52bdbbbb896d886221ab088229c8287a32a3
2025-03-13 03:55:58 -07:00
Tom Power 8f4c5c4b16 add support for non-rgb textures in xml_native_writer
PiperOrigin-RevId: 736221430
Change-Id: I83c19e06f0f7be054a88c3e894807e7b90ee012a
2025-03-12 12:17:32 -07:00
Google DeepMind 5c3bab4d09 Change default metallic value to 0, as per the XMLreference doc.
See https://mujoco.readthedocs.io/en/stable/XMLreference.html#asset-material-metallic

PiperOrigin-RevId: 736190166
Change-Id: Ic841df9510aff5df8f5ea3394732ab65b550aa65
2025-03-12 10:54:29 -07:00
Alessio Quaglino 775c45c60e Do not lookup compiler options by name when attaching.
Also, fix a pre-existing bug that caused incorrect compiler option propagation with nested attachments.

Fixes #2480.

PiperOrigin-RevId: 736156202
Change-Id: Ib430493e8c60556c2312603198587b39de9b8a4a
2025-03-12 09:18:47 -07:00
Kyle Bayes 995bbf0f0f Refactor and fold in code into Process in mjCMesh for caching.
PiperOrigin-RevId: 736052216
Change-Id: Ia0e055fd99ce429b9dee97f3f9effbf2fa1aa4f9
2025-03-12 02:12:53 -07:00
Copybara-Service b9a23e8d0c Merge pull request #2475 from lyd405121:main
PiperOrigin-RevId: 735789711
Change-Id: Iad5a52a0ba29baad31ba60f0243e3b88553e6e96
2025-03-11 09:48:23 -07:00
Yuxuan Jiang 3884c86a14 Fix broken model.vis repr 2025-03-12 00:28:38 +08:00
Yuval Tassa c5473d9923 Print compilation time in sample/compile, allow compilation with no output.
PiperOrigin-RevId: 735692355
Change-Id: I4371f800ec150f8d665cf164b50a0e5a0b5ac082
2025-03-11 03:25:51 -07:00
Yuval Tassa de48f4178f Add missing term in mj_jacDot
PiperOrigin-RevId: 735686836
Change-Id: I813ca46f71e368ddc97a6d2e540102137b31dbcf
2025-03-11 03:01:29 -07:00
Yuval Tassa 3b27f30827 Added comment regarding numpy slices.
PiperOrigin-RevId: 735681812
Change-Id: I832219bb63c83ecd5115ac1d5755cd35b4362478
2025-03-11 02:36:51 -07:00
Yuval Tassa bd9d30adc7 Improve documentation of mj_saveLastXML fixes #2075
PiperOrigin-RevId: 735672207
Change-Id: I951b8be9cf12a2a4965a40bb8db4de4ddda18570
2025-03-11 01:57:46 -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
Alessio Quaglino 14dc6fd33b Do not use inertia during mesh compilation.
Fixes #2479.

PiperOrigin-RevId: 735387473
Change-Id: Ib241f2a0efc100bbe2cec24e0399bfcc87268094
2025-03-10 08:35:33 -07:00