Commit Graph

407 Commits

Author SHA1 Message Date
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
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 5927b3d4d9 Add time to attached keyframes.
PiperOrigin-RevId: 662886533
Change-Id: If9118a226250d2e806d184c9715c7e6a1390fd95
2024-08-14 05:47:43 -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
Kyle Bayes 39896f8064 Restructure mjCMesh for caching.
PiperOrigin-RevId: 662496475
Change-Id: I4c3a58a63ef2c3b1196b3e6b30eb556b5528ff7f
2024-08-13 06:40:36 -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
Alessio Quaglino 648fd56ed1 Preserve time when recompiling a model.
Fixes #1890.

PiperOrigin-RevId: 662084324
Change-Id: I6aed40761cee5044e63426935d102123db295b25
2024-08-12 08:00:36 -07:00
Yuval Tassa d3a976e10d Fix indent.
PiperOrigin-RevId: 662035313
Change-Id: I30ec124e8144b8130623daa6b0802a46de124aec
2024-08-12 04:23:48 -07:00
Yuval Tassa d45d13e5ad Remove uses of mjtNum-typed functions from user_objects.cc
PiperOrigin-RevId: 662026275
Change-Id: Idfb2b6ced6eac4b4b60079e219aac63fc1d00b89
2024-08-12 03:45:43 -07:00
Yuval Tassa 02ffaa8248 Yet another GCC-related fix.
PiperOrigin-RevId: 661595661
Change-Id: Ib66a0d891533be50451adc850d7350532fc39d67
2024-08-10 05:32:28 -07:00
Yuval Tassa d72f01bad4 Add break statements in user_objects.cc to appease persnickety GCC
PiperOrigin-RevId: 661590599
Change-Id: I2d167ca92cc4d5230922d221c9267a2e8d018b40
2024-08-10 04:56:18 -07:00
Yuval Tassa e397fcb5a5 Add return values to private mjJCJoint methods.
PiperOrigin-RevId: 661438758
Change-Id: I08a77eb878703610ead526040d86f3f3fccb080b
2024-08-09 16:09:17 -07:00
Taylor Howell 466368efc6 Add shellinertia support for primitives: sphere, capsule, cylinder, ellipsoid, and box.
PiperOrigin-RevId: 661407997
Change-Id: Icddac58c540c71ea26ac7a3be874788443bd1122
2024-08-09 14:40:13 -07:00