Commit Graph

44 Commits

Author SHA1 Message Date
Yuval Tassa 4c066a26b5 Change mjVISSTRING of connect and weld equality constraints from "Constraint" to "Equality". This is more consistent with the 'E' shortcut key and with mjDISABLESTRING ("constraint" means all constraints, "equality" means bilateral constraints).
Also remove unused ampersands from `mjVISSTRING` names, these are a remnant from a very old version of the UI framework.

PiperOrigin-RevId: 593469811
Change-Id: I0f6f73c9f5d2c61b2280f395f76434b0710ce4f3
2023-12-24 12:06:59 -08:00
Yuval Tassa 38fa756a20 Add mjGEOM_LINEBOX, used in visualization of collision trees.
PiperOrigin-RevId: 591224734
Change-Id: I09ad8c4b711021ff4dd5548ba5381d25d5a3d7f8
2023-12-15 05:36:35 -08:00
Alessio Quaglino 9ae40e718e Define mj_multiRay bindings explicitly.
Fixes #1184.

PiperOrigin-RevId: 581956413
Change-Id: I6c611ac7537442a65e6961430ec724326ee6095a
2023-11-13 07:31:22 -08:00
Nimrod Gileadi 084facc9ab Python bindings: Store a reference to MjModel in MjDataWrapper.
Before this change, MjDataWrapper contained a custom data structure called MjDataMetadata, which contained the sizes of various arrays needed to create MjData. This was used for serialization and deserialization, as well as copying MjData instances.

This worked fine for native MuJoCo models, but as soon as plugins were used, there was information in the model that was needed and not available in MjDataMetadata. Since plugins are so general, keeping MjDataMetadata was untenable.

PiperOrigin-RevId: 578205355
Change-Id: I11b9ee797d1da5aaf1fecbbe170b3b0f1f1a3e6c
2023-10-31 09:16:40 -07:00
Alessio Quaglino 5a70ad08ab Add Flex component.
PiperOrigin-RevId: 572830650
Change-Id: I6908228087b7b9683be3506c8d9cdc725ed5dcd5
2023-10-12 10:49:35 +01: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 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
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
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
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 90f58ebe5d Rename mj_stackAllocBytes to mj_stackAllocByte
PiperOrigin-RevId: 559071711
Change-Id: I19072e07ac86ee0486703aa48b0dceb297f5f893
2023-08-22 04:43:53 -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
Saran Tunyasuvunakool 488041d362 Add a private function for resizing contact and efc-sized arrays in Python.
This function is currently used for internal experimentation.

PiperOrigin-RevId: 558238153
Change-Id: I32eec8f13ac2d995e90c5421f2a157412e2148f2
2023-08-18 13:53:04 -07:00
Yuval Tassa 3e034e38b2 Add constraint island discovery
PiperOrigin-RevId: 557067599
Change-Id: Ic41e1d0efef02b7a79142518afe49cf9d4e74725
2023-08-15 02:30:05 -07:00
Yuval Tassa 5cfbb6ac8b Add mjd_quatIntegrate, expose mjd_subQuat.
PiperOrigin-RevId: 546252926
Change-Id: I7d6b2bd6536e7e8afc368f3c46037c20f6a1cb5e
2023-07-07 05:33:24 -07:00
Kyle Bayes ac1f41160d Add engine internal error macro mjERROR to prepend calling function to error function.
PiperOrigin-RevId: 541584847
Change-Id: I57447e64375413ee07aa96372a402e1ced59ff4a
2023-06-19 03:29:31 -07: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
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
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
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 db28c31f05 Rename <required> tag to <plugin>.
PiperOrigin-RevId: 509237786
Change-Id: I35e812830b479004ac5025cbd9477888f51fb43e
2023-02-13 08:41:52 -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
Kevin Zakka a173e01f42 Prevent division by zero in Ornstein–Uhlenbeck control noise.
PiperOrigin-RevId: 498753494
Change-Id: Ib43e165a4da524c12fab4ea05848b084b2e7713c
2022-12-31 10:29:03 -08:00
Copybara-Service 3a00e025ce Merge pull request #619 from traversaro:fixpypytests
PiperOrigin-RevId: 494129535
Change-Id: I301cb505a224eaa26df4896924d36c623b1a4a26
2022-12-09 03:39:22 -08:00
Silvio Traversaro bfe1017fc8 Skip tests that cannot run on PyPy 2022-12-07 19:19:21 +01:00
Yuval Tassa c83be2bc05 Add mju_clip, mju_fill, mju_eye and mju_symmetrize to python bindings.
- Also change signatures of `mju_fill` and `mju_symmetrize` to conform to standard.

PiperOrigin-RevId: 485613824
Change-Id: I8dd618bac92ef40aa6c76380fa73302e81968687
2022-11-02 09:22:28 -07:00
Saran Tunyasuvunakool ec6ea6a69e Fix a memory leak when using Python callbacks.
Fixes #527.

PiperOrigin-RevId: 481173711
Change-Id: Ie176a8bda09727b6be8b6641d3be9a75c675d566
2022-10-14 10:12:11 -07:00
Alessio Quaglino 95fe2fbc40 Add plugin support to Python bindings.
PiperOrigin-RevId: 480675078
Change-Id: I2967654b6662efced8ae62cae9b03c6c8e65c67c
2022-10-12 11:30:15 -07:00
Saran Tunyasuvunakool 58fd72f53d Dynamically allocate contact and efc_ arrays on a new memory arena.
- Add private function `mj_arenaAlloc`. This is used internally to allocate memory from the arena.

- Add private function `mj_nefc` to count constraints. This function returns a tight upper bound on `d->nefc`. The number of counted constraints can be slightly bigger than exact `d->nefc` in the case of constraints with empty Jacobian, as when placing a frictional tendon between two world sites.

- Add new `memory` attribute to the `size` XML element for specification of arena memory size. This attribute is mutually exclusive with `nstack` and `njmax` specifications, which are now deprecated (but left around for the time being for legacy compatibility).

- Move `d->stack` to the end of the new arena space. The stack now grows in reverse from the end.

PiperOrigin-RevId: 479341539
Change-Id: Ie019c202e0908577ffc6f833a37920858116f667
2022-10-06 10:03:05 -07:00
Saran Tunyasuvunakool c13979cd17 Add id and name properties to MjModel and MjData indexers.
PiperOrigin-RevId: 476078133
Change-Id: I905cc8ec147ac595cd56f0a42e38013ae1ac6903
2022-09-22 06:19:03 -07:00
Yuval Tassa f4e7fa97af Add mju_mulVecMatVec, mutiplies a square matrix M by a vector x on both sides. Returns x^T * M * x.
PiperOrigin-RevId: 474292806
Change-Id: I3432469dbe1f02ccf5a13241c7aa12d824cbe034
2022-09-14 08:05:28 -07:00
Yuval Tassa 8957976674 Add mju_boxQP solving box-constrained quadratic programs.
PiperOrigin-RevId: 474256629
Change-Id: I87d70fe6899608122fe0688b017420a3e81afae2
2022-09-14 04:31:34 -07:00
Saran Tunyasuvunakool 3a3ca37615 Fix msan bugs in bindings_test.py.
PiperOrigin-RevId: 465321721
Change-Id: Ie5bfbf5fb0cd3f2b3db3adc86bff3cb1c4df3da0
2022-08-04 08:36:05 -07:00
Nimrod Gileadi 41bcf2d621 Python bindings: Add __repr__ implementations to grouped views.
PiperOrigin-RevId: 457704673
Change-Id: Idf0d2132ce0872e6ae3eef319b4c3119ab769cd0
2022-06-28 05:23:16 -07:00
Nimrod Gileadi e14cf7ddf1 Python bindings: Give a detailed error message when passing non-existent name.
List all valid names in the error message.

Fix an off-by-one error when accessing elements by numeric index (rather than name).

PiperOrigin-RevId: 457702283
Change-Id: I6e4f1518b4ecd9ca91ac9b0bf6b0963fc0a9bd18
2022-06-28 05:06:28 -07:00
Saran Tunyasuvunakool 185b79f664 Make msan treat mjData buffer as uninitialized in mj_resetData.
Indiscriminate memset into d->buffer and m->buffer previously caused msan to not detect uninitialized reads.

Also fix tests with uninitialized read bugs that are detected by msan after this change.

PiperOrigin-RevId: 451508224
Change-Id: I1f4b080a8ef765c34ba7a0adc2c686419f6e5516
2022-05-27 16:34:33 -07:00
Saran Tunyasuvunakool 87539dbd24 Version 2.1.5: Fix GLAD loading on Linux, experimental multi-CCD.
PiperOrigin-RevId: 441482552
Change-Id: I16b7ba81cd81ca2293a9a12bfa08a40ab24c70bb
2022-04-13 16:22:26 +01:00
Saran Tunyasuvunakool 55c1c91382 Don't return ndarray with empty shape through named indexers.
NumPy arrays with an empty shape cannot be assigned via the usual syntax.

Fixes: #238.
Related: #237.
PiperOrigin-RevId: 441265437
Change-Id: Ib0de22c83f9babe9a97682dc5a32660c198ad68c
2022-04-12 20:57:16 +01:00
Saran Tunyasuvunakool 90dea1bdfb Version 2.1.4: Switch to GLAD, minor improvements to simulate.
PiperOrigin-RevId: 439277749
Change-Id: I741d1c499ae88753338fcc6d141a65e92e13023e
2022-04-04 13:53:21 +01:00
Saran Tunyasuvunakool 3c71720d83 Revert commit d627374545.
This commit requires a new binary build, and therefore breaks compatibility with version 2.1.3.

Fixes #217.

Change-Id: I1e08b6fd2c468e3845e2166a1e4cc9d265de64de
2022-03-31 11:54:51 +01:00
Yuval Tassa d627374545 Add contact frame visualisation.
This is useful when writing or modifying collision functions, when the actual direction of the x and y axes of a contact can be important.

PiperOrigin-RevId: 437256700
Change-Id: I5eab737fc98018399e151552778c6109088bf614
2022-03-29 13:08:05 +01:00
Saran Tunyasuvunakool df202d23b1 Implement reversed arithmetic operators for enums and fix division behavior.
PiperOrigin-RevId: 435408435
Change-Id: Ifeeff679cff658d5aae96a9ba5fee19d499656a3
2022-03-23 16:57:25 +00:00
Saran Tunyasuvunakool 295602b3eb Implement binary operations between enums and numbers.
PiperOrigin-RevId: 435352475
Change-Id: I95ffab7d35898b8e04e00e2f37933b7959b90097
2022-03-23 16:57:25 +00:00
Saran Tunyasuvunakool 3577e2cf8b Version 2.1.2: Python bindings, OBJ assets support, bugfixes.
PiperOrigin-RevId: 434731612
Change-Id: I0cfda3e7a3d1c72036764986efc252ffa1b8c6b0
2022-03-15 14:04:44 +00:00