Commit Graph

231 Commits

Author SHA1 Message Date
Yuval Tassa 893a993bf6 Fix typos.
PiperOrigin-RevId: 716211176
Change-Id: Ibadfe13db89ed9047832b977e918faa3c5c6d9f1
2025-01-16 06:28:54 -08:00
Alessio Quaglino c2138c3fb0 Do not copy the spec during attach.
Use a reference count for managing the memory.

PiperOrigin-RevId: 716169486
Change-Id: Id270c4858c17b9250115e9544d5ea143584e2d5f
2025-01-16 03:53:17 -08:00
Alessio Quaglino 6654d63438 Add spec lookup in the attached spec array using the compiler option pointer.
This enables to find the spec associated with the compiler option stored in the objects, which do not necessarily belong to the model that owns them.

PiperOrigin-RevId: 713259419
Change-Id: I579c770147ff07ed2a5edd20e7a795ee7cc27147
2025-01-08 05:44:00 -08:00
Alessio Quaglino f882f4b065 Remove requirement to specify a name prefix or suffix during attach.
PiperOrigin-RevId: 703049862
Change-Id: I5fd6da0581331b1b716110292a8160ae16934157
2024-12-05 03:19:57 -08:00
Alessio Quaglino 10239a673b Change from parent ID to parent pointer in mjCBody.
This is required to have parent body info during attach and during body to frame tranformation for uncompiled models.

PiperOrigin-RevId: 703038426
Change-Id: Ib482059ba419a020860c649d6ea1b1088045f2e1
2024-12-05 02:32:56 -08:00
Alessio Quaglino afc86ac1b3 Associate children of deleted body to the newly created frame in mjs_bodyToFrame.
Also associate all children that need a parent body to the parent of the deleted body.

This is a bug that was causing the former children of the body that gets transformed to a frame to not be children of the new frame.

PiperOrigin-RevId: 702702853
Change-Id: I36d48f0446bc87c665b18d34e0b0609d82c70f51
2024-12-04 06:30:21 -08:00
Alessio Quaglino 13b6055098 Add material namespacing to sites.
Fixes #2243.

PiperOrigin-RevId: 699713625
Change-Id: I1b45e43f2a6ccfa64c46489c9426fcc2acdc94c3
2024-11-24 08:39:29 -08:00
Alessio Quaglino 821f1d3f98 Do not namespace empty actuator strings during attach.
Fixes #2233.

PiperOrigin-RevId: 698070772
Change-Id: I19613acfd407ba6a8ede40dad85324a70db480a8
2024-11-19 10:42:24 -08:00
Alessio Quaglino 45f908c165 Enable attaching plugins not instantiated in the extension section.
Fixes #2217.

PiperOrigin-RevId: 695766524
Change-Id: I534b63400810bd6ef888f39f6665213280fd93ac
2024-11-12 09:36:06 -08:00
Alessio Quaglino 159f23e6b4 Remember compiler options during attach.
Note:
- Move compiler options into `mjsCompiler` struct.
- The compiler options from the attached model are not written by mj_SaveXML.
PiperOrigin-RevId: 689391440
Change-Id: I1d63c146a32f87c737b7a55b64a54b0ffe3aecc9
2024-10-24 08:31:15 -07:00
Alessio Quaglino ed7655cf97 Store a copy of the attached specs in the destination spec.
PiperOrigin-RevId: 689013340
Change-Id: I2cb7a1f3850f0e3592834b355d35dcc2cd8f150f
2024-10-23 10:20:42 -07:00
Alessio Quaglino 4a3f77dd1f Add missing default namespaces.
Fixes #2162.

PiperOrigin-RevId: 688575676
Change-Id: I6c43e33ebead68dece0f779e6f031e90a5e19096
2024-10-22 09:16:31 -07:00
Alessio Quaglino bfa78614c8 Require prefix for the attach tag.
For `mjs_attachFrame` and `mjs_attachBody`, require either a prefix or suffix.

It is tempting for users to not use a prefix (see #2162), but this causes issues. For example, it creates a duplicate "main" default class in the parent as a child of the already existing "main" default.

PiperOrigin-RevId: 688535755
Change-Id: I653181ca35943f1e4eb89c70fca8b5289818324e
2024-10-22 07:08:33 -07:00
Alessio Quaglino 8740533644 Check obj and ref types before casting them to a geom.
PiperOrigin-RevId: 686616350
Change-Id: I43b14344df6324b371c6bb2447c63197b88178d5
2024-10-16 13:16:01 -07:00
Alessio Quaglino 11af1e2a95 Fix a bug in mj_recompile.
The qposadr_ and dofadr_ variables of the joints were not being reset to -1 when a joint is copied. This could lead to errors when calling mj_recompile after attaching a compiled spec.

PiperOrigin-RevId: 686152004
Change-Id: I9e058089ce87ea0d8e51a7f43475bc48c6527a26
2024-10-15 10:24:32 -07:00
Kyle Bayes 8d84b5f693 Disable hfields for collision sensors.
PiperOrigin-RevId: 685730321
Change-Id: Ib1d4a90b7b31ca388e018076a274e25c40409080
2024-10-14 09:19:11 -07:00
Alessio Quaglino 1e7c109887 Raise warning when attaching a spec with pending keyframes to a different spec.
PiperOrigin-RevId: 685677622
Change-Id: Iba522c523ebd2afe64d6ab28c6b6b4b3cd399cf8
2024-10-14 05:54:18 -07:00
Alessio Quaglino 766cd20273 Add mjs_bodyToFrame() to convert a body to a frame.
Also add test for attaching the world body.

PiperOrigin-RevId: 685603933
Change-Id: I3cfe7d226d6f032b5a587e44d0f4f18207977188
2024-10-14 00:39:20 -07:00
Alessio Quaglino 1f9dca8bc4 Do not expose plugin_slot.
PiperOrigin-RevId: 683215401
Change-Id: Ic64f7221ed83ca3b0c8cca16eb680ea67c67b564
2024-10-07 09:38:01 -07:00
Alessio Quaglino 66faba9aa5 Avoid changing semantics of mjsPlugin.name across XML sections.
The `extension` section used to discard the plugin name and write the instance name in `plugin.name`, while all of the other sections wrote the instance name in `plugin.instance_name` and optionally the plugin name in `plugin.name` (via the function `OnePlugin`). Now all plugin names are in `plugin.plugin_name` and the instance is written in `plugin.name`, so that it is possible to lookup a plugin via its unique instance name.

PiperOrigin-RevId: 683183804
Change-Id: I179ef5d221143b720db24d745b09e327bf1449ef
2024-10-07 07:57:03 -07:00
Alessio Quaglino dfd1f8fefc Fixed a bug causing an early stop of tree traversal.
Fixes #2112.

PiperOrigin-RevId: 681804470
Change-Id: I15a6f010db1a97931438fa6d8fd1d5cda6863c32
2024-10-03 03:38:17 -07:00
Alessio Quaglino dfe8e45101 Namespace plugin instances when attaching.
Fixes #2112.

PiperOrigin-RevId: 681045462
Change-Id: I2c945c5405fcb91e0f9a1b0b1e94f68d174c84ee
2024-10-01 09:14:37 -07:00
Alessio Quaglino 89aea5e217 Add body.find_all() to Python bindings.
This enables to generate a list of all body children of a given type.

Also, add recursive option to mjs_firstChild and mjs_nextChild. Fixes #2112.

PiperOrigin-RevId: 681039348
Change-Id: Iebbb26fd5ec314150206edfdddd88633baa0bec6
2024-10-01 08:57:25 -07:00
Alessio Quaglino 40b2ae92e5 Reset pending keyframes in source model after attaching.
Fixes #2101.

PiperOrigin-RevId: 680526395
Change-Id: I3bd06db5231d653b1c5bc1c2ba6b03b52e65f288
2024-09-30 05:05:21 -07:00
Alessio Quaglino 58a49bad96 Add nested keyframes attachment test.
This is a no-op change for keyframes but it shows an example of behavior.

Also, fixed two bugs:
- Missing namespace when attaching frames.
- Incorrect body id and subtreedof when attaching a compiled spec. Fixes #2063.

PiperOrigin-RevId: 680289467
Change-Id: I2ddaa7ad2226fa466ec3bbf74a7553d497bb4bb9
2024-09-29 11:57:56 -07:00
Alessio Quaglino 25e4d75a07 Return attached body/frame in mjs_attachBody/Frame.
PiperOrigin-RevId: 679601525
Change-Id: Icdc4616808e14bf0a3ebc17d89392382d084c31b
2024-09-27 08:34:00 -07:00
Alessio Quaglino 0ba11b9623 Add plugins list to mjSpec Python API.
Fixes #2061.

PiperOrigin-RevId: 677762985
Change-Id: I8e407373e7b505d9b0f1c023e97c5ea92169bbf6
2024-09-23 06:13:42 -07:00
Yuval Tassa 50f43b8745 Fix various issues with body inertial parsing and compiling.
- Add errors in body compiler for incorrect mixing of specifiers.
- Correctly process inertia orientation specifiers.

PiperOrigin-RevId: 676843326
Change-Id: I7e7eb22e25a6769754794f98fad5e0dcc0e5946f
2024-09-20 07:53:42 -07:00
Alessio Quaglino f4381e12a2 Delete plugins when their corresponding objects are deleted, if their instance belonged the object.
Fixes #2061.

PiperOrigin-RevId: 676402701
Change-Id: Ia4807d57a3763e2100702b7e7ec96c300d0a9cfb
2024-09-19 07:21:42 -07:00
Yuval Tassa f161b63a22 Set default body position to (0, 0, 0).
The "undefined" body position is a remnant of the now-removed `compiler/coordinate` attribute, see [documentation in version 2.3.3](https://mujoco.readthedocs.io/en/2.3.3/modeling.html#cframe) (or older).

PiperOrigin-RevId: 676361485
Change-Id: I104c8da2a988a0430eb85fff8b9b60f8c1e08582
2024-09-19 04:36:39 -07:00
Alessio Quaglino aca4b3324d Resolve default asset names while attaching a spec.
PiperOrigin-RevId: 676053538
Change-Id: I717b87be4bc18a5d9f8e5f2dc071bd93409eea81
2024-09-18 10:58:12 -07:00
Taylor Howell 60a1921b34 Add site semantics to weld constraint. Fixes #1896
PiperOrigin-RevId: 675112981
Change-Id: Ie4c01440d54116075df89f480591700762892cbd
2024-09-16 05:46:01 -07:00
Alessio Quaglino c77babe046 Fix a bug in MuJoCo's user_mesh.cc that caused meshdir_ to be overwritten when a model was loaded with a nested model.
PiperOrigin-RevId: 675092713
Change-Id: Iad6336141749510bf5544cab9c06533ee1589c08
2024-09-16 04:22:13 -07:00
Alessio Quaglino 567793c26f Store model paths in assets.
This enables to preserve the paths of the child spec during `attach`.

PiperOrigin-RevId: 673349237
Change-Id: Ibf075c7ec037ff5d540bc60d6e77c12f60269791
2024-09-11 05:20:14 -07:00
Yuval Tassa 621ea29382 Improve error message for keyframe size mismatch. Fixes #2041
PiperOrigin-RevId: 671069582
Change-Id: Ie63d3bf2b543f7bb5e3c123093095e76a95b7b48
2024-09-04 12:58:31 -07:00
Yuval Tassa 8954a088ce Add automatic free-joint alignment.
PiperOrigin-RevId: 671010083
Change-Id: Ib7d60f75c7f545b1886703715663db8de77feeef
2024-09-04 10:07:33 -07:00
Alessio Quaglino ae4987026c Add tree element support to mjs_firstElement() and mjs_nextElement().
PiperOrigin-RevId: 671003046
Change-Id: I9e07d7c85c7218e9bded0f50af9db62d0f1e21e1
2024-09-04 09:46:24 -07:00
Alessio Quaglino d3dfa6f970 Add mjs_findElement() to find any element in a spec by name.
Also, remove mjs_findMesh() and mjs_findKeyframe().

PiperOrigin-RevId: 670978980
Change-Id: Id88b800eb8a4c5efc40866f72a4442bf1d1437d0
2024-09-04 08:24:22 -07:00
Yuval Tassa a1036b86d3 Allow connect constraints to be specified using sites.
PiperOrigin-RevId: 668925419
Change-Id: I10cb71e6706e617c830cd90d6d0836b94a5a8cfa
2024-08-29 07:10:51 -07:00
Yuval Tassa ad9cd7301e Correctly apply frame transform to light direction.
PiperOrigin-RevId: 665340267
Change-Id: Ida16ddbf3a057ffd3e260b71180a45acbf749931
2024-08-20 06:48:11 -07:00
Yuval Tassa 4aab00fa2d Minor cleanups to body and joint compilers.
PiperOrigin-RevId: 664824939
Change-Id: I6014ff10683849e2926f1b1c8df8b6862192cd00
2024-08-19 08:43:10 -07:00
Alessio Quaglino 4b88e9bebf Do not delete keyframes during mjs_detachBody.
PiperOrigin-RevId: 663281082
Change-Id: I6eedf8c5a3a422bcd78086f2fe30c2099f0b9d16
2024-08-15 06:10:43 -07:00
Yuval Tassa d932faa1d4 Flip order of cases in user_objects.cc (readability)
PiperOrigin-RevId: 663040865
Change-Id: I27d06a6a769d5bfc41189d270021b4fc1d4b5932
2024-08-14 13:49:11 -07:00
Alessio Quaglino 4c64e6f036 Add mocap state to SaveState/RestoreState and attached keyframes.
PiperOrigin-RevId: 662975257
Change-Id: I3edb44f34426525813033902caf31db16ad7b2ab
2024-08-14 10:42:49 -07:00
Alessio Quaglino 7be4df7e03 Add ctrl to attached keyframes.
PiperOrigin-RevId: 662878508
Change-Id: Ie273fae0220c8b257766cbbd90a880d44b901725
2024-08-14 05:14:49 -07:00
Alessio Quaglino afd7c73f44 Attach multiple keyframes.
Still missing: support for ctrl, mocap, and time.

PiperOrigin-RevId: 662871569
Change-Id: I8a418c4007663e3063d7146bd72db4eba78ddc5d
2024-08-14 04:42:54 -07:00
Alessio Quaglino 19aa68c2b2 Add keyframe support to attach.
Limitations:
- Supports attaching a single keyframe. If multiple keyframes are present in the child, only the first one will be attached.
- Does not support time, ctrl, mpos, mquat.
- If mjs_detachBody is used, all keyframes are removed.
PiperOrigin-RevId: 662517666
Change-Id: If6e3839471e1884afc14e1a75e7ce1957c2f3581
2024-08-13 08:00:01 -07:00
Saran Tunyasuvunakool acab66d799 Remove superfluous break statements. 2024-08-13 10:46:35 +01:00
Alessio Quaglino 851bb6eef4 Add option to mjspec for creating a texture directly from a buffer.
PiperOrigin-RevId: 662186527
Change-Id: I469c876681d52964ac971c0bb2ec3517224d3a3d
2024-08-12 12:29:08 -07:00
Kyle Bayes 20cae556ee Encapsulate BVH class members.
PiperOrigin-RevId: 662141171
Change-Id: Ica202d31dacc9cc500d0aeecded941b79002b9a1
2024-08-12 10:27:03 -07:00