Commit Graph

1042 Commits

Author SHA1 Message Date
Alessio Quaglino 7e46e21ef3 Add mju_mat2Rot.
This function extracts the 3D rotation from an arbitrary 3x3 matrix by refining the input quaternion. It is based on the paper "A robust method to extract the rotational part of deformations" by Müller, Matthias, Jan Bender, Nuttapong Chentanez, and Miles Macklin.

PiperOrigin-RevId: 700006006
Change-Id: I77550993233dea9cdf68601762a3ae7ded749bdf
2024-11-25 09:19:10 -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
Yuval Tassa 1d64362adc Add mjv_copyModel to copy mjModel, skipping large arrays not required for abstract visualization.
This functionality is meant for fast copying of `mjModel` when synchronizing the visualization state, as in the Python passive viewer.

PiperOrigin-RevId: 699199743
Change-Id: I13a5160063eb09139ec1aee9c4969bc1c6f547f1
2024-11-22 09:38:08 -08:00
Yuval Tassa cedd602bc1 Compress dense rows in mjData.actuator_moment
PiperOrigin-RevId: 698516133
Change-Id: Idd861c2b63d77748a6282d72f8241eaeeb88006c
2024-11-20 14:10:28 -08:00
Yuval Tassa 1767c11d46 Direct assignment of mjData.moment_rownnz
This allows for better sanitizer coverage, errors will be caught upon read rather than upon use.

PiperOrigin-RevId: 698458735
Change-Id: I3003f3a122b83bbf42a6510260abbb8353c56a40
2024-11-20 11:24:36 -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
Yuval Tassa 58d68d08d3 Refactor CopyPlugins() out of TryCompile()
PiperOrigin-RevId: 698072233
Change-Id: I2138d9d8383838328611eef463448fe2f15bd173
2024-11-19 10:46:53 -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
Yuval Tassa 5c23ae11ef Fix bug in material texrepeat attribute, fixes #2223.
Was mistakenly cast from float to int, bug introduced in 3.2.0

PiperOrigin-RevId: 697993181
Change-Id: I643a07e2b0866a4af56d7cbd3344e764a7caf56f
2024-11-19 06:30:55 -08:00
Kyle Bayes 0cb35a0fe1 Populate missing fields in mjCCDStatus in GJK code.
PiperOrigin-RevId: 696965759
Change-Id: Idf0799a44876e95fc8d688dd39663a34f1808b27
2024-11-15 12:24:37 -08:00
Kyle Bayes f91588a171 Fallback to polytope3 if tetrahedron from GJK has the origin on a face (most likely due to a numerical issue).
PiperOrigin-RevId: 696872633
Change-Id: I58edb0fdc30ad472c8f1338df728e8d42c25fc39
2024-11-15 06:53:00 -08:00
Kyle Bayes 0a0de6615d Back out of gjkIntersect when convergence fails due to algorithm oscillating between two support points. Also, fix related bug in box support function.
PiperOrigin-RevId: 696482893
Change-Id: Icedaf5489b761b8bf03ec30558b5d1128668a647
2024-11-14 05:12:32 -08:00
Yuval Tassa 536c60a0ac Print arena usage percentage in mjData print.
PiperOrigin-RevId: 696464274
Change-Id: Ib794148e037521118138bd72c021dbe086c9681a
2024-11-14 03:52:41 -08:00
Kyle Bayes 0e8cca93e1 Refactor nativeccd interface.
- Update mj_ccd interface for multi-contacts,
- Support GJK cutoff distance, and
- Remove mjc_fixNormal from nativeccd (causes bug with cylindar box collisions).

PiperOrigin-RevId: 696185362
Change-Id: I4828b7ee1bde078268220172a4937cd553f6187e
2024-11-13 10:28:45 -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
Kyle Bayes eb77d5b933 Fix bug in mesh hillclimbing support function.
PiperOrigin-RevId: 695710616
Change-Id: I2127aee584c13efb44d70cc4e267354ca0b80bf0
2024-11-12 06:36:55 -08:00
Yuval Tassa 414b677eb8 print memory footprint of model and data
PiperOrigin-RevId: 694088011
Change-Id: I3b743df2a59f554414b440aebfa6bf0d0e29b2d8
2024-11-07 05:56:02 -08:00
Yuval Tassa 18f88efe17 Contact visualization: if penetration is deeper than height, extend cylinder to show computed depth.
PiperOrigin-RevId: 693869892
Change-Id: I1c873e3803286d6a636336246f498552617e978b
2024-11-06 14:46:31 -08:00
Kevin Sayed 276f5b04cd Bump MuJoCo version to 3.2.6.
PiperOrigin-RevId: 693472991
Change-Id: Ic202f52dd42c55c43ba05ca21b5cc6a4024b0c72
2024-11-05 14:13:08 -08:00
Kyle Bayes c168ac3397 Add source code links in docs for remaining API functions.
PiperOrigin-RevId: 692728907
Change-Id: I145eb47453e6aa017505d53d3e17215959252e3d
2024-11-03 11:09:56 -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 ebe60b9ad5 Add const to mjsDefault when used as function argument.
Fixes #2197.

PiperOrigin-RevId: 692346264
Change-Id: Iddb9be1377a7d59c86911802d8c5563f6bf6b043
2024-11-01 18:18:42 -07:00
Taylor Howell a51f346059 Use sparse (uncompressed) actuator_moment in mj_transmission.
PiperOrigin-RevId: 692179704
Change-Id: Ic30ac5a98dc13de2028e378df65dc88ba3912bf5
2024-11-01 08:06:28 -07:00
Yuval Tassa c9f78ad8a8 Rename nnzJ to nJ in mjData.
This naming is more consistent.

PiperOrigin-RevId: 691858223
Change-Id: Ife3db822afa0b51b30d0792548b35b3742da388a
2024-10-31 10:43:10 -07:00
Kyle Bayes 18682aac6a Fix function definition formatting.
PiperOrigin-RevId: 691782530
Change-Id: Ib1611285e77e274b17074d5f09ede00cdc0c6f0f
2024-10-31 06:45:41 -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
Yuval Tassa 70d944b458 micro-optimization to mju_mulMatTVecSparse
PiperOrigin-RevId: 691431137
Change-Id: I95f94ff38ae911194b21aa220af35c7374af9739
2024-10-30 08:41:18 -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
Taylor Howell ce5f8b4728 Fix typo in mju_muscleDynamics comments.
PiperOrigin-RevId: 690949399
Change-Id: I8102fb72cce909786eab0771467c7f6f751792bf
2024-10-29 03:31:28 -07:00
Yuval Tassa 864b805a6e Fix multiple bugs related to connect and weld constraints with site semantics. Fixes #2179
The introduction of site specification to connects and welds in 3.2.3 conditionally changed the semantics of `mjData.eq_obj1id` and `mjData.eq_obj2id`. These changes were not properly propagated in several places leading to incorrect computations of constraint inertia, readings of affected force/torque sensors and runtime enabling/disabling of such constraints.

PiperOrigin-RevId: 690670420
Change-Id: I55ee8a013cbee8457f8d6c7f33c2981aedafbab6
2024-10-28 10:44:04 -07:00
Copybara-Service d95befaddd Merge pull request #2180 from pschmutz:schmutz/error_handling_when_loading_plugins
PiperOrigin-RevId: 690567811
Change-Id: I2d2c4e37e74ab4d97c0add5633feb766ef66dd08
2024-10-28 05:11:14 -07:00
Yuval Tassa d8494fef3b Remove deprecated mjv_makeConnector function.
PiperOrigin-RevId: 690563333
Change-Id: Ice9c6b6cf41de8a55fa361477f9aee9181d50184
2024-10-28 04:51:47 -07:00
Taylor Howell a36f2cccb6 Add nnz argument for size of allocated memory to mju_dense2sparse and check if this number is too small for number of non-zeros.
PiperOrigin-RevId: 690545825
Change-Id: I0e31cb907a1151cb2e4766d5f0cdfecb5629a2a6
2024-10-28 03:46:50 -07:00
Yuval Tassa 7dc8aef807 Remove the convexhull compiler option.
PiperOrigin-RevId: 690307675
Change-Id: I62d8213579ad07296ca96de004d39ae012174aa4
2024-10-27 04:31:10 -07:00
Yuval Tassa 61cb552f8a Refactor PBR texture layers from separate sub-elements to a single layer sub-element.
Add new element to PyMJCF schema.

PiperOrigin-RevId: 690115286
Change-Id: I7bb3f184cb321ca96037b2ca0ee160efef37469d
2024-10-26 07:41:38 -07:00
Philipp Schmutz 7cf457286d Print error instead of failing silently when loading plugins
Previously the return value of dlopen was ignored, meaning a failed load of a shared library would stay unnoticed
2024-10-26 16:22:47 +02:00
Yuval Tassa a3ea01e57e Remove deprecated mju_rotVecMat and mju_rotVecMatT functions.
PiperOrigin-RevId: 689405782
Change-Id: I0281376d5d6f5c31ea2603d61c03c7b94aaa6312
2024-10-24 09:15:23 -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
Kyle Bayes 1043633cc3 Remove arbitrary limit of a 1000 elements from certain attributes. Fixes #2166.
PiperOrigin-RevId: 689343609
Change-Id: I7cbf5007884433807c76c6c309cb4a858479d34d
2024-10-24 05:37:17 -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
Yuval Tassa e14aebfd16 Expose mju_sparse2dense to public API.
PiperOrigin-RevId: 688985153
Change-Id: I9559f1d47363d0afada80c86abdc729cd1910b63
2024-10-23 09:01:25 -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
Kyle Bayes 0c97dcf1fd Avoid overflowing the stack when allocating memory for polytope in EPA.
PiperOrigin-RevId: 688641864
Change-Id: I3eef7e821ffbfa8d97a946ecf86d098cb4f0c233
2024-10-22 12:11:22 -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
Kyle Bayes 708fd83a49 Remove goto statement from engine collision code.
PiperOrigin-RevId: 688539516
Change-Id: I29b5dd39acccde59df2dbcaf5e866eb6a0406c43
2024-10-22 07:22:18 -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
Taylor Howell 94e9912d28 Add mju_mulMatTVecSparse to multiply transposed sparse matrix and dense vector.
PiperOrigin-RevId: 688535240
Change-Id: I0bacf1e911cde99014b2dcb0a1434e61a4f41d51
2024-10-22 07:06:29 -07:00
Kyle Bayes 2b0629d75f Replace mjQUICKSORT with faster, native sorting function. fixes #1638
PiperOrigin-RevId: 688519096
Change-Id: I05ab1576703c2458968ef81915ac682a8beac391
2024-10-22 06:05:12 -07:00