Commit Graph

1136 Commits

Author SHA1 Message Date
Alessio Quaglino 6aabbc1892 Fixes an issue when self-attaching a model with pulley in tendons.
The decision to attach a tendon is taken by looking at whether any of the elements in its path exist when the namespace is added to them. This does not work when pulleys are present so we need to ignore them in the count of unreferenced element.

PiperOrigin-RevId: 729484365
Change-Id: I561a3a2eaa975a17421c8abe3ebfec8d4dd88951
2025-02-21 04:54:31 -08:00
Yuval Tassa fe9fcae5dc Clean up mj_tendon.
PiperOrigin-RevId: 729042293
Change-Id: Id0d8483b71b9dbb99e19a67323034f3762e26346
2025-02-20 03:44:39 -08:00
Alessio Quaglino 6a86247810 Fix flex textures for 3D grids.
Fixes #2013.

PiperOrigin-RevId: 728673726
Change-Id: Idb2b6bf9e5392576d0b09f3e71dbea6f4636ae81
2025-02-19 07:59:22 -08:00
Kyle Bayes 7f3bb062c3 Add fields in mjModel for supporting mesh multicontact in nativeccd.
PiperOrigin-RevId: 728659204
Change-Id: I7f8a11b082640284ea009d8693f228078680b953
2025-02-19 07:12:26 -08:00
Yuval Tassa b516edae1b Rename inertia factorization routines:
```
mj_factorI -> mj_factorI_legacy
mj_solveLD -> mj_solveLD_legacy
mj_factorIs -> mj_factorI
mj_solveLDs -> mj_solveLD
```

PiperOrigin-RevId: 728246367
Change-Id: I3bc7804cb96faac2ae5419ba9abfc3c1648ed4c6
2025-02-18 09:42:05 -08:00
Yuval Tassa fb07e0d1f7 Convert qLD to CSR format.
PiperOrigin-RevId: 728196818
Change-Id: I31bdf32e251293284426ed345019f27fd051a0e1
2025-02-18 07:14:45 -08:00
Kyle Bayes 442b968e22 Improve box-box multicontact with nativeccd.
PiperOrigin-RevId: 728136635
Change-Id: I2343110e5c87b6621d5750c7ad42f0e75081d737
2025-02-18 03:41:26 -08:00
Alessio Quaglino 7f11a0df12 Add check for height fields size during compilation.
Fixes #2427.

PiperOrigin-RevId: 727805729
Change-Id: Idf3192e5fb238249faaeae6b4fb9de4c55755d96
2025-02-17 04:01:27 -08:00
Tom Power 78a4d2f389 Fix mass/inertia checking for moving bodies with nested children.
Previously, we only checked immediate children of moving bodies.

PiperOrigin-RevId: 726999705
Change-Id: I133a557daf86223b8751c6d46e25809781e168a1
2025-02-14 11:26:28 -08:00
Tom Power 89253d957d Changes to inertia inference from meshes.
PiperOrigin-RevId: 726051033
Change-Id: I6edfc118280d103a2dd9d07f29f0094858769761
2025-02-12 07:43:13 -08:00
Yuval Tassa e39a5df06a mju_compressSparse(): add option to compress away small elements.
PiperOrigin-RevId: 726010576
Change-Id: Ib6458037a5cf9a9d82abb364b7dda7aab2f36807
2025-02-12 05:08:20 -08:00
Yuval Tassa faed1a1137 Clean up mj_jacSparse.
PiperOrigin-RevId: 725994792
Change-Id: I928a6312a6910231bfeb96ef7a3f29f1d128565c
2025-02-12 04:06:00 -08:00
Kyle Bayes e3b9538d92 Add saving the indices of mesh vertices with the support points in nativeccd.
PiperOrigin-RevId: 725660975
Change-Id: I036882a5bde5d009bfa6e66b6a10f6cfb1a78292
2025-02-11 09:28:49 -08:00
Google DeepMind ac2a324fbd Reduce "shadow acne" artifacts
PiperOrigin-RevId: 725640931
Change-Id: I95df97d6076b99c12e291f69e8e54bbe70538293
2025-02-11 08:28:12 -08:00
Yuval Tassa 5ee0654830 Roll back recent change to mjData.qLD until some issues are resolved.
PiperOrigin-RevId: 724389161
Change-Id: I1b30ab0950ab5c5e611b1c6fc3bf3f42f964939c
2025-02-07 10:21:42 -08:00
Alessio Quaglino c1ecc50081 Store joint damping and stiffness in the private spec when springdamper is used in the public spec.
PiperOrigin-RevId: 724288204
Change-Id: I7341d5d804e1ea73ded48b8b447addd4e124ab97
2025-02-07 03:55:24 -08:00
Yuval Tassa c27d3758c2 Convert qLD to CSR format.
PiperOrigin-RevId: 723955038
Change-Id: I30c3dc7f59739e89ae5fff8841432bc74717ec1b
2025-02-06 08:59:35 -08:00
Copybara-Service cb1696eb34 Merge pull request #2390 from talregev:TalR/mesh
PiperOrigin-RevId: 723916727
Change-Id: I0abb0a12121c9eb291ccbc6afa0b4117bd389956
2025-02-06 06:46:40 -08:00
Alessio Quaglino fe16c27555 Always compute the convex hull if the mesh inertia is set to convex.
PiperOrigin-RevId: 723477903
Change-Id: Ibc50d62741f47a5b96a648efd8fb244810664c17
2025-02-05 05:52:10 -08:00
Yuval Tassa 49d07c6100 Fix text edit buffer underrun.
PiperOrigin-RevId: 723474334
Change-Id: Ibff6d83d67275e6c6333a00cabe33967913dceb1
2025-02-05 05:36:32 -08:00
Alessio Quaglino 0d4bc1de00 Do not use flexedge_length if trilinear interpolation is used.
PiperOrigin-RevId: 723452451
Change-Id: I5a67fb74c13e80ae6d390694dd0c9f8c5e4d5213
2025-02-05 04:09:32 -08:00
Kyle Bayes 3235f69afc Make polytope2 and polytope4 more numerically robust in nativeccd.
PiperOrigin-RevId: 723412555
Change-Id: Id262a3c19bcd30b74b1495591bdc95f951bfca50
2025-02-05 01:40:41 -08:00
Tom Power 3d9946cff3 Improve mesh processing readability
PiperOrigin-RevId: 721524528
Change-Id: I3af4e25815cbc7517b772826af7d929ea93f8164
2025-01-30 14:41:21 -08:00
Alessio Quaglino 7cdf180641 Introduce trilinear flex parametrization.
These flexes use only 24 DOFs (3 per vertex of the bounding box), while colliding with the full high resolution mesh.

On an 8x8x8 cube, the performance using DOFs at all vertices is

```
 Simulation time      : 18.74 s
 Steps per second     : 533
 Realtime factor      : 0.53 x
 Time per step        : 1874.4 µs

 Contacts per step    : 114.88
 Constraints per step : 3322.51
 Degrees of freedom   : 1536
```

With the new implementation, it is the following:

```
 Simulation time      : 1.82 s
 Steps per second     : 5507
 Realtime factor      : 5.51 x
 Time per step        : 181.6 µs

 Contacts per step    : 38.84
 Constraints per step : 155.36
 Degrees of freedom   : 24
```

PiperOrigin-RevId: 721008829
Change-Id: I833df027527db578d86667cc4b24295bcf6f7d22
2025-01-29 09:38:22 -08:00
Tal Regev fd568d68d4 Generalize mesh object to be the type of tiny_obj_loader. 2025-01-28 11:33:29 +02:00
Yuval Tassa 6a23841aad manually inline mju_combineSparse
PiperOrigin-RevId: 720326669
Change-Id: I03727291f133e3d481e73ad88735e54af8f62f1f
2025-01-27 15:22:18 -08:00
Yuval Tassa 9605990648 Replace custom sort of sparse fixed tendons with mju_combineSparse.
PiperOrigin-RevId: 720219887
Change-Id: I0491b3cb8987c119c3864fc0b5c38ca303d8f7f0
2025-01-27 10:24:58 -08:00
Yuval Tassa d86900aac1 Speed up mju_cholUpdateSparse by not checking for varying sparsity pattern where it is guaranteed to not vary.
PiperOrigin-RevId: 720126576
Change-Id: I3a43bdd0259656fab462b1cd155cb422982e970d
2025-01-27 05:07:28 -08:00
Alessio Quaglino 21d97902ee Check keyframe size before appending it during attach.
Fixes #2365.

PiperOrigin-RevId: 718455748
Change-Id: I20c56b7c6fbd868962d19682e72e6294edb6893e
2025-01-22 11:09:49 -08:00
Kyle Bayes aa505a7872 Add support for NativeCCD multiple contacts for box-box collision.
PiperOrigin-RevId: 718352304
Change-Id: Icaa827e716a2d7aa7c0c644e0ccd2913b476e6fb
2025-01-22 06:02:58 -08:00
Yuval Tassa 67dd4827a6 Improve printing of inertia-like matrices, allow mj_printData to take const mjData*
PiperOrigin-RevId: 718176884
Change-Id: I057dabe6973e19db86e9ff9ce4430c6d17dfce2b
2025-01-21 19:59:45 -08:00
Kyle Bayes bd1bbfe401 Fix bug where EPA horizon returns zero edges due to numerical inaccuracies in float32.
PiperOrigin-RevId: 717825833
Change-Id: I9fa440816765d4c3eaa0c6c26ec0bd90c774fa01
2025-01-21 02:50:53 -08:00
Yuval Tassa 2624d524ba Switch mj_solveM_island to use CSR representation
PiperOrigin-RevId: 717684720
Change-Id: I7d74a5d4aef4aa5b0c0acddf88c5b8591d63e88d
2025-01-20 18:36:04 -08:00
Yuval Tassa a5ab7a9515 Switch mj_solveM2 to use CSR representation.
PiperOrigin-RevId: 717639495
Change-Id: I59eee0f23606481480ec5acb8a3bba2c14b2ea2f
2025-01-20 15:16:26 -08:00
Kyle Bayes 600f4acb52 Change GJK and EPA return values.
PiperOrigin-RevId: 717549079
Change-Id: I42df5660bcc8336e2e9c8fce71385cbb06104848
2025-01-20 08:59:37 -08:00
Yuval Tassa 5c4c79cd6a Refactor LD back-substitution (CSR version).
PiperOrigin-RevId: 717403904
Change-Id: Idcd5e71f03a960203c22cb737d399fac5a0ba59c
2025-01-19 22:47:25 -08:00
Yuval Tassa 240a7afdee Add sensors for potential and kinetic energy.
PiperOrigin-RevId: 716775375
Change-Id: Ic8ab7f1a51df970ab551dabe7c797cde13cd97fd
2025-01-17 13:10:12 -08:00
Yuval Tassa 893a993bf6 Fix typos.
PiperOrigin-RevId: 716211176
Change-Id: Ibadfe13db89ed9047832b977e918faa3c5c6d9f1
2025-01-16 06:28:54 -08:00
Kyle Bayes 4da2ddce29 Only correct box-box collisions with the mjc_BoxBox function.
PiperOrigin-RevId: 716209565
Change-Id: I3419ce82f9934606bed80acd8372284fc7ac7ac8
2025-01-16 06:22:20 -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
Gabe Oppenheimer 6436055c6c Update the version number to 3.2.8 following the 3.2.7 release.
PiperOrigin-RevId: 715870970
Change-Id: I9fc9a09d959043f3029faa7296a717ea56f75c89
2025-01-15 11:13:27 -08:00
Alessio Quaglino 05d4c3d670 Add mjs_getParent to retrieve the parent body of an object.
PiperOrigin-RevId: 715794859
Change-Id: Ib9792787cdb966f579938dde3f94ebabca8ef1fc
2025-01-15 07:42:43 -08:00
Yuval Tassa d4ca66a47b Allocate dual-solver memory inside mj_projectConstraint, no more than required.
PiperOrigin-RevId: 714093658
Change-Id: Id7e710c5dffd24871019a72a7bf2aa6eb3f7a36e
2025-01-10 10:19:13 -08:00
Yuval Tassa 2409a6e537 Add mjData.nA the number of non-zeros in the constraint inverse inertia matrix.
PiperOrigin-RevId: 714076988
Change-Id: I4c323a6e81dfb23f7972b662719bbcb688bacf4a
2025-01-10 09:23:55 -08:00
Yuval Tassa ca6162e6d0 Refactor mj_projectConstraint to use CSR representation, don't allocate quadratic memory inside the function.
PiperOrigin-RevId: 714062168
Change-Id: Ib6ddd0e751fabcded20911e3ced59672be0da8b5
2025-01-10 08:32:05 -08:00
Yuval Tassa 00010f5848 Compute diagonal indices in mj_sqrMatTDSparse
PiperOrigin-RevId: 713714087
Change-Id: Icc8eae74e6e47ba1d12a6e9aa0d774ab006cfe38
2025-01-09 10:17:31 -08:00
Kyle Bayes daba00ca9d Fix a box-box bad collision in NativeCCD.
PiperOrigin-RevId: 713683497
Change-Id: I0c4cfd55d00faa196d8759046c87ee4ef74f01ab
2025-01-09 08:35:50 -08:00
Alessio Quaglino f7d38dac62 Add recursive call to FindSpec for handling nested attachments.
PiperOrigin-RevId: 713629578
Change-Id: I23efa5a86bac187fc42eb955d29cc03cbacfd9e0
2025-01-09 04:56:12 -08:00
Saran Tunyasuvunakool 357ea024c0 Remove unconditional mj_markStack in mjv_addGeoms.
Prior to commit 3f855f32d9, calling `mjv_updateScene` and `mjv_updateSceneFromState` on an "empty" `mjData` (one without a buffer but where all sizes are also zero) was a valid operation. The `mj_markStack` call requires free stack space, so a call to `mjv_addGeoms` on an empty `mjData` results in a stack overflow whenever `mjVIS_TENDON` is enabled.

Fixes #2305.

PiperOrigin-RevId: 713418586
Change-Id: I99b5de23fe94ba9aa86eeef0700c891976c9aecc
2025-01-08 14:32:44 -08:00
Yuval Tassa f912e8df16 Print sparsity structure of mjData.efc_AR
PiperOrigin-RevId: 713296073
Change-Id: Ifede6ea66dd1177f5e85c8498860decebaa65f06
2025-01-08 08:12:47 -08:00