Commit Graph

30 Commits

Author SHA1 Message Date
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
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
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 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
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
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
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
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
Yuval Tassa 165e72f798 Apply force perturbations at selection point rather than body center-of-mass.
PiperOrigin-RevId: 489996756
Change-Id: I87870a0c1d173449f15a7249f2459a6b726ff417
2022-11-21 09:13:16 -08:00
Yuval Tassa 5004a4c8c5 Better memory setting and reporting, updated example models.
- Memory heuristic rounds up to the nearest MB.
- `simulate` reports total memory currently allocated in the info box.
- All example models use `<size memory/>` rather than legacy attributes.
- Regenerated `example_saved.xml` and reformatted original model in [overview chapter](https://mujoco.readthedocs.io/en/latest/overview.html?#examples).
- `<size>` top-level section does not get written if empty.

PiperOrigin-RevId: 486702670
Change-Id: I0306e335f32344c59562ba606664ec9d2101f8a8
2022-11-07 10:36:37 -08: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
Nimrod Gileadi a693a2d981 Don't infer limited attributes automatically by default.
This is an amendment to 4bfc2c0311.

Add an autolimits compiler option. When true, *limited will be inferred from the presence of the *range attributes.
When false, models where limited is not specified, and range is will fail to compile.

PiperOrigin-RevId: 472438650
Change-Id: I489098e879ee695030f44e0d8cd969787e75fb90
2022-09-06 06:11:53 -07:00
Yuval Tassa 46da1285af Cartesian end-effector control using site transmission.
- Added `refsite` attribute to actuators with `site` transmission.
- Such actuators now have a well defined length and can be used for e.g., Cartesian end-effector control.
- Added example models and documentation describing the new feature.

PiperOrigin-RevId: 471561218
Change-Id: I538f09af9600d5c53992c4a9fed325648aab4fa3
2022-09-01 10:06:52 -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
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 ae0ac86ec3 Add catenary visualisation to string-like tendons.
https://youtu.be/I2q7D0Vda-A

PiperOrigin-RevId: 468687422
Change-Id: I84f34e149cf098346a77a51f265113d8fa4f2525
2022-08-19 06:25:07 -07:00
Yuval Tassa ea956dfe34 Derivatives of ellipsoid fluid model.
PiperOrigin-RevId: 459751881
Change-Id: I52db87d82e20e10698b13065df2e983b9841bd7a
2022-07-08 07:19:48 -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 6ead14614f Adds rendering of ball and free joints actuators using an inflated joint geometry.
PiperOrigin-RevId: 453939612
Change-Id: I621f91d242b2974e6ae6acf239cdcb10efcb2629
2022-06-09 09:10:03 -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
Alessio Quaglino 736e0b391b Added visualization of site actuators.
PiperOrigin-RevId: 453609866
Change-Id: Icde220687f0c0e9e7fbbe0e3e56d995f823ffe07
2022-06-07 23:59:06 -07:00
Alessio Quaglino f3453cf87f Stricter parsing of XML array attributes.
PiperOrigin-RevId: 451456510
Change-Id: I2556d4365762378261c04d3c9f1942166fbd156e
2022-05-27 12:51:02 -07:00
DeepMind 64bc6d27b2 Add implicit integrator.
Added analytic derivatives of smooth (unconstrained) dynamics forces, with respect to velocities:
  - Centripetal and Coriolis forces computed by the Recursive Newton-Euler algorithm.
  - Damping and fluid-drag passive forces.
  - Actuation forces.

A new implicit-in-velocity integrator is implemented using the analytic derivatives. This integrator lies between the Euler and Runge Kutta integrators in terms of both stability and computational cost.

PiperOrigin-RevId: 450377010
Change-Id: Ie192b441876c22e732fb749333926f296e0a09cc
2022-05-23 01:22:15 -07:00
Saran Tunyasuvunakool 1913a02b40 Initial open sourcing of MuJoCo.
PiperOrigin-RevId: 450374687
Change-Id: Ie3225a46ce095fc28ae8e63c326a640261f562bb
2022-05-23 01:08:49 -07:00