Commit Graph

115 Commits

Author SHA1 Message Date
Yuval Tassa f67e359532 Add mjtState enum and related mj_stateSize, mj_getState and mj_setState functions.
PiperOrigin-RevId: 539667943
Change-Id: I14c34be8ce4c287e529380257b5c5bffc3ab45ce
2023-06-12 08:56:48 -07:00
Yuval Tassa d82f5ce5a4 Add mjContact.solreffriction, mjModel.pair_solreffriction and related implementation, allowing contact reference acceleration to be different for normal and frictional contact directions. This is required for e.g. elastic frictional collisions.
PiperOrigin-RevId: 538513357
Change-Id: Id9eb910fe791cf898c712030cb2c0fc481389c91
2023-06-07 09:40:20 -07:00
Saran Tunyasuvunakool 1d79657512 Fix out-of-bound read in mju_combineSparseCount.
PiperOrigin-RevId: 535615505
Change-Id: I740d4f50b46ec2a1cd1a5a615fb4312f1bbebd94
2023-05-26 07:44:47 -07:00
Yuval Tassa c66d79409c Change mj_ray behaviour to match geom visualisation conventions:
- Planes and height-fields respect `mj_ray`'s `geom_group` argument.
- The `flg_static` argument now applies to all static geoms, not only those directly in the world body.

Before this change:
- Rays always intersected with height fields and planes, unless `flg_static` was set to 0.
- `flg_static` only applied to static geoms that were direct children of the world, but not geoms that were children of static bodies.

PiperOrigin-RevId: 534969091
Change-Id: I8dc7c320c63d6af95709b9f5e83a3c50e1c199fa
2023-05-24 13:52:21 -07:00
Alessio Quaglino 03d6d27f64 Use mesh BVH for speeding up ray mesh intersection.
PiperOrigin-RevId: 534141245
Change-Id: I9f5a71ea059a1a232fd2910d1efc0506ab6dbef3
2023-05-22 12:05:20 -07:00
Alessio Quaglino dab49d487c Use mesh BVH for speeding up ray mesh intersection.
PiperOrigin-RevId: 532516008
Change-Id: Ia9cac060279d030221c1a6b4fad457a857701370
2023-05-16 11:10:38 -07:00
Alessio Quaglino 9d1a21f99d Use mesh BVH for speeding up ray mesh intersection.
PiperOrigin-RevId: 532464595
Change-Id: If159c89b93c24e6a7be6310911364cfad7baae81
2023-05-16 08:17:50 -07:00
Alessio Quaglino fcc825c5e6 Add cutoff argument to mj_multiRay.
PiperOrigin-RevId: 532158635
Change-Id: I70f98be9f781c8281e21aa5c17bd85f3654e9383
2023-05-15 10:44:37 -07:00
Yuval Tassa 770b4b363a Added optional smoothing to muscle dynamics:
- `muscle` actuators take a new `tausmooth` attribute (defaults to 0) which when positive, smooths the transition between activation and deactivation timescales.
- `mju_muscleDynamics` takes 3 parameters, adding width of smoothing sigmoid.

PiperOrigin-RevId: 531473354
Change-Id: I8ab6c0289ff04437e798c3ca6edda132a30fcc31
2023-05-12 04:58:53 -07:00
Yuval Tassa 49066e1794 equivalent but clearer quat-diff call in mj_differentiatePos
PiperOrigin-RevId: 530075836
Change-Id: I3bbe5dec17ccdf53c372bb81087dddde30a24c5c
2023-05-07 02:21:52 -07:00
Yuval Tassa 49efa9cc15 Change finite-support mju_sigmoid from a two-quadratic construction to a single quintic with zero 1st and 2nd derivatives at 0 and 1, the boundary of the smooth-support segment.
Note: this function is currently unused in the MuJoCo codebase.
PiperOrigin-RevId: 529969804
Change-Id: I2bddc72916eff67625b806510935bc7f3ce5c770
2023-05-06 09:22:37 -07:00
Kyle Bayes 67f0f5154f Add various improvements for resource providers.
PiperOrigin-RevId: 529706437
Change-Id: I20385e031446674584349c301982dbe13b812477
2023-05-05 07:03:49 -07:00
Alessio Quaglino b798f89212 Fix bug with the position of bounding sphere in mj_multiRay.
PiperOrigin-RevId: 529665457
Change-Id: I486a094303b3b26c8067f8be7aca03afbe8e6217
2023-05-05 02:53:11 -07:00
Yuval Tassa 90813b8198 Add mjd_subQuat (private function)
PiperOrigin-RevId: 529418945
Change-Id: I6764ae866b13482ef3aa951f427b58cae007c301
2023-05-04 08:40:34 -07:00
Alessio Quaglino 267299fb59 Change elevation to [0,pi] in mj_multiRay.
PiperOrigin-RevId: 529393944
Change-Id: I23f3113fd91e909fa1dc23b620d66e963db59355
2023-05-04 06:43:16 -07:00
Alessio Quaglino 7e49d935ba mj_multiRay: Reset elevation angle if crossing the coordinate singularity.
PiperOrigin-RevId: 529341397
Change-Id: I0ca6ed5b97bcc585b0f426d6fb8a6b4cf9367a2b
2023-05-04 01:50:38 -07:00
Yuval Tassa b0bc330b54 Add utility functions for banded-then-dense symmetric matrices.
PiperOrigin-RevId: 528757637
Change-Id: I916d843140322c28e857100a6b305a041f704d53
2023-05-02 05:58:08 -07:00
Alessio Quaglino 2ad82d5998 Add mj_multiRay function to perform multiple ray intersection with the same source.
PiperOrigin-RevId: 528684535
Change-Id: I6e1747a4a0910e6061d6154e19ad8723f56c22e3
2023-05-01 23:02:45 -07:00
Yuval Tassa c50177d301 Add mjd_inverseFD for finite-difference approximations of inverse dynamics Jacobians.
Fixes #703.

PiperOrigin-RevId: 527899700
Change-Id: I10e41a381dcecf62c53b3b9aa72a4ce666161366
2023-04-28 09:04:41 -07:00
Kyle Bayes 23961e24b7 Refactor user codebase to use LoadResource helper method.
* Fix small bug when registering resource providers.
* Add test cases for OS filesystem fallback with VFS.
* Rewrite LoadModelFromString using a resource provider (now can pass custom VFSs).

PiperOrigin-RevId: 526959705
Change-Id: Iee1773e5584535d868aab6b206d1bf362e600c8a
2023-04-25 07:24:45 -07:00
Yuval Tassa a2a1ac9fc2 Pass mjvOption to plugin visualize callback.
PiperOrigin-RevId: 526047180
Change-Id: Ia63f02184f5c6a7e3b588298639fa0ab4a6da649
2023-04-21 08:44:20 -07:00
Saran Tunyasuvunakool b362cb4972 Expose a handle for the Python viewer.
This change also requires user scripts to explicitly synchronize changes to physics state to the viewer. The Simulate class was reconfigured so that certain UI events are handled during this sync operation, outside of the render loop on the main thread. These correspond to operations that require access to the full mjModel/mjData.

To support other, more interactive operations (e.g. camera movements), a new mjvSceneState struct is introduced which captures only the portion of the physics state required for scene re-rendering. The mjvSceneState is updated from mjModel/mjData during the viewer sync operation, and is significantly cheaper than a full mj_copyModel and mj_copyData.

Fixes https://github.com/deepmind/mujoco/issues/796

PiperOrigin-RevId: 525723636
Change-Id: Id08d0210a2c067d5afe85e2bf104f276aeddd75e
2023-04-20 05:59:19 -07:00
Saran Tunyasuvunakool 34e62aa3c1 Don't use designated initializer in engine_resource_test.
MuJoCo codebase is currently C++17, not C++20.

PiperOrigin-RevId: 525507811
Change-Id: Iaa1b5a271e811bee34418be79583fc5bdda3bee9
2023-04-19 11:42:23 -07:00
Kyle Bayes fe3dccfd1d Add a new plugin / extension mechanism called a resource provider along with retrofitting VFS on top of it.
A resource provider provides a mechanism for MuJoCo to read from filesystems other than the OS filesystem or the Virtual File System (VFS).

PiperOrigin-RevId: 525394983
Change-Id: I077ff5a7e2e76806b48b6defb531280aadc8b169
2023-04-19 03:02:22 -07:00
Copybara-Service 9027b243b7 Merge pull request #801 from hartikainen:fix-mj_sizeModel
PiperOrigin-RevId: 522013801
Change-Id: Iff5e930fb7c86ae4296beb40f266ed02aabb6a7f
2023-04-05 04:20:11 -07:00
Kristian Hartikainen f91b760799 Clean model in VerifySizeModel test 2023-04-05 11:56:07 +01:00
Kristian Hartikainen 98c9718aaf Add (currently-failing) mj_sizeModel test 2023-04-05 11:09:23 +01:00
Kyle Bayes 9924cce4b7 Add nnz per row precount method for mju_sqrMatTDSparse.
PiperOrigin-RevId: 521744893
Change-Id: Ie0fbfab552a680127f4acf9041b07916f8a2a490
2023-04-04 06:21:22 -07:00
Yuval Tassa 0becf8fd98 Remove unused headers in test files.
PiperOrigin-RevId: 520610859
Change-Id: I5ac906b422a7c02737af85f6a2aea46206f0cb28
2023-03-30 05:26:33 -07:00
Kevin Zakka 3f14d97f6b Add equivalent inertia ellipsoid visualization.
PiperOrigin-RevId: 519154067
Change-Id: I35f1993c1493df9be752b7163385004649498070
2023-03-24 08:47:43 -07:00
Yuval Tassa 3620376d81 Add model used for testing UI for stacking.
PiperOrigin-RevId: 519137042
Change-Id: Id16ea2735ea2f853c927fc6f88a9284b2f5aee95
2023-03-24 07:23:29 -07:00
Nimrod Gileadi 0e7e299bf6 Declare loop variables inside for loop in C++ files.
PiperOrigin-RevId: 518852339
Change-Id: I0174d873d89e48f11b816d337728f213c2798248
2023-03-23 07:22:36 -07:00
Nimrod Gileadi 8a402631a3 Add another test for sizes of arena pointers in mjData.
PiperOrigin-RevId: 518224754
Change-Id: I034f6778dedeeef49d2bb4a06337044469450f40
2023-03-21 03:39:19 -07:00
Kyle Bayes dfd463cdb5 Reset nnzJ in resetData.
PiperOrigin-RevId: 517976421
Change-Id: I329c0096d368062f150c6dbeec181f5b0eeefcbf
2023-03-20 08:33:36 -07:00
Alessio Quaglino 70959c1a2c Added a collision midphase on geom pairs using rotated AABBs static trees.
PiperOrigin-RevId: 517357695
Change-Id: I068fee714d9638be2fb6d042d5d86f8ff970635b
2023-03-17 02:37:29 -07:00
Yuval Tassa 9a97674e1e Break up engine_derivative.c into analytical and finite-differencing functions (moved to engine_derivative_fd.c)
PiperOrigin-RevId: 517165392
Change-Id: I649f5521364877d36d7564bb650a889298f0c8a1
2023-03-16 10:45:15 -07:00
Yuval Tassa 8c7f6ce5a0 New implicitfast integrator and sparse RNE derivatives for implicit.
PiperOrigin-RevId: 516910733
Change-Id: I29a0465c0f0b1749a73e3d7e01925200d025ddd0
2023-03-15 13:17:41 -07:00
Kyle Bayes 056e849273 Provide improved mju_sqrMatTDSparse implementation that doesn't require dense memory allocation for sparse matrices.
PiperOrigin-RevId: 516812783
Change-Id: Ieb43337831d8d3b2c7f18a7facd8e0a0f2b0eff5
2023-03-15 06:56:16 -07:00
Yuval Tassa 222ee00a66 Break out passive force functions into a new file engine_passive.c
PiperOrigin-RevId: 513834952
Change-Id: I5347440f24d767a7dc81a34e48e1e17d8c10173f
2023-03-03 08:32:16 -08:00
Kyle Bayes 50bebcb4ee Precount number of non-zeros for constraint Jacobian sparse matrix.
PiperOrigin-RevId: 512947632
Change-Id: I9605e81b4e51fbc90854c13153e4fee38ad48fb9
2023-02-28 08:57:56 -08:00
Yuval Tassa 7542c90cd2 Improved behaviour of mouse-spring interactions.
Also:

- Renamed recently introduced `mjvPerturb` member `reflocalpos` -> `refselpos` and corrected docstring.
- Added `mjvPerturb.localmass`: body spatial inertia at selection point.
- Removed `const` qualifier to `mjData` argument of `mjv_initPerturb()`, to facilitate spatial inertia computation.
- Improved `mj_Object{Velocity, Acceleration}` docstrings, clarifying that rotational velocities precede linear velocities.
- Removed redundant const qualifiers from non pointer arguments to `mju_dot` and `mju_writeNumBytes`.

PiperOrigin-RevId: 511002168
Change-Id: I27400f497947f330072d4abb7c9bf7e71e6c5d49
2023-02-20 08:40:33 -08:00
Yuval Tassa 6a85b5db45 Improve cartesian actuator example model.
Significantly reduced joint-level damping, introduced damping in the actuators themselves. This reduces dynamics artifacts by matching the space in which damping and actuation forces are applied.

PiperOrigin-RevId: 509574523
Change-Id: Id99b69aea4562509c48ed1a24fb9ea3e008c0b69
2023-02-14 10:41:21 -08:00
Saran Tunyasuvunakool db28c31f05 Rename <required> tag to <plugin>.
PiperOrigin-RevId: 509237786
Change-Id: I35e812830b479004ac5025cbd9477888f51fb43e
2023-02-13 08:41:52 -08:00
Nimrod Gileadi 48e95817e4 Don't compute sensors in mjd_transitionFD, if not requested.
PiperOrigin-RevId: 507878658
Change-Id: I97ece521fd177d97fa5758dda1eb012ba26bcabe
2023-02-07 14:02:45 -08:00
Copybara-Service 6b80b010af Merge pull request #705 from hartikainen:bug/mj_deleteFileVFS-infinite-loop
PiperOrigin-RevId: 507544780
Change-Id: Ie5819d4cc567dce44ceb59624a889a06ecdd7c1b
2023-02-06 12:01:11 -08:00
Nimrod Gileadi dc3a900809 Apply body pair filtering at broadphase.
mj_contactFilter removed geom pairs where their bodies share the same weldid, but this check can be applied at broadphase instead of at geom-geom level.

PiperOrigin-RevId: 507435848
Change-Id: Ia37c741071dc5e1c26686dd319f42c9bd334d305
2023-02-06 03:46:20 -08:00
Yuval Tassa 7feecf6e94 Improve behaviour of set-pose mouse interactions with free and mocap bodies.
PiperOrigin-RevId: 506051745
Change-Id: If666757deb743f7bf3af4113d10976c3294e0879
2023-01-31 10:57:19 -08:00
Kyle Bayes c741dfce7d Implement a more performant mju_transposeSparse that doesn't require dense memory allocation.
PiperOrigin-RevId: 505044194
Change-Id: Ibe0e39e3ad711b2b5bdad45180ca4f83b5c8fc82
2023-01-27 00:20:01 -08:00
Kristian Hartikainen d35670932f Fix for-loop syntax to match style convention 2023-01-25 19:11:13 +00:00
Kristian Hartikainen 436fc6e77c Fix infinite loop in mj_deleteFileVFS 2023-01-21 17:26:01 +00:00