Commit Graph

291 Commits

Author SHA1 Message Date
Kyle Bayes 340c0d7c97 Fix a box-box bad collision in NativeCCD.
PiperOrigin-RevId: 711773153
Change-Id: I8a526ef5933be19d863e67f40edeb95b0b1249cd
2025-01-03 09:23:57 -08:00
Yuval Tassa 923f75fd23 Use only lower triangle in CSR back-substitution.
PiperOrigin-RevId: 711686157
Change-Id: I4fc98cdfb927e5608ce3a99ea34890ce556fcfd7
2025-01-03 02:33:59 -08:00
Yuval Tassa 4510c6d290 Further speedup to CSR back-substitution using dof_simplenum.
PiperOrigin-RevId: 711440268
Change-Id: I81cd9a6a8b8ec78d08cfbc34f60a9216ea753833
2025-01-02 09:04:51 -08:00
Yuval Tassa ec322641b7 Fix bug in mj_mulM2.
PiperOrigin-RevId: 710756899
Change-Id: I30c0725859ba0f1a59750dc89eebb9eba84fa71b
2024-12-30 11:14:56 -08:00
Yuval Tassa 273ced428a Add simple unit test for mjv_updateScene.
PiperOrigin-RevId: 709334033
Change-Id: I69adc1d3ad0565f3684346749a372894d12ce99a
2024-12-24 06:44:02 -08:00
Copybara-Service 526637f118 Merge pull request #2276 from traversaro:reducetestboilerplate
PiperOrigin-RevId: 707613522
Change-Id: Ic945c6b057b77f3462dbdb758139af12133f6a8f
2024-12-18 11:22:59 -08:00
Kyle Bayes ec230fa4b6 Prune face linear map in EPA.
PiperOrigin-RevId: 705138358
Change-Id: I835ce7094d066b19ee39af48e0b83b51f7a0954e
2024-12-11 09:44:19 -08:00
Yuval Tassa 3ca97248a3 Fix comparison in engine_core_constraint_test.
(was comparing number to itself)

PiperOrigin-RevId: 705053943
Change-Id: I3d179ab4bb2ed1bc1b74b4edec7ce1114ad16b37
2024-12-11 04:11:13 -08:00
Kyle Bayes a364308d5a Use GJK to recover contact points for sphere and capsule geoms in nativeccd.
PiperOrigin-RevId: 704727907
Change-Id: Iff641b6a32637c48e9892dbaa60826617c54ed06
2024-12-10 08:53:27 -08:00
Yuval Tassa 1c4c7b012c CSR implementation of mj_solveLD.
PiperOrigin-RevId: 704316200
Change-Id: Ibaff0284e40b3ebbe43bb489b6211ce739270e27
2024-12-09 09:34:17 -08:00
Silvio 756a8d716a Reduce cmake test boilerplate
All instances of mujoco_test in the code base were followed by
a call to  target_link_libraries(<testname> fixture gmock).

As anyhow mujoco_test already was calling target_link_libraries
to some predefined list of targets (mujoco and gtest_main),
this PR adds to the list of default linked targets also fixture
and gmock, to reduce the boilerplate.

Furthermore, to completly remove the need for calling
target_link_libraries after a call to mujoco_test, this PR also
add to the mujoco_test macro the ADDITIONAL_LINK_LIBRARIES
argument, that can be used if a given test needs to link some
additional targets beside the default ones.

To permit to use these new features also for mujoco benchmarks,
this PR adds a MAIN_TARGET parameter to mujoco_test, to select
if gtest_main or another target is used to provide the main
entry point to the test executable.
2024-12-07 17:14:20 +01:00
Yuval Tassa 0e7d2ef6df Fix bug in box-sphere collider. Fixes #2206
PiperOrigin-RevId: 702627603
Change-Id: Ie6015b7fa6f8507459325d692581b0f5f83aa159
2024-12-04 01:19:27 -08:00
Yuval Tassa 13d3bdedad Add debugging method for printing matrices to stderr to fixture.h
PiperOrigin-RevId: 702301299
Change-Id: I01738b6634a91cde6b146475d06731471dcf3764
2024-12-03 05:20:54 -08:00
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
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
Kyle Bayes cd84011d7b Default to nativeccd for geomDistance test.
PiperOrigin-RevId: 698340192
Change-Id: I814286903e1726462b24390eb2c3dc5b3b76899e
2024-11-20 04:14:24 -08:00
Kyle Bayes 867e8b8adb Fix ARM issues with tests with nativeccd.
Note: frameless_contact_hfield.xml doesn't work with libccd nor nativeccd on ARM as expected.
PiperOrigin-RevId: 698317464
Change-Id: I4c57e04639b9870b416c67d79a16a313c5276cf6
2024-11-20 02:30:15 -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 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 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
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
Yuval Tassa e889cffe23 Clarify in mju_boxQP test that for the synthetic test set, the average number of factorizations is expected to be 5 or less, while the worst case is expected to be 6 or less.
PiperOrigin-RevId: 691037804
Change-Id: Id0bc8bedf08d623efcacbe696775f0ef0f6781b9
2024-10-29 08:55:50 -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
Yuval Tassa a4a6248a06 Move AsVector utility to fixture.h
PiperOrigin-RevId: 690577546
Change-Id: I2cebcffa1f2e3b0789f43e772e364c4762719ab3
2024-10-28 05:52:25 -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
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
Yuval Tassa 90bc4b555d Add box-box collision to collection of collision performance benchmark models.
Cosmetic tweaks to existing models.

PiperOrigin-RevId: 688133030
Change-Id: I8085b8288d67b75e1cbcbcac0dfa68fccc7d63ca
2024-10-21 07:45:54 -07:00
Yuval Tassa 0ffaeb4d56 Improve comments in mju_cholFactorNNZ, clarify that this function reads from the upper triangle of the source matrix.
PiperOrigin-RevId: 686113654
Change-Id: I029f9279d177f4cb9ff60396a26d64821aee3a6c
2024-10-15 08:26:07 -07:00
Kyle Bayes 8d84b5f693 Disable hfields for collision sensors.
PiperOrigin-RevId: 685730321
Change-Id: Ib1d4a90b7b31ca388e018076a274e25c40409080
2024-10-14 09:19:11 -07:00
Yuval Tassa 7ec94f46d4 Refactor Newton solver: move Hessian from arena back to the stack.
The changes in 9a0dc20821, moving the Hessian from the stack to the arena, should be rolled back: they prevent future threading over islands. Unlike the stack, arena allocations are not thread-friendly. The reason for the original move was to save memory, but the savings are small: `O(ctx->nH)` and only linear in `nv`. The significant reduction of the Cholesky factor, from quadratic in `nv` to quadratic in the largest dof island — the reduction afforded by 2dd518734f — remains in place.

Also refactor and improve readability.

PiperOrigin-RevId: 685717356
Change-Id: Ia9ec3e44a62d459a3b9cffb578cf6479d5aa1d7f
2024-10-14 08:34:16 -07:00
Kyle Bayes 70d6655434 Add faster support functions for NativeCCD.
PiperOrigin-RevId: 684809392
Change-Id: I5125d4bb74c167d370aa919befba9d356c7162da
2024-10-11 05:59:30 -07:00
Yuval Tassa 3f3fe92860 Remove unused argument in mju_sqrMatTDSparseInit
PiperOrigin-RevId: 682375566
Change-Id: If05f5d15a2f8925eee9dd0ebc5d485164d90d787
2024-10-04 10:45:33 -07:00
Taylor Howell 6a6e10d779 Add mju_cholFactorNNZ to compute the number of non-zeros per row for sparse Cholesky factorization.
PiperOrigin-RevId: 679553197
Change-Id: I6f92deec347dae97d2e219cfb5376f92e777da1a
2024-09-27 05:39:08 -07:00
Kyle Bayes 04f8403d8e Add unit tests for NativeCCD to produce better test coverage.
PiperOrigin-RevId: 677793306
Change-Id: I435865f00553c74d1d0c0fa86d9c41fb1e5497ff
2024-09-23 07:55:39 -07:00
Kyle Bayes 7a92423cf2 Add height fields to list of discrete objects in NativeCCD.
PiperOrigin-RevId: 676452215
Change-Id: I5d6a0d1e26ee852c774b44f550c1d0531b7a269b
2024-09-19 09:48:41 -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
Kyle Bayes bd811a44e7 Remove redundant copying in NativeCCD and refactor code for readability.
PiperOrigin-RevId: 675573079
Change-Id: If9f7bc21d9ee7806997f05a8985ebe6b1b3c8332
2024-09-17 08:14:10 -07:00
Yuval Tassa fb56d70dee Add model with mixed geoms for CCD performance testing.
PiperOrigin-RevId: 675567065
Change-Id: I9629b0757270ca541a96bb64384b5c41e7a9b728
2024-09-17 07:56:35 -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
Kyle Bayes 5144be2baa Add unit tests for NativeCCD.
PiperOrigin-RevId: 673849092
Change-Id: Ie703c9f461bb483fd3335d1ba589211205c73c8c
2024-09-12 08:03:18 -07:00
Kyle Bayes 8d165d5cc7 Fix early termination in GJK. It's possible for x_k to be the origin, so we should run the previous test to conclude that the objects are colliding.
PiperOrigin-RevId: 673834101
Change-Id: I596b30d2847670261f8067840b34dc13de401ecb
2024-09-12 07:17:53 -07:00
Yuval Tassa 4e3dc14f8e Remove model/humanoid100/humanoid100.xml (used <include>), replace with model/humanoid/humanoid100.xml (uses <attach>)
PiperOrigin-RevId: 673123895
Change-Id: I0c3c6dac69d9fc12a6ea76d586c34503fc167bad
2024-09-10 15:14:04 -07:00
Kyle Bayes 44145742a7 Exit GJK early if geom distance doesn't need to be recovered.
PiperOrigin-RevId: 672334991
Change-Id: I4af582c799140ccf3ac4d51952e547b08ab5d55e
2024-09-08 14:57:50 -07:00
Kyle Bayes 4fc6fb179b Remove libccd compatibility layer from native ccd.
PiperOrigin-RevId: 671740643
Change-Id: If3c1097df5c505f70c2dc0c090a7f5a93a43c683
2024-09-06 06:56:01 -07:00
Yuval Tassa 8954a088ce Add automatic free-joint alignment.
PiperOrigin-RevId: 671010083
Change-Id: Ib7d60f75c7f545b1886703715663db8de77feeef
2024-09-04 10:07:33 -07:00
Yuval Tassa 2d3d5415b7 Add mj_jacDot: Time derivative of kinematic Jacobian.
PiperOrigin-RevId: 670505417
Change-Id: Icf30cff5dc955e002bd2f5d5fb3a04f8388d0780
2024-09-03 04:49:47 -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