Commit Graph

630 Commits

Author SHA1 Message Date
Yuval Tassa 1d47a91c19 Add a test for mj_solveM2
PiperOrigin-RevId: 717278730
Change-Id: I7507e569620c34f250482eec8402c08c793f4e48
2025-01-19 11:34:20 -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
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
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 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
Alessio Quaglino 6654d63438 Add spec lookup in the attached spec array using the compiler option pointer.
This enables to find the spec associated with the compiler option stored in the objects, which do not necessarily belong to the model that owns them.

PiperOrigin-RevId: 713259419
Change-Id: I579c770147ff07ed2a5edd20e7a795ee7cc27147
2025-01-08 05:44:00 -08:00
Yuval Tassa 8a5f092081 Allow CSR back-substitution to handle multiple vectors.
PiperOrigin-RevId: 713229673
Change-Id: I7a5b43fe966cf9e482bd41e2eea6c30dd3ffa1d4
2025-01-08 03:32:16 -08:00
Yuval Tassa 4d82ab5762 Add function to merge chains of indices.
PiperOrigin-RevId: 712863690
Change-Id: I15652bec03dc9ce90e230788bd12b44b1a2b8217
2025-01-07 04:42:11 -08:00
Yuval Tassa 1c69e64e6e Extend test comparing dense and sparse pipelines to all solvers.
PiperOrigin-RevId: 712862658
Change-Id: Ieb8515d32a225a098ab96055598a5d56bad7e476
2025-01-07 04:37:04 -08:00
Yuval Tassa 674d227050 Standardize names of sparse fill-in pre-counting functions
PiperOrigin-RevId: 712835830
Change-Id: I8e90dfa52af56ede917e1fd90b8d551898c244e5
2025-01-07 02:39:46 -08:00
Alessio Quaglino f607d9554e Check that there are no pending keyframes while writing a spec.
This can happen when a body is detached without compiling or recompiling.

Also added error catching when trying to delete a body instead of detaching it.

Fixes #2327

PiperOrigin-RevId: 712526730
Change-Id: I4b48df83120fca12d475c85b3a54893841449653
2025-01-06 07:50:30 -08:00
Yuval Tassa ac11e5faa6 Add CSR implementation of mj_factorI
PiperOrigin-RevId: 712498431
Change-Id: I13b52e53482ed97da8788875d4d95e2beb5ca7c1
2025-01-06 05:48:14 -08:00
Yuval Tassa 7eb8231fda Represent only the lower triangle in Newton solver's reduced dof-dof matrix.
PiperOrigin-RevId: 712488529
Change-Id: Iad91c72654376539791d7856765a0d0ac9088251
2025-01-06 04:58:55 -08:00
Alessio Quaglino ee6f4837f3 Auto-generate 3D mesh from convex OBJ if dim=3 in flex.
This requires the user to explicitly specify an origin.

PiperOrigin-RevId: 712483526
Change-Id: Ie316a5eccb676bb918d4bb746795019145c10f5b
2025-01-06 04:35:59 -08:00
Alessio Quaglino 65048d6b8f Do not use fast lookup for frames.
Fast lookup is not possible since mjOBJ_FRAME > mjNOBJECT, which is the size of the objects maps used for the search.

Fixes #2328.

PiperOrigin-RevId: 712479460
Change-Id: I7bcfa75ff8a1e288183d60ed4a44cab5bc6f4173
2025-01-06 04:17:41 -08:00
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 8dd360a2c0 Add some elements to test model.
PiperOrigin-RevId: 710067190
Change-Id: I478085b8177ea8ebfa4190db8eb722c306c9793e
2024-12-27 08:18:46 -08:00
Yuval Tassa ea98c57921 Clean up engine_core_smooth_benchmark_test.
PiperOrigin-RevId: 709573203
Change-Id: I461f259c33d74b3eaf0b6fe58124fe09418c5303
2024-12-25 07:44:25 -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
Yuval Tassa 3a14ada308 Store index of diagonal element for C and D in mjData.
PiperOrigin-RevId: 704287869
Change-Id: I15d1faa0b5c3ff54721f692ec6329726456ec318
2024-12-09 08:01:30 -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
Alessio Quaglino 10239a673b Change from parent ID to parent pointer in mjCBody.
This is required to have parent body info during attach and during body to frame tranformation for uncompiled models.

PiperOrigin-RevId: 703038426
Change-Id: Ib482059ba419a020860c649d6ea1b1088045f2e1
2024-12-05 02:32:56 -08:00
Alessio Quaglino afc86ac1b3 Associate children of deleted body to the newly created frame in mjs_bodyToFrame.
Also associate all children that need a parent body to the parent of the deleted body.

This is a bug that was causing the former children of the body that gets transformed to a frame to not be children of the new frame.

PiperOrigin-RevId: 702702853
Change-Id: I36d48f0446bc87c665b18d34e0b0609d82c70f51
2024-12-04 06:30:21 -08: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 82b6dbeb40 Copy attached spec before attaching anything else.
Spec were copied after bodies are attached, so the reference to the source spec got lost during mj_copySpec().

PiperOrigin-RevId: 701287267
Change-Id: I55eff53c7ae9d42b03957be48ea506b80d274e03
2024-11-29 07:41:49 -08:00
Alessio Quaglino e310c23267 Fix return value of mj_saveXML and mj_saveXMLString, fixes #2247
PiperOrigin-RevId: 700269761
Change-Id: Ifb7e9c66c70eac7d681cfcf106712d47291cf9e2
2024-11-26 02:32:50 -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
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
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
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
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
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 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
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