Commit Graph

327 Commits

Author SHA1 Message Date
Yuval Tassa a1b6026b8c Delete derivative code sample.
PiperOrigin-RevId: 573477509
Change-Id: I0e619e36dd3fe677a27bbbdac87a15f04670cc13
2023-10-14 08:38:37 -07:00
Nimrod Gileadi eb41c720d4 Restore full state in mjd_stepFD.
Make sure that plugin state is also restored after finite-difference calculations.

PiperOrigin-RevId: 573272654
Change-Id: Ie276ecc391c463ae5c47cafa5b8de873b9345a7d
2023-10-13 11:23:52 -07:00
Nimrod Gileadi 60fd6a3298 Check if there's enough data in the buffer before reading fields while loading MJB.
Before this change, loading a truncated MJB file would crash with mjERROR. After this change it will just return NULL.

PiperOrigin-RevId: 572928724
Change-Id: I9611eaffcc2e5ef1b957f48162ce2ef29619e087
2023-10-12 09:30:00 -07:00
Alessio Quaglino 386b65086b Reduce contact label length.
PiperOrigin-RevId: 572868387
Change-Id: Icedec0792516b05d083068b9a3dad7e47e4ccc41
2023-10-12 05:10:03 -07:00
Alessio Quaglino 3addd490a4 Increase contact label length.
PiperOrigin-RevId: 572856066
Change-Id: I9d68481644b5a67720c055461607c95de8ec16ac
2023-10-12 04:10:25 -07:00
Alessio Quaglino 5a70ad08ab Add Flex component.
PiperOrigin-RevId: 572830650
Change-Id: I6908228087b7b9683be3506c8d9cdc725ed5dcd5
2023-10-12 10:49:35 +01:00
Matthew Bennice 2842245ca9 Multithread parallelizable operations in mj_fwdPosition
PiperOrigin-RevId: 572576240
Change-Id: I70eb518385366a0027c5dad44ac15e3904d1b4a3
2023-10-11 08:01:53 -07:00
Saran Tunyasuvunakool 2e15574b58 Allow user-defined visualization geoms to be added to the passive viewer.
Fixes #1023, #1082

PiperOrigin-RevId: 572303635
Change-Id: Ia8399f816f311b38a7b137f5bd4f359f77a1da1c
2023-10-10 10:52:21 -07:00
Google DeepMind 1bd6c94e6d Fix setting wrong value in efc_diagApprox for rotational components of weld constraints.
PiperOrigin-RevId: 572276016
Change-Id: Ic985a342777aca976f5c4bc781133fb4a8976e3f
2023-10-10 09:34:34 -07:00
Alessio Quaglino 8af09eb70d Add timing of collision phases.
PiperOrigin-RevId: 572273621
Change-Id: Ib9440a996a05e42e00dcf4f1ce487a12f65e999b
2023-10-10 09:27:45 -07:00
Yuval Tassa 18d9f1abb0 Improvements to timing.
- Fixed bug in timing of kinematics, was under-reported.
- Moved timing of inertia and collision into respective functions, in preparation for multi-threading.
- Detailed profiling in `testspeed` is always on, removed command-line flag.
- Improved `testspeed` self-documentation.

PiperOrigin-RevId: 571989548
Change-Id: If0e3cc17f6f3511b98fc36339f406a19968a9361
2023-10-09 11:14:44 -07:00
Alessio Quaglino f0608648cb Stricter swapping condition in mju_eig3.
This solves the texture rendering issue with the Rubik's cube. The texture were specified with respect to the incorrect frame, so a default rotation of (0, 0, pi/2) is now applied to the model file.

PiperOrigin-RevId: 571715153
Change-Id: I3efae3b1fc8f64e6c9e4db90a7609506e3cbed86
2023-10-08 04:04:34 -07:00
Alessio Quaglino 77d0400733 Accelerate inertia computation for simple bodies.
PiperOrigin-RevId: 571411319
Change-Id: I82732e95795cc0f0645f8273a1b084f2a9187a75
2023-10-06 12:51:14 -07:00
Yuval Tassa d61d0349b8 Fix mju_eig3 declarations.
PiperOrigin-RevId: 571296456
Change-Id: Ic05f44c8c0883fe96e5671d71fe9b447c2e91162
2023-10-06 04:10:44 -07:00
Matthew Bennice 071af3b015 Implement threading for island constraint solving.
Humanoids22 No threads:
 Benchmark Execution Time: 9.475905812s

Humanoids22 with 10 Threads:
 Benchmark Execution Time: 4.871352s

PiperOrigin-RevId: 571214307
Change-Id: I1f4f2c761b4ae6bc8fac1f28c6c695f6c499f339
2023-10-05 21:05:19 -07:00
Yuval Tassa ee78b8f76b Added mjData.eq_active user input variable, for enabling/disabling the state of equality constraints.
Renamed `mjModel.eq_active` to `mjModel.eq_active0`, which now has the semantic of "initial value of `mjData.eq_active`".

Fixes #876.

PiperOrigin-RevId: 570410643
Change-Id: Id03171e751377c7cc453f143abee64239ee2e2ed
2023-10-03 09:32:24 -07:00
Yuval Tassa e1549376f6 Use body AABB for torque perturbation visualisation, if available.
PiperOrigin-RevId: 569579715
Change-Id: I62c1083fb868520832746ca1f28fab2bf1d679cc
2023-09-29 13:50:02 -07:00
Alessio Quaglino 36d2ffe4f2 Specify camera parameters using standard robotics conventions.
PiperOrigin-RevId: 569147555
Change-Id: I3443f95e5de56a17024f5e5c03f33888dd583edb
2023-09-28 05:19:19 -07:00
Saran Tunyasuvunakool ca60de79c8 Change sz to 64-bit integer in mj_setPtrData.
PiperOrigin-RevId: 569123159
Change-Id: If16777f06a2b0ea08083261d1b77c95fc14f2751
2023-09-28 03:20:18 -07:00
Yuval Tassa 772326e9eb Fix potential out-of-range write in solver statistics saving.
PiperOrigin-RevId: 569094007
Change-Id: I2e596a7c03d76523359cae7ae7f4501b06256a38
2023-09-28 00:58:13 -07:00
Saran Tunyasuvunakool 8ed321d469 Rename mesh_assetpathadr to mesh_pathadr and move it to the end of the mesh section.
PiperOrigin-RevId: 568911603
Change-Id: I8f21c3d1cc9c73b6a95292a50f262b1a199d0898
2023-09-27 11:32:10 -07:00
Matthew Bennice ff4158efff Modify memory allocation in MuJoCo to be thread safe:
1) protect mj_arenaAllocBytes with mutexes
2) create shards for each thread in the stack and update mj_stackAllocBytes to allocate memory within each shard for a given thread

PiperOrigin-RevId: 568315726
Change-Id: I0dee6694f2a5200fa4df22ade0e68dfaebf637fc
2023-09-25 13:53:28 -07:00
Matthew Bennice 7f8018a3f3 Update XML parsing to store asset path so that assets can be recovered and sent to external renderers
PiperOrigin-RevId: 567347908
Change-Id: I4d8e1abe35be3a67643ff925af709921280856f8
2023-09-21 10:27:52 -07:00
Matthew Bennice 4f34cacf35 Add maxuse_threadstack to mjData
PiperOrigin-RevId: 567334177
Change-Id: Ifd772350042e548a63ab269fd68fb5e5fef55831
2023-09-21 09:41:00 -07:00
Yuval Tassa dfd48dd821 Replace mjMIN and mjMAX with mju_min and mju_max, where possible.
PiperOrigin-RevId: 566602924
Change-Id: I2d24183d0d9df3e647bb2d7d7544473582f38128
2023-09-19 05:40:41 -07:00
Yuval Tassa 9cf1f6eba4 Remove mjOption.collision and associated option/collision attribute.
PiperOrigin-RevId: 566427090
Change-Id: I6e5873b8db707586820b17b53c7ab4bbff0f0b2b
2023-09-18 15:15:54 -07:00
Yuval Tassa 9902b73502 Rename mj_stackAlloc to mj_stackAllocByte.
PiperOrigin-RevId: 566351365
Change-Id: I91541168e83b05a730113661cc9f07985ac9ff0c
2023-09-18 10:53:35 -07:00
Yuval Tassa 812e617fe9 Clear mjData.actuator_moment more selectively.
PiperOrigin-RevId: 566324919
Change-Id: Ie453f8de059d39fa1ebd5248f33a18758ee748af
2023-09-18 09:27:03 -07:00
Yuval Tassa 63fd23a934 Remove mjTIMER_ACCELERATION, add mjTIMER_ADVANCE.
- mjTIMER_ACCELERATION is not very useful, it's usually very tiny (0.5% for humanoid, 1% for 22humanoids). It basically times a single call to `mj_solveM`.

- Added `mjTIMER_ADVANCE` to time `mj_Euler` and `mj_implicit` (which can be significant).

- Moved `mj_transmission` to `mjTIMER_KINEMATICS` where it belongs (and used to be).

PiperOrigin-RevId: 565936880
Change-Id: I26b8a067133594e5500ca1c809beb3518b4a8d9c
2023-09-16 08:03:45 -07:00
Yuval Tassa 2cc1205498 Add island support to CG solver.
BEGIN_PUBLIC

Add island support to CG solver.

END_PUBLIC

PiperOrigin-RevId: 565653886
Change-Id: Ib971ae37dd011b8f2cbe1f88d8875e0ed657c7af
2023-09-15 05:47:24 -07:00
Alessio Quaglino 1afd98ec4b Add [SdfLib](https://github.com/UPC-ViRVIG/SdfLib) plugin to first-party SDFs.
The following dependencies are disabled with a cmake patch file.
- Enoki
- OpenMP
- Assimp
- FCPW

PiperOrigin-RevId: 565352386
Change-Id: Icff9de68408e0afa2032bb83b24491fc4e41d181
2023-09-14 06:42:42 -07:00
Yuval Tassa 86d8b912f4 Rejigged solver statistics in preparation for islanding.
- See public description below.
- Stopped incrementing the iteration count in saveStats().
- `sizeof(mjSolverStat) == 40`, so this ends up costing 160KB, up from 40KB.

BEGIN_PUBLIC

Changed the size of `mjData.solver`, the structure used to collect solver diagnostic information. The array is now of length `mjNISLAND * mjNSOLVER`, where each row of length `mjNSOLVER` contains separate solver statistics for each constraint island. Until solver islanding is implemented, only row 0 is used.

- The new constant `mjNISLAND` is set to 20.
- `mjNSOLVER` is reduced from 1000 to 200.
- Added `mjData.solver_nisland`, the number of islands for which the solver ran.
- `mjData.solver_niter` (renamed from mjData.solver_iter) and `mjData.solver_nnz` are now integer vectors of length `mjNISLAND`.

END_PUBLIC

PiperOrigin-RevId: 565030093
Change-Id: I773e918805c6ced79f0dab5f19ea23956760c8c5
2023-09-13 06:18:37 -07:00
Alessio Quaglino b0abafe3bb Set camera origin at top-left of the first pixel.
PiperOrigin-RevId: 564768176
Change-Id: Ieef632f0f6888390acca91b6de01c8951c747fe4
2023-09-12 10:44:51 -07:00
Alessio Quaglino 8064ad59c8 Add camera projection sensor.
BEGIN_PUBLIC
Add camera projection sensor.
END_PUBLIC

PiperOrigin-RevId: 564726114
Change-Id: I33b8e5562eff29c21538bf8f38ce3116c7dfc5a9
2023-09-12 08:16:20 -07:00
Alessio Quaglino ccda87aafa Use mesh_pos and mesh_quat in SDF transformation.
The SDF is defined in the `geom` frame. Using a mesh changes this frame so the inverse transformation is needed. So far the full `geom_pos` and `geom_quat` were used, which possibly contained user transformation. This CL uses the new structures which only contain transformations due to mesh processing.

PiperOrigin-RevId: 564721461
Change-Id: I6fb28001b38eaa50663427bce452cb1f05a56ac0
2023-09-12 07:58:04 -07:00
Nimrod Gileadi 71faea0e62 BEGIN_PUBLIC
Don't update actuator state when actuation is disabled.
END_PUBLIC

PiperOrigin-RevId: 564712814
Change-Id: I3cb656e81c9018a48d46348960cc07b14ae15b4a
2023-09-12 07:17:57 -07:00
Nimrod Gileadi fbcd96d03f BEGIN_PUBLIC
Zero all of act_dot when there are custom actuator dynamics, but no callback.
END_PUBLIC

PiperOrigin-RevId: 564712105
Change-Id: I107481727a42eb2577d62e29ac4e1496c56bb634
2023-09-12 07:14:15 -07:00
Saran Tunyasuvunakool 2f14a7c102 Make asan instrumentation in mj_(mark|free)Stack cheaper.
Symbolization and string comparison results are now cached.

PiperOrigin-RevId: 564697198
Change-Id: I0447f283a90143e2f67ecd90d895a36a078b3981
2023-09-12 06:06:04 -07:00
Yuval Tassa 2b192cebb6 PUBLIC: In mju_normalize4, don't normalize if norm is less than mjMINVAL away from 1.
This makes mj_forward calls idempotent if warmstart is disabled and quats in qpos are normalized.

PiperOrigin-RevId: 564442666
Change-Id: I9c43add82bcfb4101c19fbfbfc8c30091b8906d5
2023-09-11 11:09:53 -07:00
Saran Tunyasuvunakool a07e172770 Make MuJoCo work with -fsanitize=alignment.
PiperOrigin-RevId: 563702045
Change-Id: Ieca69595b7e2fc1e35ca69754d7cc7971825f48b
2023-09-08 03:29:34 -07:00
Google DeepMind 040d3efce2 Add options for controlling early termination criteria of CG/Newton linesearch.
Useful for performance tuning models.

PiperOrigin-RevId: 563175078
Change-Id: Id64a510d6080038ea8d5876dabbf0b2b311435bb
2023-09-06 12:02:58 -07:00
Saran Tunyasuvunakool 48d0bfde44 Replace glfw.get_time with time.time in the Python viewer timing logic.
PiperOrigin-RevId: 563134207
Change-Id: Ic548701fc78336d8d87e94ea48833f94ee6395b8
2023-09-06 09:52:12 -07:00
Saran Tunyasuvunakool 4929077211 Remove mjMARKSTACK and mjFREESTACK macros.
PiperOrigin-RevId: 562844184
Change-Id: Id2f57f5d132c47094dad75c6dab7297d7aa73458
2023-09-05 11:41:43 -07:00
Saran Tunyasuvunakool 329ed193ac Disallow variable-length arrays and turn on -Wpedantic in Clang and GCC.
PiperOrigin-RevId: 562832747
Change-Id: I0532624cee31e089a47426305d885687eb0fc5c5
2023-09-05 11:05:04 -07:00
Yuval Tassa d5292976de Add internal utility for zeroing int vectors.
Remove unnecessary branches in related functions.

PiperOrigin-RevId: 562768873
Change-Id: I3964a7a953d95bcd4e29137a7b590be5ffa6e311
2023-09-05 07:15:14 -07:00
Matthew Bennice 6225186964 Add threading primitives.
PiperOrigin-RevId: 562649644
Change-Id: I9c35b270e4b3b50cc7eb5a152f24d71def8e2fcd
2023-09-04 20:09:19 -07:00
Saran Tunyasuvunakool 94a8705ad0 Add mj_markStack and mj_freeStack as public API functions.
Also add asan instrumentation to detect stack frame leakages (i.e. `mj_markStack` without a corresponding `mj_freeStack` in the same caller function).

PiperOrigin-RevId: 562625645
Change-Id: I4e3ff66ca0b9d08ed0a95cef45393db8e3053e22
2023-09-04 17:04:11 -07:00
Yuval Tassa 9308e1d383 Add internal utility for zeroing int vectors.
PiperOrigin-RevId: 562608956
Change-Id: I25ff1bbf9abf8fe2a636ed1d728d10ae862e04c9
2023-09-04 14:27:11 -07:00
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