Commit Graph

55 Commits

Author SHA1 Message Date
Yuval Tassa 30b4309af9 Rename mjpPlugin.capabilities -> mjpPlugin.capabilityflags
PiperOrigin-RevId: 495080532
Change-Id: I81743472b816a331890a7cb05bfb7a89ebf07ff9
2022-12-13 11:33:27 -08:00
Saran Tunyasuvunakool 5c021d042b Modify signature of plugin reset callback.
The `reset` function is called inside `mj_resetData`, before any physics forwarding call has been made. It is therefore an error to read anything from mjData at this stage.

The only valid operation on mjData during `reset` is for a plugin to write into its own state variable slots and data struct. We modify the function signature to only provide access to these.

PiperOrigin-RevId: 495032492
Change-Id: Ic6d2967d2571a9083cbca1ba239ca70a8a51f474
2022-12-13 08:41:35 -08:00
Saran Tunyasuvunakool e4f1d584ad Add control plugin API.
PiperOrigin-RevId: 493311715
Change-Id: Iccd99fb26004f39832818e378f01f9149a0e3e3b
2022-12-06 08:23:49 -08:00
Kyle Bayes 73fb61e3e2 Bump version number to 2.3.1.
PiperOrigin-RevId: 493076656
Change-Id: I48c7a45b503c4a7363ea1455a4a3788262d007f7
2022-12-05 12:13:55 -08:00
Alessio Quaglino 0d52feaa94 Add updateScene callback for plugins.
PiperOrigin-RevId: 492497689
Change-Id: I4a15cc5fa39dc7c9b85d132727f82033d4aec2c8
2022-12-02 10:11:32 -08:00
Saran Tunyasuvunakool 9ecade0707 Move plugin loading and scanning logic from Simulate to MuJoCo library.
PiperOrigin-RevId: 489020177
Change-Id: I1c29d931b47d5252e57e1d797cc7c17645859ffc
2022-11-16 13:15:51 -08:00
Alessio Quaglino fd4d47e4a5 Format memory warning in human-friendly way.
PiperOrigin-RevId: 486610408
Change-Id: I6beecb12059e69f4407e921d20efc54ce6b3f491
2022-11-07 02:56:07 -08:00
Yuval Tassa 36b30e4500 Allow more than 1 activation state per actuator, but only for dyntype user.
Fixes #305.

PiperOrigin-RevId: 486597273
Change-Id: I3eb806f60949e68ebe6cbe35a6e66218a167ed45
2022-11-07 01:43:02 -08: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
Kyle Bayes 23092a11d7 Add per-body gravity compensation (buoyancy) passive force.
PiperOrigin-RevId: 485342531
Change-Id: Icb3e6bb5080b6ef17a3d3b1cc67e0503cfeaeffb
2022-11-01 09:48:06 -07:00
Saran Tunyasuvunakool c7960385be Declare DllMain as extern "C".
Fixes #550.

PiperOrigin-RevId: 484540205
Change-Id: I3915f65f1ae6ab3a93118b9d747b5c09d9abe872
2022-10-28 08:41:46 -07:00
Yuval Tassa 893942a729 Allow tendon springlength attribute to take two values between which the spring produces no force (a deadband).
If given two non-decreasing values, `springlength` specifies a deadband for spring stiffness, inside of which the force is 0 and outside of which force behaves like a regular spring, with the setpoint corresponding to the nearest value. This can be used to create tendons whose limits are enforced by springs rather than constraints, which are cheaper and easier to analyse. See test/engine/testdata/tendon_springlength.xml example model.

Spring-limited spatial tendons whose lower range value is 0 are rendered as catenaries.

Fixes #520.

PiperOrigin-RevId: 484509706
Change-Id: I6698e94ee36168f52d501e83057559805e05172d
2022-10-28 05:57:37 -07:00
Yuval Tassa 0eb7f871b9 Remove requirement that stateless actuators come before stateful actuators.
PiperOrigin-RevId: 484332415
Change-Id: I1dae92c0f8e027e4ca71c20ea3f68b2926526f53
2022-10-27 13:18:57 -07:00
Yuval Tassa f905c7fb7f Add mju_fill, mju_symmetrize and mju_eye utility functions.
PiperOrigin-RevId: 484226916
Change-Id: I79593d54e903ddacab0f859bfc6d17eccad7d3a1
2022-10-27 05:28:26 -07:00
Saran Tunyasuvunakool 57b0b36699 Bump version number to 2.3.0.
PiperOrigin-RevId: 481823754
Change-Id: Ie8c2c65b11178952355830ef019fe2efdf774189
2022-10-17 22:36:59 -07:00
Alessio Quaglino e250ff0d5a - Added passive forces plugins
- Added new `cable` composite type:
  * The `initial` parameter specifies the joint at the starting boundary: `free`, `ball`, or `none`.
  * The boundary bodies are exposed with the names:`B_left` and `B_right`.
  * The vertex initial positions can be specified directly in the XML with the parameter `vertex`.
  * The orientation of the body frame **is** the orientation of the material frame of the curve.

- Added new `cable` passive force plugin:
  * Twist and bending stiffness can be set separately with the parameters `twist` and `bend`.
  * The stress-free configuration can be set to be the initial one or flat with the flag `flat`.
  * New cable example showing the formation of plectoneme.
  * New coil example.
  * New belt example showing interaction between twist and anisotropy.
  * Added test using cantilever exact solution.

PiperOrigin-RevId: 480033694
Change-Id: I491271bce8fccb185961477e903e5a72d172c8a3
2022-10-10 02:46:51 -07:00
Saran Tunyasuvunakool 1a393429ef Fix formatting of large unsigned numbers in mju_warningText.
PiperOrigin-RevId: 479902611
Change-Id: Ia7187478a246b8b068684e75d6f3851d749844c9
2022-10-09 04:55:26 -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
Tom Erez d995787cb7 Use angle brackets for standard-library imports.
PiperOrigin-RevId: 479168997
Change-Id: Ib6820f159c35fff4be9169679cde344855a9cd53
2022-10-05 16:16:58 -07:00
Alessio Quaglino bc1490b7a8 Add realtime parameter to visual global.
PiperOrigin-RevId: 478775714
Change-Id: Ic2d178a5c57d298d005215219ce8470392c4651b
2022-10-04 07:09:15 -07:00
Saran Tunyasuvunakool f9b4593d11 Add macro for dynamic library plugin initializer definition.
PiperOrigin-RevId: 478544478
Change-Id: Idc899eef25261f2cb0b8317a84989cea2d8c2243
2022-10-03 10:40:30 -07:00
Yuval Tassa a6b338db64 mju_boxQP only reads from the lower triangle of the input Hessian.
- Before this change, an asymmetric Hessian would lead to solver failure. After this change the Hessian is symmetric by definition (upper triangle is ignored).
- API documentation was updated to reflect this contract.

PiperOrigin-RevId: 477135411
Change-Id: I60d011d36853afebac26c359771c217baf101360
2022-09-27 04:32:40 -07:00
Saran Tunyasuvunakool 1e2a9a53bc Implement plugin mechanism for actuators and sensors.
PiperOrigin-RevId: 474874088
Change-Id: I65a8ffdf845f4fa0f8266c165883a747ab5812d8
2022-09-16 12:21:29 -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 94b6ae2b69 Bump version number to 2.2.2.
PiperOrigin-RevId: 472513958
Change-Id: I42f321c6681fdd42c5f80368f612534aa885af74
2022-09-06 11:32:55 -07:00
Saran Tunyasuvunakool 4210d31cf0 Restore MJAPI declaration for mjd_transitionFD.
Commit e3a82247c2 removed MJAPI in mujoco.h but not in engine_derivative.h, causing a linking error when building on Windows with MSVC.

PiperOrigin-RevId: 471639915
Change-Id: I6b965e23a19faee6f9f8f9c0168dc2774b19f310
2022-09-01 14:55:15 -07:00
Yuval Tassa e3a82247c2 Add sensor matrices to mjd_transitionFD.
- Also add missing `mj_jacSubtreeCom` to Python bindings.

PiperOrigin-RevId: 471610181
Change-Id: I31410d194527ce6a7bdbd01e176f3a41efa52d84
2022-09-01 13:00:36 -07:00
Alessio Quaglino d26501c0f3 Add two new attributes to weld constraints:
- `anchor` determines the point of wrench application, in the frame of body2.
- `tfratio` scales applied torques relative to applied forces.
- Add visualisation of both anchor points to both weld and connect constraints.
- Add a test model showing how the new weld parameters behave.

PiperOrigin-RevId: 470021901
Change-Id: I3faba0e5dcab2e29ee81096f5ff71ff66d99758c
2022-08-25 10:22:15 -07:00
Yuval Tassa 090fe2db3f Add a disable flag for sensors.
PiperOrigin-RevId: 469473066
Change-Id: I296ed790c6261c4fb15b349540edcb77e53e0567
2022-08-23 09:02:56 -07:00
Alessio Quaglino abc0a39b7a Add two new attributes to weld constraints:
- `anchor` determines the point of wrench application, in the frame of body2.
- `tfratio` scales applied torques relative to applied forces.
- Add visualisation of both anchor points to both weld and connect constraints.
- Add a test model showing how the new weld parameters behave.

PiperOrigin-RevId: 469228149
Change-Id: I836b0791f10fb624607a12ef3c687da991c21789
2022-08-22 10:46:46 -07:00
Alessio Quaglino 8ca5887c20 Add two new attributes to weld constraints:
- `anchor` determines the point of wrench application, in the frame of body2.
- `tfratio` scales applied torques relative to applied forces.
- Add visualisation of both anchor points to both weld and connect constraints.
- Add a test model showing how the new weld parameters behave.

PiperOrigin-RevId: 469190483
Change-Id: I20f6da85b09cd2c4c0b5d29eb8003eabb524e55e
2022-08-22 08:19:22 -07:00
Yuval Tassa c8ff7b3d34 Remove distance constraints.
- `distance` constraints were not very useful and increased the contact buffer within the constraint solver, violating a core design principle. Therefore they have been removed.
- The enum value `mjEQ_DISTANCE` is retained, but errors will be thrown in the parser and engine if these constraints are selected.

PiperOrigin-RevId: 467050101
Change-Id: Ie72a07e4fe338eea5107004a9fc0f5e47eb0c3b7
2022-08-11 14:31:11 -07:00
Copybara-Service 396fdf00c3 Merge pull request #425 from aftersomemath:cull-face-flag
PiperOrigin-RevId: 466904386
Change-Id: Icd5515c2bbb8f8f3417501ea43c8e5ae22b32f91
2022-08-11 02:44:37 -07:00
Copybara-Service 9cd1c2f726 Merge pull request #428 from aftersomemath:segmentation-doc-fix
PiperOrigin-RevId: 465644599
Change-Id: I5f3c0ef5d52935906e73035c371345f936e062ea
2022-08-05 14:11:08 -07:00
Levi Burner 581f009c02 Cull face flag 2022-08-05 11:53:46 -04:00
Levi Burner eab1f0da7d Fix off by one in segmentation with IDCOLOR documentation 2022-08-05 11:46:22 -04:00
Yuval Tassa b966a37855 Add optional azimuth and elevation to initial free camera.
- Add `azimuth` and `elevation` to `visual.global`.
- Add `mjv_defaultFreeCamera`.
- Use `mjv_defaultFreeCamera` in `simulate`.

PiperOrigin-RevId: 465505244
Change-Id: I61e60f14a990d4e2d220958adb75c325001978ee
2022-08-05 01:04:02 -07:00
Yuval Tassa 3d77eb1ef4 Add adhesion actuators.
- Adhesion actuators using contact normals as force transmission mechanism.
- Related video: https://youtu.be/HdBue4MUZys

Closes #229

PiperOrigin-RevId: 464389367
Change-Id: I9f69b3cd152d957e8f65870d208788463c036a6d
2022-07-31 08:54:06 -07:00
Yuval Tassa fcf4131771 Add mj_jacSubtreeCom for computing subtree center-of-mass Jacobians.
PiperOrigin-RevId: 464075727
Change-Id: If679c0fdd05b7dc84154cec00963aeea7bbdacc3
2022-07-29 07:44:32 -07:00
Saran Tunyasuvunakool 373cc894a8 Bump version number to 2.2.1.
PiperOrigin-RevId: 461471944
Change-Id: Ia752d992fabdc57b822bc30b01030c19162917ac
2022-07-17 09:50:31 -07:00
Yuval Tassa 138a01625e Fix typo.
PiperOrigin-RevId: 460312313
Change-Id: I4ff1f82afb28d1286e33aaee8b008f76f81935ac
2022-07-11 15:20:38 -07:00
Yuval Tassa c14a7ef4a7 Add clock sensor type.
PiperOrigin-RevId: 459720950
Change-Id: Ibda48ae7dc4aa7be451a947a1c53d10a7eaf176b
2022-07-08 03:50:08 -07:00
Yuval Tassa d3a86bb748 - Add floating changes to changelog.
- Add sections about the state and derivatives to the Computation chapter.

PiperOrigin-RevId: 459032736
Change-Id: I0b69401688f24c84d5747f1b49980e38e19a54a3
2022-07-05 02:18:01 -07:00
Yuval Tassa 6d01627c0b No longer modify control vector in-place, add mju_clip.
- Never modify `d->ctrl`:
  - `ctrl` values which are outside their respective `ctrlrange` are clamped internally, but `d->ctrl` itself is unmodified.
  - Similarly, if `mjWARN_BADCTRL` is raised (NaNs or huge values), `ctrl` is cleared internally, but `d->ctrl` itself is unmodified.
- `mjWARN_BADCTRL` is no longer raised for `d->ctrl` values that are larger in absolute value than `mjMAXVAL`, if clamping makes them smaller than that.
- Added `mju_clip()` utility function.
- Added missing warning string for `case mjWARN_BADCTRL`.

PiperOrigin-RevId: 459025950
Change-Id: Ifbf974f9c02c3d70afdaa3114018fc81dfd746d3
2022-07-05 01:38:32 -07:00
Yuval Tassa 09a5efc09e Add control values to keyframes.
- Add basic test for keyframes.
- Add missing documentation for keyframe mocap positions and quaternions.

PiperOrigin-RevId: 459021649
Change-Id: I91cf7ecbddc6262e8c72a868eeb82d627f389fb3
2022-07-05 01:07:37 -07:00
Alessio Quaglino 2d0995b47c Add visualisation groups to skins.
PiperOrigin-RevId: 458441645
Change-Id: I14324e8efda5142b2718a5cc9215228c7556dbf7
2022-07-01 04:57:34 -07:00
Yuval Tassa 228264c92b Add efficient finite-difference Jacobians of mj_step.
- Add `qH` and `qHDiagInv` to `mjData` to save factorized modified inertia.
- Add `mj_EulerSkip`, `mj_implicitSkip`, to `engine_forward.c`.
- Using the above functions, implement `mj_stepSkip` in `engine_derivative.c`.
- Add `mjd_stepFD` and `mjd_transitionFD` to `engine_derivative.c` to compute `mj_step` Jacobians.
  - Exploit "Skip" functionality for speed.
  - Correctly handle quaternion derivatives.
  - Handle warmstarts and control limits.

PiperOrigin-RevId: 456584811
Change-Id: Iee8541f11e7b66feb8f431cb102d9bbe65461f79
2022-06-22 12:48:48 -07:00
Alessio Quaglino 307cf692e5 Add <damper> actuator shortcut and related mjGAIN_AFFINE.
**Rationale**

A general `mjGAIN_AFFINE` actuator adds the term `force = (c + kp * length + kv * velocity) * ctrl`. The damper shortcut restricts it to `kv * velocity * ctrl` and sets the `ctrllimited` attribute to true.

**API**

```xml
<actuator>
  <damper ctrlrange="0 1" kv="1"/>
</actuator>
```

* Required attributes: `ctrlrange` (>=0)
* Optional attributes: `kv` (>=0)

PiperOrigin-RevId: 455366866
Change-Id: I88773abbeccabb6442f215c9fc05e205df63f692
2022-06-16 06:21:17 -07:00
Alessio Quaglino 066367fcc8 Add visualisation flag for activations.
- Added illustrative model: `test/engine/testdata/activation.xml`

PiperOrigin-RevId: 453628961
Change-Id: I061ec3d17e57c6baffa0fe446a0be3564c44519d
2022-06-08 02:19:03 -07:00