Commit Graph

279 Commits

Author SHA1 Message Date
Yuval Tassa 1aa375ef9a Allow RHS vector in mj_mulM_island to use uncompressed memory.
PiperOrigin-RevId: 562605681
Change-Id: If34bceed9eade59957ac9fd9b6a41fb736b58024
2023-09-04 13:56:54 -07:00
Yuval Tassa 600c12533d Add mj_constraintUpdate_island.
PiperOrigin-RevId: 562581620
Change-Id: If156a02873168127e2c5f2f377532fd45f7eec1c
2023-09-04 10:33:34 -07:00
Yuval Tassa b7686440d1 Indent a couple of #ifdef bodies.
PiperOrigin-RevId: 562572883
Change-Id: I44e2d6dc486ed7a181ca4614b1bf3f2f762f52f9
2023-09-04 09:32:35 -07:00
Yuval Tassa 5cef4708f2 Allow mj_mulJac(T)Vec_island to read and write from uncompressed vectors (length nv or nefc).
PiperOrigin-RevId: 562547310
Change-Id: Id517c1842e711639f4113d23cc364945839a3759
2023-09-04 06:51:51 -07:00
Saran Tunyasuvunakool 0e36f00857 Fix more mjData stack leakages.
PiperOrigin-RevId: 562545230
Change-Id: I2facf25b00878669dc12d5865767a44229d2ca48
2023-09-04 06:38:50 -07:00
Saran Tunyasuvunakool 5a21e202ed Eliminate mjContact copying during collision detection.
This results in approximately 4-5% speedup in collision detection for particle.xml.

PiperOrigin-RevId: 562526634
Change-Id: Ia6487b1908618064d858bac484fe6861ed37a402
2023-09-04 04:46:26 -07:00
Yuval Tassa feb8aa2fbb Fix bugs in engine_island.c
PiperOrigin-RevId: 562519702
Change-Id: I3075e539ccc1cef92485152721a9344f180aa4b1
2023-09-04 04:06:39 -07:00
Saran Tunyasuvunakool 89f47c33e4 Fix mjData stack frame leakages.
PiperOrigin-RevId: 562091591
Change-Id: Ia7bb8a70ccba6bd40edc06ad8ebfac16e4286836
2023-09-01 17:57:39 -07:00
Saran Tunyasuvunakool 33f51856c1 Check that alignment is power of 2 in mj_stackAlloc.
PiperOrigin-RevId: 562024496
Change-Id: I9230c6dc05ebb78e935f9b2f606aa77c921d67e5
2023-09-01 12:45:35 -07:00
Yuval Tassa 29aa5e4a41 Allow dot products with sparse vectors to specify that one vector uses uncompressed memory.
PiperOrigin-RevId: 561951337
Change-Id: I1310d7c09d9a85ad9b43877155844a9d0ce6edab
2023-09-01 07:40:16 -07:00
Yuval Tassa 02e819e76a Tighten const qualifiers of mjData in Jacobian multiplication functions.
PiperOrigin-RevId: 561711229
Change-Id: I66dc1d2fbcfbf8e935b244fe496ada314d53b135
2023-08-31 11:27:15 -07:00
Yuval Tassa f9c57f6213 Refactor a loop in mj_constraintUpdate.
PiperOrigin-RevId: 561684763
Change-Id: Ifbca1793760ecb49f4b48a1a236bd7c1c6e73d0e
2023-08-31 09:59:40 -07:00
Yuval Tassa eaa2572a8b Add private function mj_mulJacTVec_island for Jacobian transpose multiplication with sub indices corresponding to one island.
PiperOrigin-RevId: 561672392
Change-Id: Ic72fd7de2a542603cc42e1c15ecb4edd27a9a986
2023-08-31 09:12:34 -07:00
Yuval Tassa 85fd922b37 Add private function mj_mulJacVec_island for Jacobian multiplication with sub indices corresponding to one island.
PiperOrigin-RevId: 561648540
Change-Id: I8080a620807e824b40b5d6ba484beb06d081d444
2023-08-31 07:28:24 -07:00
Yuval Tassa 9fd186ac2b Add private function mj_mulM_island for mass matrix multiplication with sub indices corresponding to one island.
PiperOrigin-RevId: 561639405
Change-Id: I3777cea51ef22f6847b3cf3e17bdac5cf621c019
2023-08-31 06:42:33 -07:00
Yuval Tassa 129abc6bca Add private function mj_solveM_island for mass matrix solve with sub indices corresponding to one island.
PiperOrigin-RevId: 561622962
Change-Id: Ib43f03b3dd0c7456c57d4ba45a68e0708bf1c91c
2023-08-31 05:11:00 -07:00
Google DeepMind ba5cf4d54d Address -Wint-conversion issues.
PiperOrigin-RevId: 561604684
Change-Id: I31af8621f8506d2e029c4ca630982f82ea4cfca9
2023-08-31 03:25:02 -07:00
Yuval Tassa ac150f751d Clean up mj_mulM.
PiperOrigin-RevId: 561404770
Change-Id: Ie802f5d7f1df6bf32d4549d3db6809d0f507d1e1
2023-08-30 11:46:55 -07:00
Kyle Bayes 16ee0dfde5 Add modified callback to resource providers (for caching purposes).
PiperOrigin-RevId: 561327623
Change-Id: Id6683f6d6d32ee91019aba46599c28cbffe29df6
2023-08-30 06:53:20 -07:00
Kyle Bayes f86e8b449f Refactor VFS logic out of ResourceProvider plugin code.
PiperOrigin-RevId: 561302536
Change-Id: I952f9e76e85a7e3a111e0338f307378a6ff58197
2023-08-30 04:47:24 -07:00
Saran Tunyasuvunakool 215433f5f7 Implement mj_stackAlloc and mj_arenaAlloc alignment using bitwise-and.
This implementation explicitly avoids calling division instructions (which are generally expensive) even when link-time optimization is not active or if the alloc functions aren't inlined for some reason.

Also make mj_stackAlloc cheaper for external callers who may be linking against MuJoCo dynamically (and therefore cannot benefit from inlining).

PiperOrigin-RevId: 561299565
Change-Id: Iea4be5bf6d351ddf0c9d1fd8bd89a0c207b39309
2023-08-30 04:29:18 -07:00
Saran Tunyasuvunakool 4c899b92cc Rename mj_stackAllocByte to mj_stackAlloc and make it public.
PiperOrigin-RevId: 561133040
Change-Id: I4f5ffe51c1287aa0c82af68bfe17ed6dd2ad09da
2023-08-29 14:07:54 -07:00
Yuval Tassa d3ed16e78f Add mjData.dof_islandind, indexing from dofs into islands.
Also fix bug in allocation for constraint islands, added allocation for limit constraints.

PiperOrigin-RevId: 561083128
Change-Id: I9e01d5a5b7454ec3cf60bccadaa0f96f2c0d87d1
2023-08-29 11:06:17 -07:00
Saran Tunyasuvunakool daa2ac7f8b Rename nstack to narena, change it and pstack to count bytes.
PiperOrigin-RevId: 561066311
Change-Id: I4d0e645e6c254dd906bfc42159e0e99149a7c6c8
2023-08-29 10:13:33 -07:00
Saran Tunyasuvunakool b979a26b10 Rename mj_stackAlloc to mj_stackAllocNum.
PiperOrigin-RevId: 561040193
Change-Id: I49ea21ffb5b596471d2aacefb1961c11c5c905d0
2023-08-29 08:43:03 -07:00
Kyle Bayes ea5e00cad8 Move mju_combineSparseCount into engine_util_sparse.
PiperOrigin-RevId: 561025741
Change-Id: I0bdc48554928fc4545a38a8cea3bdeb593bd7ecd
2023-08-29 07:40:53 -07:00
Yuval Tassa df1b3515c7 Add mjData.nl: number of active limit constraints.
PiperOrigin-RevId: 561012367
Change-Id: I9a01fec55502f8a90d7435972e477455ae29df15
2023-08-29 06:32:18 -07:00
Kyle Bayes 389736f5a1 Add Base64, defined by RFC 4648, encoding and decoding to MuJoCo engine.
PiperOrigin-RevId: 561008882
Change-Id: I494eb163bc82e8a5c9ad2116ef119072b08a9f48
2023-08-29 06:14:02 -07:00
Yuval Tassa 5f3e22a45f Refactor a loop in engine_solver.c
PiperOrigin-RevId: 560997065
Change-Id: I26540e4f750eb18d9497bf35396adbb15cc3a122
2023-08-29 05:17:14 -07:00
Yuval Tassa 8ba3291365 Fix typo.
PiperOrigin-RevId: 560750842
Change-Id: I11064d43ab43ff0de96997a859bf32d4b0833e05
2023-08-28 10:29:48 -07:00
Yuval Tassa f44c657544 Restore acceleration after mj_inverse with invdiscrete flag.
PiperOrigin-RevId: 560647025
Change-Id: If51f721426be7ecf2b7aa53048ad8c897b51e76e
2023-08-28 02:17:20 -07:00
Tom Erez 819b5cb982 Add invdiscrete flag to enable discrete-time inverse dynamics with mj_inverse.
PiperOrigin-RevId: 560161140
Change-Id: If3e30be5e9af4982571dd310172f2fc0d8d1c551
2023-08-25 12:08:37 -07:00
Yuval Tassa 4db3377467 Don't use mj_stackAlloc for int allocations.
PiperOrigin-RevId: 559846094
Change-Id: I43eeec0b1970b2c6047be4e7c3548a4ce9aa6f5f
2023-08-24 13:09:51 -07:00
Alessio Quaglino b0077e4052 Use geom margin in the midphase.
At the leaves of the midphase trees in `mj_collideTree`, a bounding sphere test is performed. The margin was incorrectly set to zero instead of reading it from `geom_margin`.

PiperOrigin-RevId: 559782262
Change-Id: Icfceb8445bbf6977582e0061566d7bd4def2f0ae
2023-08-24 09:45:10 -07:00
Yuval Tassa 1dad5993f0 Refactor constraint island representation.
Required for constraint solver islanding.

Replace linked lists with `island_{dof,efc}_{num,adr,ind}`, corresponding to the standard `{rownnz,rowadr,colind}` sparse matrix representation. By effectively defining two sparse matrix structures of dimensions `nisland x nv` and `nisland x nefc`, respectively, this representation is more conducive to reuse of existing sparse matrix utility functions, while being cache-friendlier by making sequential indices adjacent in memory.

PiperOrigin-RevId: 559704957
Change-Id: I919362cbef0d5fe5acc4aa2bb4ffb17eee8223a2
2023-08-24 03:48:57 -07:00
Saran Tunyasuvunakool 1f5a9e8c70 Reinstate max_align_t alignment in mj_stackAllocByte.
PiperOrigin-RevId: 559433104
Change-Id: I891a6a0562cab1c3af0e3dc395304207ca3a3190
2023-08-23 08:22:31 -07:00
Yuval Tassa b7cf479abe Add flag for disabling implicit integration of joint damping in the Euler integrator.
PiperOrigin-RevId: 559398414
Change-Id: I43b23c5e75a2830a64b1898daeaa16f19e011718
2023-08-23 05:51:37 -07:00
Yuval Tassa 5f2a2a325c Fix typo.
PiperOrigin-RevId: 559393250
Change-Id: Ibe257d7db371868d87fbea56111972d3f96f7147
2023-08-23 05:20:50 -07:00
Yuval Tassa e4c3e1468b Fix typo
PiperOrigin-RevId: 559383537
Change-Id: I9510970c26b94b8e8bb90423d6164fc82b9bd016
2023-08-23 04:25:22 -07:00
Yuval Tassa 90f58ebe5d Rename mj_stackAllocBytes to mj_stackAllocByte
PiperOrigin-RevId: 559071711
Change-Id: I19072e07ac86ee0486703aa48b0dceb297f5f893
2023-08-22 04:43:53 -07:00
Nimrod Gileadi dae74030fe Handle initial_capacity = 0 in mju_arrayListCreate.
Add const to ArrayList function arguments where appropriate.

PiperOrigin-RevId: 559064386
Change-Id: I8763974a60a05f34dadd56e953cefa40fe78df42
2023-08-22 04:04:02 -07:00
Matthew Bennice 1d36b57d83 Switch from max_align_t to mjtNum until we sort out the git builds
PiperOrigin-RevId: 558982369
Change-Id: I24d9fd6400dae5e1bc1753ee74484da635ea8ecd
2023-08-21 21:30:49 -07:00
Matthew Bennice c2e586f303 add c stddef to engineio
PiperOrigin-RevId: 558949604
Change-Id: Ibe7fbb1a7fb3fcc9258bff3aae260a805eb853dd
2023-08-21 17:51:08 -07:00
Matthew Bennice 4b983e8439 Add an ArrayList container type.
PiperOrigin-RevId: 558887266
Change-Id: I201978bfa5e6cfa2f4e495feaecf61374baf7b7b
2023-08-21 13:38:45 -07:00
Matthew Bennice 59138af10b Refactor stack allocations to have a clean byte allocation interface.
PiperOrigin-RevId: 558881470
Change-Id: I08c45cb5fa25a1a9c39560e598e805cfa5141c3e
2023-08-21 13:18:29 -07:00
Yuval Tassa 22fd0586b1 Move core_constraint arena allocations to local function.
PiperOrigin-RevId: 558823297
Change-Id: I4a564f0d05c17634e70fbff16e8bdca2e7d7fb63
2023-08-21 10:07:10 -07:00
Alessio Quaglino b5f9628dd7 Reduce mjMAXCONPAIR to 50.
Use only the first `mjMAXCONPAIR` contacts in SDF-mesh collisions after sorting them using the penetration depth.

PiperOrigin-RevId: 558176217
Change-Id: Ia1ee12bd5ceb81e4c52f143831ad00426e8cf174
2023-08-18 10:02:44 -07:00
Kyle Bayes ba12a1354b Optimize and refactor combineSparse and combineSparseCount.
PiperOrigin-RevId: 558126391
Change-Id: Iead14c31136e789560f3c8124b84bd4e383158f4
2023-08-18 06:14:09 -07:00
Yuval Tassa b1ecc943bb Fix multiple bugs related to mjvSceneState.
PiperOrigin-RevId: 557864131
Change-Id: I47d9692930c54b1304a5cc161f99bbd81d992a7c
2023-08-17 10:25:39 -07:00
Alessio Quaglino fdb041580c Add Signed Distance Field to collision geometries.
PiperOrigin-RevId: 557507088
Change-Id: I358a642407aee1ba8dfc9d405eb9a4f609435fe9
2023-08-16 09:15:23 -07:00