Commit Graph

281 Commits

Author SHA1 Message Date
Kyle Bayes 8cbfc42767 Fix issue with zero size cache.
PiperOrigin-RevId: 819773517
Change-Id: Iff1523e17ffbd1dff02bee71db896c64bd8b565c
2025-10-15 08:46:00 -07:00
Alessio Quaglino 98682ae284 Do not modify mesh position when fitting a geom to the mesh AABB.
Also, unify the meaning of fitting a geom to an AABB: it now means to find the smallest geom such that its AABB contains the mesh AABB.

Fixes #2881.

PiperOrigin-RevId: 817097544
Change-Id: I883c686feffa803bd16ba461db24a474dfec7712
2025-10-09 03:05:00 -07:00
Sam Haves 2dc533b63b Allow flipping textures with any number of channels and user provided pixel data.
PiperOrigin-RevId: 813256285
Change-Id: I0d49885dc483ab8f093b2566ec4bef355575505e
2025-09-30 07:28:13 -07:00
Sam Haves 922aebbeed Provide explicit argument for asset cache ID.
This will allow assets to cache compiled results with different parameters. For example, we could cache both an RGB version of a texture and a Mono version.

PiperOrigin-RevId: 811341377
Change-Id: Ifd6a4ff88661a2b38be47c02d6a666de2c202885
2025-09-25 07:24:12 -07:00
Google DeepMind 0e1104768a No public description
PiperOrigin-RevId: 809083979
Change-Id: I5c6641b73c76153c15f5cdf858b788e1433acc81
2025-09-19 10:10:45 -07:00
Google DeepMind 26ea20a21f No public description
PiperOrigin-RevId: 809074980
Change-Id: Ib3e3522addceddba6a057cfef80fcbd30a420b3d
2025-09-19 09:49:07 -07:00
Alessio Quaglino 77e025ea98 Move meshdir and texturedir to mjsCompiler.
For backwards compatibility in the Python bindings, both `spec.compiler.meshdir` and `spec.meshdir` are now allowed.

Fixes #2834.

PiperOrigin-RevId: 809060113
Change-Id: Ie23f1c5dd57de43568312a8e062906f4013bb474
2025-09-19 09:05:44 -07:00
Alessio Quaglino 5bbda2186d Make the Octree interpolation continuous.
This is done by detecting the hanging nodes and compute the function at those location by interpolating the corresponding coarse vertices.

PiperOrigin-RevId: 807700228
Change-Id: I27dcb85361ca445c2099dd07b280cae5c92d3131
2025-09-16 08:15:26 -07:00
Kyle Bayes ac4874226c Support NULL in dir parameter in mj_addFileVFS.
Fixes #2839.

PiperOrigin-RevId: 807208005
Change-Id: I8def3b1e388dc19fa2fa8a92d53abef30dee5b88
2025-09-15 06:00:13 -07:00
Alessio Quaglino 4fc69fa64d Ensure that the Octree is balanced.
This means that two adjacent nodes can only have at most one level of refinement difference.

Note: This is a small breaking change for mjWarp since the order of the children was flipped.
PiperOrigin-RevId: 806299445
Change-Id: Ia326a31c7a8162ae02d70c868d87779198e805be
2025-09-12 08:34:15 -07:00
Alessio Quaglino 9d5063799f Resize keyframes also at the start of compilation.
Previously, it was assumed that attaching was the last operation performed on the mjSpec, so keyframes resulted in the incorrect size. In order to prevent information loss, we now only allow the resize function to expand the keyframe array, since attach should never remove a degree of freedom.

PiperOrigin-RevId: 804917828
Change-Id: Icfacd207ced1c6aac600d514f8d9065ceff2d347
2025-09-09 08:16:32 -07:00
Kyle Bayes ea660f4c13 Expose minimal asset cache API.
PiperOrigin-RevId: 803126923
Change-Id: Iabf63802572f7cb86864b5ece85f44b3f15a4ec0
2025-09-04 12:18:36 -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
Yuval Tassa b566ef2883 Ignore geoms with tiny mass in inertiafromgeom computation. Fixes #2754
PiperOrigin-RevId: 795475978
Change-Id: I02b5db9e2ac7ec556cb0a0ec6dbe4214ba9128d7
2025-08-15 07:57:02 -07:00
Alessio Quaglino 840108cf7c Refactor octree in preparation for continuous interpolation.
PiperOrigin-RevId: 792092644
Change-Id: I096ca0989210a00ae0b4556498d96212755d23c7
2025-08-07 04:06:03 -07:00
Yuval Tassa fde479736e Finalize built-in mesh example model and documentation
PiperOrigin-RevId: 791227350
Change-Id: Ibdcdb8a4ee5b3f78c9ae93e1db2a9a2f9d55a80c
2025-08-05 08:32:51 -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 89f4789085 Add mjs_makeMesh to create a builtin mesh.
PiperOrigin-RevId: 788538127
Change-Id: I999733399a1a0da07b0f915f34d31364ab8b3b52
2025-07-29 11:31:18 -07:00
Baruch Tabanpour 3434f5d9c7 Compute convex hull for collision pairs.
build / windows-2025 (push) Has been cancelled
build / ubuntu-22.04-clang-13 (push) Has been cancelled
build / ubuntu-22.04-clang-14 (push) Has been cancelled
build / ubuntu-22.04-clang-15 (push) Has been cancelled
build / ubuntu-24.04-clang-16 (push) Has been cancelled
build / ubuntu-24.04-clang-17 (push) Has been cancelled
build / ubuntu-24.04-clang-18 (push) Has been cancelled
build / ubuntu-22.04-gcc-10 (push) Has been cancelled
build / ubuntu-22.04-gcc-11 (push) Has been cancelled
build / ubuntu-22.04-gcc-12 (push) Has been cancelled
build / ubuntu-24.04-gcc-13 (push) Has been cancelled
build / ubuntu-24.04-gcc-14 (push) Has been cancelled
build / macos-15-arm64 (push) Has been cancelled
build / macos-15-x86_64 (push) Has been cancelled
PiperOrigin-RevId: 788074030
Change-Id: I3d4bbe71f824db82e998e374d95a5c49995af806
2025-07-28 10:49:50 -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 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
Alessio Quaglino 594e17074a Replace name attribute with setters and getters in the C API of mjSpec.
PiperOrigin-RevId: 778816015
Change-Id: Ieffb7a5bce37e887ff009f9a02d2434435e79ca1
2025-07-03 02:30:56 -07:00
Alessio Quaglino 5c1f1f9dba Add octree to meshes of SDF geoms.
PiperOrigin-RevId: 777634862
Change-Id: I3210c2f8d73fd30ceecb0a11abd1d82e086b3d5d
2025-06-30 10:50:15 -07:00
Yuval Tassa 21bae3a388 Report which body has too-small mass/inertia in compilation error.
PiperOrigin-RevId: 776196017
Change-Id: Ib81efb170347a57cdc4b446c14cd7b8f5357958c
2025-06-26 10:40:40 -07:00
Alessio Quaglino 0488d9f4eb Replace mjs_detachBody and mjs_detachDefault with mjs_detach.
In a follow-up, mjs_detach will be changed to only remove without deleting an element.

PiperOrigin-RevId: 773637351
Change-Id: I9ee4d3584ba88ccc225591337cf036bab806e25c
2025-06-20 04:12:27 -07:00
Alessio Quaglino d2501eff68 Use procedural model creation in plugin tests.
This will be useful for simplifying the mjSpec API for plugins.

PiperOrigin-RevId: 772505558
Change-Id: I8eb57d7e129e0f6430fb4c610a543e0dc0f3b295
2025-06-17 09:30:54 -07:00
Alessio Quaglino b8768aa1cd Allow to fusestatic a body if it doesn't generate a referencing error.
PiperOrigin-RevId: 769189929
Change-Id: I62f512813ea330da088b28d39373df39be10a602
2025-06-09 10:05:57 -07:00
Alessio Quaglino 7932b4b202 Accumulate inertial in mjs_bodyToFrame.
PiperOrigin-RevId: 765129145
Change-Id: Ib7caca42ef4272ebe762655eee9380dae471be7f
2025-05-30 04:10:38 -07:00
Google DeepMind 568620dd2f Add texture attribute to lights.
PiperOrigin-RevId: 763739805
Change-Id: I333ed2ac68f30f79f688ca01d7b5fd6bf2d836c9
2025-05-27 05:04:01 -07:00
Sam Haves 924ee3070a Modify user values in mujoco to allow users to provide cleanup functions to avoid memory leaks.
For the MJCF -> USD plugin, and I suspect other usecases for user values, it's necessary to give ownership of the object to Mujoco. However since they get type erased, we can't clean up the data automatically for the user. Instead this allows c++ clients to provide a cleanup function with their data.

PiperOrigin-RevId: 756832010
Change-Id: I80b8e7822e1a0e399a0d19dcaa57ee69b3ccc16a
2025-05-09 11:03:06 -07:00
Alessio Quaglino ad80a4625b Always generate a BVH in flex.
The BVH is used also for computing normalized vertex coordinates in the trilinear interpolation, so we need to compute it also when the flex cannot collide.

PiperOrigin-RevId: 756349244
Change-Id: Ib397c472e31251df5a7ea85850d83a62f3b2c949
2025-05-08 09:46:47 -07:00
Kyle Bayes f4774a5449 Fix bug in cached meshes where convex hull was missing. Previously if a mesh was copied from the cache it would not have its convex hull if the original mesh that was cached didn't previously compute it.
Fixes #2609

PiperOrigin-RevId: 756223337
Change-Id: I54705456636c270607a17340b249047e0df75d0b
2025-05-08 02:42:15 -07:00
Mohammad Hamid 3429a4881a Detect mismatch between maxNodes and Nodes in a gmsh block. Fixes #2342
PiperOrigin-RevId: 745967745
Change-Id: If1b5fcd71079a0e6a6def9b442758678e31a5828
2025-04-10 04:15:21 -07:00
Taylor Howell 96dda6ea75 Add tendon actuator force limits and tendon actuator force sensor.
PiperOrigin-RevId: 745096883
Change-Id: Ib9acb727fbbfc6b0b0323ee6a889053a7a878056
2025-04-08 05:16:35 -07:00
Alessio Quaglino d7027fb1c0 Do not skip mjSpec's with repeated model names when attaching a new mjSpec.
PiperOrigin-RevId: 744705838
Change-Id: Ie47a3c029f443910629619b7f9ff43ab07646725
2025-04-07 06:52:12 -07:00
Alessio Quaglino cc2f57d820 Change mjSpec and mjModel signature mechanism.
The signature now contains the necessary information to safely perform `bind`. The private UIDs are now removed.

Fixes an issue of changing signature when compiling a copy of an mjSpec.

PiperOrigin-RevId: 744670626
Change-Id: Id3c66419cf2afbe78e91bc4b37d2299f5ec00ab1
2025-04-07 04:21:27 -07:00
Alessio Quaglino 8941f56e86 Copy UIDs during mj_copySpec.
This will produce the same mjSpec signature after a deep copy.

PiperOrigin-RevId: 743538018
Change-Id: Ic0f5b06a00e8883cb92dc98159db3bea02cb7a36
2025-04-03 06:29:07 -07:00
Yuval Tassa e5912c3ce4 Use tolerance to compare quaternion components in UserObjectsTest.Inertial
Fixes #2515

PiperOrigin-RevId: 742704324
Change-Id: Ib26891e43128e66d2ac1840ed574285781fb12a5
2025-04-01 08:12:01 -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 648a03c2cf Override inertia of body with visual geoms if discardvisual is true.
Fixes #2546.

PiperOrigin-RevId: 742650702
Change-Id: I753c1e1c89da732ece100676644bbecf9d6373bb
2025-04-01 05:21:48 -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 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
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
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