Commit Graph

423 Commits

Author SHA1 Message Date
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 6a415da267 Make from_file() and from_string() classmethod functions.
This prevents the user from modifying an mjSpec and then calling the functions to load it from string/file.

PiperOrigin-RevId: 679311284
Change-Id: I4f1ae3cc8f15bece245f624303470d538deec410
2024-09-26 15:16:10 -07:00
Alessio Quaglino 1eb6fc2285 Disallow using elasticity and edge constraints at the same time.
Fixes #2084.

PiperOrigin-RevId: 678614880
Change-Id: I44eead3dc4edf82d725a3063b927a421c660721a
2024-09-25 02:56:20 -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
Yuval Tassa 5219893813 Replace mjQUICKSORT with std::stable_sort in user_mesh.cc
PiperOrigin-RevId: 677864209
Change-Id: I1cca8e1ae8c84e652b12c24cfddfbca97d8c6841
2024-09-23 11:06:46 -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 4998e7b392 Move flex damping to the engine and remove membrane and solid plugins.
PiperOrigin-RevId: 676434954
Change-Id: I24e8dbaa90afcffd613a9cf106ef8b7262195328
2024-09-19 09:01:30 -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
Alessio Quaglino 66a9cacc90 Move elasticity force computation to the engine.
PiperOrigin-RevId: 676028775
Change-Id: I994e3dda8d6470815763c04df0c276e265aa1f54
2024-09-18 09:55:00 -07:00
Alessio Quaglino ddbc083810 Move elasticity computation to mjCFlex.
PiperOrigin-RevId: 675949380
Change-Id: Ia48f4fd6ae1ede206ccacd1205914e7e4b3c7aec
2024-09-18 05:23:10 -07:00
Yuval Tassa 2ffa0fe942 Avoid freeing model and/or data twice in case of errors during the compilation process.
PiperOrigin-RevId: 675136721
Change-Id: Ibe01216f86893db44a8279c560c307726fb03f81
2024-09-16 07:18:15 -07:00
Alessio Quaglino 31abd7900a Add edge ids to flex elements in mjModel.
PiperOrigin-RevId: 675130981
Change-Id: If2ccfb268142d235273b7a50e15740f6399903b2
2024-09-16 06:58:10 -07:00
Alessio Quaglino b15de2c951 Add elasticity parameters to the schema.
PiperOrigin-RevId: 675115200
Change-Id: Ic6608ce61cbb857dca71b3d9cbdac057e8f1ac7a
2024-09-16 05:56:36 -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 2da15cf137 Add flex elasticity stiffness matrix to mjModel.
PiperOrigin-RevId: 675101645
Change-Id: Ic169c108b9eece3657ea4ec211df357abe615b7e
2024-09-16 05:00:54 -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
Yuval Tassa fd17b2144a Replace double- or single-precision-denominated function calls in the engine with the equivalent mjtNum-denominated calls. This avoids unnecessary casting or precision loss when MuJoCo is compiled for 32-bit float precision. Accordingly, remove #include <math.h> from all engine source files.
build / windows-2022 (push) Has been cancelled
build / macos-12 (push) Has been cancelled
build / ubuntu-20.04-clang-10 (push) Has been cancelled
build / ubuntu-20.04-clang-11 (push) Has been cancelled
build / ubuntu-20.04-clang-12 (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-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-22.04-gcc-9 (push) Has been cancelled
Also, minor type-related fixes in `user_mesh.cc`.

PiperOrigin-RevId: 675082329
Change-Id: Icc5eb9f9eb4fbf09b08d7d4b9b2929f414e4a75c
2024-09-16 03:40:17 -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
Alessio Quaglino 4862b9e765 Remove plugin support from Composite particles.
This functionality is replaced by FlexComp.

PiperOrigin-RevId: 672503965
Change-Id: I58953267de285f82e416f9f60576a336b7d0da4c
2024-09-09 04:58:26 -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
Alessio Quaglino 0e8c0b80eb add content_type to model in the XML schema.
PiperOrigin-RevId: 670961443
Change-Id: I98cd6bb61b50029cdd4f5b31e23d268989d136da
2024-09-04 07:25:55 -07:00
Yuval Tassa 3437361bfb Add reduced sparse dof-dof matrix structures to mjData.
PiperOrigin-RevId: 670919263
Change-Id: I3592de802ae84648d97230115c2e9c3437424968
2024-09-04 04:24:02 -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
Alessio Quaglino 505d01a1c1 Add error handling to mj_recompile.
This CL adds error handling to the mj_recompile function. If the recompile fails, the function will return -1 and set the error message in the spec. The Python wrapper for mj_recompile will catch the error and raise a ValueError exception.

PiperOrigin-RevId: 666784579
Change-Id: I225eca1769ea839c782be3c03fc4ff1ea5885a48
2024-08-23 07:18:28 -07:00
Yuval Tassa 2efbd31762 Add mjSAMEFRAME_BODYROT and mjSAMEFRAME_INERTIAROT frame alignment shortcuts.
PiperOrigin-RevId: 666318799
Change-Id: I0af1824d2bd9eaca7b48a9e33e09f873dd33b22d
2024-08-22 06:08:25 -07:00
Yuval Tassa 8b03daa09b Add mjtSameFrame enum to specify frame alignment of bodies with their children.
PiperOrigin-RevId: 666303674
Change-Id: I53dc56e1ca52afa280ae5abaf4158edc465fb1e0
2024-08-22 05:17:06 -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 5d91231d31 Rename mjBuffer to mjByteVec.
PiperOrigin-RevId: 664872558
Change-Id: I7b003374c390958667635fb21089faf2ece54b14
2024-08-19 10:40:26 -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
Michael Ahn 9924d9ca89 Fixed incorrect mesh face circumradius calculation
- In 8e2f830, this was changed from `mju_norm3` to `mjuu_normvec`, but the
  latter will mutate its input to be normalized instead of just
returning the norm (the former was likely mistaken as `mju_normalize3`
which does mutate its input).
2024-08-15 20:53:57 -07:00
Alessio Quaglino e0e134ca63 Add plugin tests for mjSpec.
Fixes #1903.

PiperOrigin-RevId: 663352920
Change-Id: I3a9e17aec5694e49c20b542f4b0a4402f88a2f17
2024-08-15 10:19:53 -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