Commit Graph

278 Commits

Author SHA1 Message Date
Alessio Quaglino 1aadef5927 Fix unused variable error from GCC.
PiperOrigin-RevId: 530591696
Change-Id: I0b1d647bb4dc343eca4966ba54a90a992ea9544f
2023-05-09 06:25:37 -07:00
Alessio Quaglino 4c487e07ed Add mesh BVH.
PiperOrigin-RevId: 530559807
Change-Id: Ibdafae22c7c74d15d707f205be73e4a571a6ae10
2023-05-09 03:31:06 -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
Copybara-Service 26ff1fc4b5 Merge pull request #304 from traversaro:patch-5
PiperOrigin-RevId: 529843317
Change-Id: Iad4a3df7d8c61f536890f9760e441793d6d884dc
2023-05-05 16:38:02 -07:00
Saran Tunyasuvunakool 496755a55d Fix mju_getfiledir when the path contains a mixture of / and \.
PiperOrigin-RevId: 529754511
Change-Id: Ifce2b86bc339a8cae584db639b7901b270e56384
2023-05-05 10:35:55 -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 42a16f65c2 Fix typo in mjd_inverseFD documentation.
PiperOrigin-RevId: 529022023
Change-Id: I2f9e014e271910989f96cd9bfd28c6adaf2e62e5
2023-05-03 01:30:44 -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
Alessio Quaglino 15e77b13dd Add mjCBoundingVolume class to represent an element of mjCBoundingVolumeHierarchy (for example an mjCGeom).
PiperOrigin-RevId: 527906004
Change-Id: Ibc3bdac0ec6d85c7fd56fd2057f5a63970e8b1d4
2023-04-28 09:29:58 -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
Saran Tunyasuvunakool 90e14ac8d0 Bump version number to 2.3.6.
Going forward, the version number at head will be kept one ahead of the latest released version. The rationale behind this change is so that it is clear that the source code at head is more recent.

PiperOrigin-RevId: 527687981
Change-Id: I7982ecd0b99ad70dccec6a8ffe86629754558bda
2023-04-27 14:40:32 -07:00
Yuval Tassa e3cdc410d6 Rename centered argument of mjd_transitionFD to flg_centered, to conform with the rest of the API.
PiperOrigin-RevId: 527258079
Change-Id: I77817be8ee007a572c79e9cd41f7c5728a091fb3
2023-04-26 07:18:52 -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
Saran Tunyasuvunakool db3b49b60f Bump version number to 2.3.5.
PiperOrigin-RevId: 526918869
Change-Id: I9f19600b0c1b855ef0834e5c026b204bf1dc06c4
2023-04-25 03:52:12 -07:00
Saran Tunyasuvunakool 66def34e0e Fix broken OBJ and PNG loading when a VFS is provided to mj_loadXML.
At present, if a VFS is used but an OBJ or PNG asset doesn't exist in the VFS, the model compilation will fail without trying to first locate the asset on disk.

This breaks the Python bindings `MjModel.from_xml_string` almost entirely when OBJ assets are involved.

Also modify error messages to disambiguate between different modes of asset loading failures.

PiperOrigin-RevId: 526637686
Change-Id: Iba02cc94989083bc2835a3e67dfc78c0a21047e9
2023-04-24 07:37:33 -07:00
Alessio Quaglino 3db483c248 Print warning and default to computing mesh inertia from convex hull if volume is negative (malformed mesh).
PiperOrigin-RevId: 526053615
Change-Id: I3974b3433da513f869b1bdab5e98232e215f6509
2023-04-21 09:01:34 -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 0630b7543d Bump version number to 2.3.4.
PiperOrigin-RevId: 525745444
Change-Id: I8a9994b72a0a2ba3f371bee2c2bea947ad8f4fd1
2023-04-20 07:52:46 -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
Alessio Quaglino 4f5da9c554 Add OnePlugin read/write functions and remove redundant plugin attributes from mjCActuator.
PiperOrigin-RevId: 525708657
Change-Id: I762de238f989b13877d5f9198c83c16ea9dc1d8b
2023-04-20 04:25:43 -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
Alessio Quaglino b25728cc2e Move tree construction to helper class.
PiperOrigin-RevId: 525171924
Change-Id: I28b572fa09a2ccc029e56f9a84808ac53a4e6ac9
2023-04-18 09:42:43 -07:00
Alessio Quaglino 94c4f72907 Specify is volume is too small or negative in mesh error messages. Fixes #799.
PiperOrigin-RevId: 525151156
Change-Id: Ia0e9d8b900b8c372e9229da934a4eb7aeb1a3b7a
2023-04-18 08:16:44 -07:00
Saran Tunyasuvunakool 3e85ef5f38 Remove spurious whole-arena copying in mj_copyData.
Fix #568

PiperOrigin-RevId: 524929990
Change-Id: I164cb98cff752bf5d0a506bc0a290198775da0ef
2023-04-17 13:14:58 -07:00
Alessio Quaglino c943797591 Make shellinertia ignore exactmeshinertia, which is only used for legacy volume computations. Fixes #759.
PiperOrigin-RevId: 524884880
Change-Id: Ia5b64ee33802866f792cdad4acfec6d9baf2a9e9
2023-04-17 10:30:20 -07:00
Copybara-Service bcb19fd85c Merge pull request #802 from hartikainen:fix-typos
PiperOrigin-RevId: 523698082
Change-Id: Ib12bbf8b6a1e02f87a278a230dcb6e5d722d2a94
2023-04-12 07:49:14 -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 f287fb020c Fix mj_sizeModel 2023-04-05 11:09:23 +01:00
Kristian Hartikainen a611b7bf6d Fix typos 2023-04-04 19:58:43 +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 7cc42ecf2a Remove "global" option from [compiler/coordinate](https://mujoco.readthedocs.io/en/latest/XMLreference.html#compiler-coordinate) attribute.
Keeping this rarely-used setting complicates the compiler logic and is blocking future improvements. In order to convert older models which used this option, load and save them in MuJoCo 2.3.3 or older.

PiperOrigin-RevId: 521739137
Change-Id: If0cb40d5db4879a4db9318cc2be258a7923e6e85
2023-04-04 05:59:38 -07:00
Kyle Bayes b327058641 Avoid computing constraint Jacobian matrix supernodes when not using AVX.
PiperOrigin-RevId: 521728016
Change-Id: I308e6283a6a1968a3d9946f04ba4367c50b1c63d
2023-04-04 04:52:49 -07:00
Alessio Quaglino 5f132af625 Add midphase and broadphase statistics to mjData.
PiperOrigin-RevId: 521387641
Change-Id: Id50f2549d119e364216491a23b107e04d9ebb5b6
2023-04-03 00:59:59 -07:00
Yuval Tassa c65e046043 Don't save actdim="{0,1}" for state{less,ful} actuators, respectively.
actdim has a default value of -1 (==unset), which means it currently gets saved for all actuators. After this change, it will only be saved if the value is > 1, errors are thrown for stateful actuators with actdim=0 and stateless actuators with actdim>0.

PiperOrigin-RevId: 520627313
Change-Id: Ia498dae5c7314cfaa0995f8077d297c2339a5c35
2023-03-30 07:00:17 -07:00
Yuval Tassa 1d6a9e09bb Don't save body pos if "0 0 0".
PiperOrigin-RevId: 520598416
Change-Id: I5bb6ffaec386f228ac7a5fa221822000635900ae
2023-03-30 04:09:22 -07:00
Yuval Tassa 3f9defa8d0 Don't save an empty <default/> section.
PiperOrigin-RevId: 520594748
Change-Id: Ib5e1eb3a93e9d579adeda1052a2c29d724d6b497
2023-03-30 03:51:14 -07:00
Yuval Tassa ddfcd3b325 Don't save body gravcomp if 0.
PiperOrigin-RevId: 520592156
Change-Id: Ifb85c1e78498877bc576cfca224c41b3cf47c9ab
2023-03-30 03:34:04 -07:00
Nimrod Gileadi e4d27d4b90 Remove unnecessary null check.
This checked that individual char arrays in the MJCF schema were not null, which would never really happen, and triggered some compiler warnings

PiperOrigin-RevId: 520348916
Change-Id: Ic8b82737460ed3bcf44d9629cd0c7de5782bee8c
2023-03-29 08:54:15 -07:00
Yuval Tassa d6f2dd143d Avoid variable name shadowing in all engine source files.
PiperOrigin-RevId: 519179975
Change-Id: I2f9269cd88857b9e758c63978b20f9c9dd17207e
2023-03-24 10:33:42 -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 15ec12b296 Use mju_symmetrize in engine_derivative.c
PiperOrigin-RevId: 519111361
Change-Id: I3125538dee70eebca7e1e9e7830bde7863be956f
2023-03-24 04:39:00 -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 145fe7f354 Declare loop variables inside for loop declaration where possible.
PiperOrigin-RevId: 518846098
Change-Id: Icdb2e5894bd80110552e29270472eeb242e6cf2c
2023-03-23 06:49:09 -07:00
Yuval Tassa ce6c9053e2 Fix bug in engine_derivative.c
- The inner loop was reusing and modifying an outer loop variable.

PiperOrigin-RevId: 518843275
Change-Id: I922f8768c4e8ef74c2fb2b1fd897de8234336acf
2023-03-23 06:32:31 -07:00