Commit Graph

207 Commits

Author SHA1 Message Date
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 82b6dbeb40 Copy attached spec before attaching anything else.
Spec were copied after bodies are attached, so the reference to the source spec got lost during mj_copySpec().

PiperOrigin-RevId: 701287267
Change-Id: I55eff53c7ae9d42b03957be48ea506b80d274e03
2024-11-29 07:41:49 -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
Taylor Howell a1b18e707a Compress actuator_moment memory using nJmom <= nu x nv.
PiperOrigin-RevId: 698446692
Change-Id: I49c9633e12129a1e690724db82d1f11204e41d9c
2024-11-20 10:53:07 -08:00
Taylor Howell aae5fd6906 Add nJmom, the number of non-zeros in sparse actuator_moment matrix, to mjModel.
PiperOrigin-RevId: 698343986
Change-Id: I3d4a4dea1ec095d4e7b231c2fffc0e6241cee39f
2024-11-20 04:30:47 -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 831d9881d3 Remove box, cylinder and ellipsoid composite types.
Also, fix a bug with Flex textures that was causing an incorrect allocation of the textures in mjModel. Fixes #2013.

PiperOrigin-RevId: 692510858
Change-Id: If781716216974e085244da27bc3aa57d91c3458c
2024-11-02 11:14:13 -07:00
Alessio Quaglino 94bbf297fc Replace flex_xvert0 with flex_vert0
`flex_xvert0` stored the Cartesian position of the vertices in `qpos0`. This array was unused, so it is now replaced with `flex_vert0`, which still contains the positions of the vertices, but normalized on the bounding box of the flex so that the coordinates are in `[0,1]^m->flex_dim`. This will be useful in the future for using different interpolation methods for computing flex deformations.

PiperOrigin-RevId: 691779361
Change-Id: I5c4223103cd4558f4e268fe3e8d8177541e4754f
2024-10-31 06:30:36 -07:00
Alessio Quaglino b941e994d9 Move keyframe resizing from compilation to attach (mjCModel::operator+=).
This allows to resize parent keyframes also when the child has no keyframes.

PiperOrigin-RevId: 691045299
Change-Id: I3ab6509b13b5754e937ec77daf9efe697cabf1bc
2024-10-29 09:17:55 -07:00
Yuval Tassa a4a6248a06 Move AsVector utility to fixture.h
PiperOrigin-RevId: 690577546
Change-Id: I2cebcffa1f2e3b0789f43e772e364c4762719ab3
2024-10-28 05:52:25 -07:00
Yuval Tassa 7dc8aef807 Remove the convexhull compiler option.
PiperOrigin-RevId: 690307675
Change-Id: I62d8213579ad07296ca96de004d39ae012174aa4
2024-10-27 04:31:10 -07: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 d17d9e835c Do not delete attached specs after compilation.
Also, copy them when copying the spec.

PiperOrigin-RevId: 688998464
Change-Id: I7229fd8032eafede582194ccf73ab4160fe06768
2024-10-23 09:42:05 -07:00
Alessio Quaglino b598d79b3f Move mesh inertia specification from global <compiler> to <asset/mesh>.
Three options:
- Convex: Use convex hull
- Exact: Use exact geometry (requires watertight mesh)
- Legacy: Legacy approximation (deprecated)

Fixes #2152

PiperOrigin-RevId: 688949900
Change-Id: I4537f343db917195c6fd58d517b189d5ee3be1cd
2024-10-23 07:06:31 -07:00
Alessio Quaglino 9e1aa37b55 Do not self-attach custom tags.
Fixes #2162.

PiperOrigin-RevId: 688518165
Change-Id: Iad90e159514c96635676a8dd53fca41e3998d8fc
2024-10-22 06:04:07 -07:00
Alessio Quaglino a70aea918c Prevent duplicated pairs in active_pugins vector.
Fixes #2150

PiperOrigin-RevId: 688164615
Change-Id: I9a5434a9dda28a399ffccfe0c4b31fa64400b85f
2024-10-21 09:30:27 -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
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 c84f35b425 Do not delete pending keyframes during body detachment.
PiperOrigin-RevId: 685670895
Change-Id: Iadd0ba8ca7e74a280559168ac0ac855405a1cfd9
2024-10-14 05:23:46 -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 52a0149cd1 Resizes keyframes before storing them during attach/detach.
Improve keyframe tests.

PiperOrigin-RevId: 685450257
Change-Id: I97aa129c4d7a66f613290605b85657e8081700b6
2024-10-13 10:02:35 -07:00
Alessio Quaglino cdb167f275 Add mjs_attachToSite for attaching a body to a site.
PiperOrigin-RevId: 684432183
Change-Id: I7100bebfb6521f9dbfbb07f31490b2b9298bf18c
2024-10-10 07:12:49 -07:00
Mohammad Hamid 694bdebc19 Fixed a bug that caused dim to be necessary in flexcomp even when it was inferred from GMSH files.
Fixes #2107.

Co-authored-by: Alessio Quaglino <quaglino@google.com>
PiperOrigin-RevId: 684419740
Change-Id: Ia73e719bd37503563223ed92f4dbe0ae07eef300
2024-10-10 06:20:43 -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 42c1718d57 Restore RecompileCompare test that was deactivated by mistake.
PiperOrigin-RevId: 682310735
Change-Id: I5edf487b194e195de0ff712ad55c2b198de2ef51
2024-10-04 07:20:13 -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 249c4b3f4f Prevent attaching models with different eulerseq, autolimits, or angle options.
PiperOrigin-RevId: 681801855
Change-Id: Iaf107853797768270319e971a3e318db0703bca0
2024-10-03 03:27:47 -07:00
Alessio Quaglino 36ee89d6da Copy only referenced plugins.
Fixes #2111.

PiperOrigin-RevId: 681486400
Change-Id: I384ac63fa76b27d6e84d91fa857127c42ff52e34
2024-10-02 09:40:48 -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 6832df3091 Replace mjs_setActivePlugins with mjs_activatePlugin.
PiperOrigin-RevId: 680613007
Change-Id: Ic03e0dc42a1f5f083e313672bc6e3ccebadc58b3
2024-09-30 09:46:47 -07:00
Alessio Quaglino e6e6e3b51b Copy plugins when attaching a model.
Before this CL, the same mjCPlugin objects were referenced by both models.

Fixes #2100.

PiperOrigin-RevId: 680579479
Change-Id: Ida3459f78f9fa4a942cea31b3d5d3e8da2832feb
2024-09-30 08:08:12 -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 bb6da503dc Make 3 the default number of channels in mjsTexture.
PiperOrigin-RevId: 679521155
Change-Id: Ie6c962e75983c8bf8323170338b3d480be3a1117
2024-09-27 03:33:04 -07:00
Alessio Quaglino f0d52813b8 Copy joint state to the modified mjSpec when detaching bodies.
Fixes #2085.

PiperOrigin-RevId: 678351210
Change-Id: I2a546877dd50abc7805099f8d5c40807ffe780e6
2024-09-24 12:26:29 -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
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
Alessio Quaglino 015bdeb756 Disallow repeated nameless assets that use the same file, except for URDFs.
PiperOrigin-RevId: 675114055
Change-Id: I142811ac2d8ef9e12bb8a06d5f3a2fdac02946da
2024-09-16 05:50:50 -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 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