Commit Graph

148 Commits

Author SHA1 Message Date
taylor howell b81dfbbc48 fix python type_error mj_differentiatePos, mj_integratePos 2023-06-14 12:19:58 -06:00
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 466c9aca82 Remove mj_activate and mj_deactivate.
PiperOrigin-RevId: 538799120
Change-Id: I4d6729131e20ab9ae15c94c221ba83ae5732e942
2023-06-08 08:55:39 -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 f887c1e928 Add ASAN and MSAN instrumentation for arena and mjData stack.
PiperOrigin-RevId: 535635490
Change-Id: Ia1e58771bae25bf72c861f57452fb8faa2b918fb
2023-05-26 09:17:26 -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
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
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
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 b28d149f8d Update Python dependency versions.
PiperOrigin-RevId: 525759204
Change-Id: I120dfc5a92e207dbe0ee31b04168c84d3ea47008
2023-04-20 08:51:53 -07:00
Nimrod Gileadi 707fcdb44f Correct return type on viewer.launch_passive.
PiperOrigin-RevId: 525753923
Change-Id: Idfff26e89deaeb37dd8b179106640f05c0deabb2
2023-04-20 08:30:42 -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
Saran Tunyasuvunakool c6e35d255c Update dependency versions.
PiperOrigin-RevId: 525487198
Change-Id: Ic352c0dc6aaa4120e1f2fa637a8c483c885ca4cd
2023-04-19 10:33:11 -07:00
Saran Tunyasuvunakool cefc290eac Reorder arguments of Simulate::Load in Python to match C++.
PiperOrigin-RevId: 523973129
Change-Id: I58760e3e392a208dd8257c340da146aa8f745fb7
2023-04-13 05:22:13 -07:00
Saran Tunyasuvunakool 5646c905cd Rename a few functions and variables to be a bit more Googley.
PiperOrigin-RevId: 523963645
Change-Id: Ife7ed3f44aa83c64dfbdc3ca78ee6de2092b0d63
2023-04-13 04:24:31 -07:00
Saran Tunyasuvunakool 2e23594fe8 Add an introspect module for structs.
Also missing struct fields to the Python bindings that were discovered as a result of the new `introspect` metadata.

PiperOrigin-RevId: 523947396
Change-Id: I367fd2dc8d5fd7e5712a45b70a5c50da51d152e4
2023-04-13 02:50:23 -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
Saran Tunyasuvunakool 34226bf52d Fix a race condition in launch_passive and launch_repl.
Before this change, these functions can return before an internal call to `mj_forward`, which results in a race condition if the user script then tries to modify the physics state.

Fixes #783
Fixes #790

PiperOrigin-RevId: 523214378
Change-Id: I8a4c6cef0f5d3ec781fd2c5cae3c20dd4b8be67f
2023-04-10 14:35:53 -07:00
Saran Tunyasuvunakool 6d63e046fd Add low-level CGL context management for macOS.
This allows rendering from non-main threads as the context is not tied to a Cocoa window.

Fixes #742
Fixes #798

PiperOrigin-RevId: 523144359
Change-Id: I98432debdd034814c313eda94e38c248c3c1f76c
2023-04-10 10:09:49 -07:00
Kristian Hartikainen a611b7bf6d Fix typos 2023-04-04 19:58:43 +01:00
Kevin Zakka 3f14d97f6b Add equivalent inertia ellipsoid visualization.
PiperOrigin-RevId: 519154067
Change-Id: I35f1993c1493df9be752b7163385004649498070
2023-03-24 08:47:43 -07:00
Nimrod Gileadi a01318712c Fix a couple of comment typos.
PiperOrigin-RevId: 518347854
Change-Id: I552554fff199ce244b7b364cf0b0486058de0e22
2023-03-21 12:27:53 -07:00
Nimrod Gileadi 33a2ce73d4 Update MuJoCo version to 2.3.3.
PiperOrigin-RevId: 517931617
Change-Id: I7c9960290f1b6e5d5f68a54df617a580f23c57e9
2023-03-20 04:36:09 -07:00
DeepMind c34826ef1a mujoco.renderer.render to output copy of pixel array.
Previously, it returned a view into the internal rgb array, which can be confusing to the user.

PiperOrigin-RevId: 517630186
Change-Id: Ibc1e86b6b6345269523bb4c82c37dd325961a8ec
2023-03-18 05:30:46 -07:00
Saran Tunyasuvunakool 7b91567585 Exit mjpython if any pthread function call fails.
PiperOrigin-RevId: 517401871
Change-Id: I2050769085690d50d331f2955ed1e09ca4c8414c
2023-03-17 06:58:26 -07:00
Saran Tunyasuvunakool 0c4e191dd6 Compatibility fixes for mjpython.
- Find Python functions in the interpreter binary itself rather than trying to find libpython.dylib, because this doesn't exist when using Conda. (https://github.com/conda-forge/python-feedstock/issues/595#issuecomment-1311275470)

- Increase the stack size of both the Python main thread and the OS main thread to 16MiB, to match what Python normally uses on macOS. (https://github.com/python/cpython/blob/3.11/configure#L11038)

- Check whether dlfcn and pthread function calls actually succeeds. Emit error messages and exit on failure rather than continuing the program (which generally leads to segfaults).

- Fix pixelated shadow in the icon.

PiperOrigin-RevId: 517390522
Change-Id: Ib91679b4baa63bac5f6b5893e634712d72161ea5
2023-03-17 05:37:35 -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
Copybara-Service 7690965d73 Merge pull request #769 from milutter:plugin_loading
PiperOrigin-RevId: 517231543
Change-Id: Ia3f0929650da235589e9434db84500b3d9f17df1
2023-03-16 14:40:25 -07:00
Saran Tunyasuvunakool e20ab6c96f Add a number of missing struct fields to Python bindings.
It is quite possible that there are a few other fields still missing since we currently do not yet have automated testing of struct field existence.

Fixes #747.

PiperOrigin-RevId: 517189048
Change-Id: I7c1d95e700eaea05aaa3cde1fd05e1a259553117
2023-03-16 12:05:50 -07:00
Saran Tunyasuvunakool 230e2780de Add viewer.launch_passive and a mjpython launcher for macOS.
The `launch_passive` function launches the GUI viewer in a non-blocking manner, allowing the Python script or REPL to continue execution. The viewer is automatically kept up to date with any subsequent modifications to mjModel and mjData.

Note that when run inside a REPL (including IPython), `launch_passive` is functionally identical to `launch_repl`.

On Linux and Windows, this is achieved by spawning a new thread and launching the GUI there.

On macOS, this is not possible as all Cocoa API calls must be made on the "macOS main thread", which is always the first thread launched in a process and carries the `com.apple.main-thread` dispatch queue. We also cannot simply trampoline from a Python script on the main thread into the user's script on a side thread because CPython's signal handler can only be installed on the "Python main thread". Putting the user's script in a side thread means that it cannot e.g. gracefully handle SIGINT by catching a KeyboardInterrupt exception. To work around this, we ship a custom Python launcher on macOS called `mjpython`. This launcher is a native binary that spawns a pthread and initialize the Python interpreter on that thread, thus allowing "Python main thread" and "macOS main thread" to represent two distinct threads. From Python's point of view, the "macOS main thread" is a secondary thread that runs a loop that continuously empties a Queue of (mjModel, mjData) and launches a viewer.

PiperOrigin-RevId: 517167868
Change-Id: Icac9d2126bbb4760d47e0b9300e0a979cffa4338
2023-03-16 10:53:11 -07:00
mlutter 5215992d55 review comments 2023-03-15 20:51:47 -04:00
mlutter 3cb0121474 fix typo 2023-03-14 14:28:31 -04:00
milutter 53ab95c792 Ensure that loaded plugins are a shared library 2023-03-14 14:21:16 -04:00
Kyle Bayes d3d789cf7d Convert mju_error and mju_warning to variadic functions, supporting printf-like arguments. The functions mju_error_i, mju_error_s, mju_warning_i, and mju_warning_s are now deprecated.
PiperOrigin-RevId: 515431052
Change-Id: I440de0cb417ce216b6d636a5d86dc9ef6cc1fc06
2023-03-09 13:51:27 -08:00
Nimrod Gileadi ac78f8aee9 Update CMake dependencies to latest versions.
Upgrade abseil and pybind11.

PiperOrigin-RevId: 514397331
Change-Id: I4a35dc9f3b9dcc79bdd13016a5326f72cd3fc67f
2023-03-06 07:12:22 -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
Saran Tunyasuvunakool ace5b74f83 Rename inteval attribute in mjLROpt to interval.
PiperOrigin-RevId: 509275105
Change-Id: I0ffb9cf485a504843ed255f0b4f24e9285a1c273
2023-02-13 10:54:25 -08:00
Saran Tunyasuvunakool db28c31f05 Rename <required> tag to <plugin>.
PiperOrigin-RevId: 509237786
Change-Id: I35e812830b479004ac5025cbd9477888f51fb43e
2023-02-13 08:41:52 -08:00
Saran Tunyasuvunakool 5e989d18c3 Enable compiler errors for implicit switch case fallthroughs.
Also unify warning options across Clang and GCC and fix minor issues that was surfaced by this.

PiperOrigin-RevId: 508619655
Change-Id: I59b777bf2dfea4422485670e2427c7d3f5cf6405
2023-02-10 03:49:00 -08:00
Saran Tunyasuvunakool 71c5f1794d Remove efc_ fields from joint indexers.
Since the introduction of arena memory, these fields now have dynamic sizes that change between time steps depending on the number of active constraints. This breaks strict correspondence between joints and `efc_` rows.

Note that these fields can still be accessed directly as attributes on the `MjData` object.

PiperOrigin-RevId: 508342388
Change-Id: I610ae6ca462f6bb5cf8bc199a3436bed3d1a5371
2023-02-09 05:02:11 -08:00
Saran Tunyasuvunakool 7d8e810ab1 Fix IPython history corruption when using launch_repl.
PiperOrigin-RevId: 508064761
Change-Id: I58fa2e4f35b57a1ab68c3172ba5c0d4495e40ced
2023-02-08 06:37:42 -08:00
Saran Tunyasuvunakool e4b094732b Update dependency versions in Python requirements files.
PiperOrigin-RevId: 507791787
Change-Id: I2f87842c118ab6ee25857c52b7c02ca3012e964c
2023-02-07 08:40:52 -08:00
Alessio Quaglino dd632b7ccc Bump MuJoCo version to 2.3.2.
PiperOrigin-RevId: 507720557
Change-Id: I7a5b577094ac1a7f468a84c484f62f61dc6b409f
2023-02-07 02:35:17 -08:00
Saran Tunyasuvunakool f1af86cf82 Fix msan failure in __repr__ when upgraded to NumPy 1.24.
PiperOrigin-RevId: 505661236
Change-Id: I37ea339679870d23886e3c95f51451349fa1de2c
2023-01-30 05:11:25 -08:00
Peter Hawkins cd99fbd59d Fix test failures under NumPy 1.24.
The use of `np.empty` triggers an msan use-of-uninitialized-value error when upgraded.

PiperOrigin-RevId: 503975799
Change-Id: I337c8227c8c1e3bd415d7a798fc5e764c88c0875
2023-01-23 07:04:33 -08:00