Commit Graph

30 Commits

Author SHA1 Message Date
Kevin Zakka 6048a55daf Add intvelocity actuator shortcut.
PiperOrigin-RevId: 454899823
Change-Id: I9b5494baacfab5a7d03bd680d0ded06a7790e75e
2022-06-14 10:36:58 -07:00
Kevin Zakka 0e1918782a Handle invalid joint type in URDF conversion. Fixes #317.
PiperOrigin-RevId: 454798685
Change-Id: Ic29a3756e78f8714ed8acc70b10e115c3df46561
2022-06-14 01:42:52 -07:00
DeepMind 8dda269c8a Avoid msan reports on globals destructors
Somehow tests load these libs twice, and construct/destruct globals twice.
Can be preproduced even without sanitizers with logging from GlobalModel::~GlobalModel.

themodel does not need to be visible. If it's static each instance will have own a copy.
_mjMap does not need to use string and avoid lifecycle issues at all.

PiperOrigin-RevId: 454678814
Change-Id: I8fca5e1f06cbc2b413beabcece1219445482c0ed
2022-06-13 12:59:09 -07:00
Kevin Zakka ec7133b0d3 More efficient implementation of mju_rotVecQuat.
```
Before:
BM_RotVecQuat_mean           10.1           10.1    833409628  99.055M items/s

After:
BM_RotVecQuat_mean            6.41           6.41  1200000000  156.095M items/s
```
PiperOrigin-RevId: 454601673
Change-Id: Ibb3ce8a6c838a88bdcebd7aaa979b649639edf0b
2022-06-13 07:16:55 -07:00
Copybara-Service d90d50629b Merge pull request #329 from liuliu:liu/fix-memory-issues
PiperOrigin-RevId: 454115420
Change-Id: I741f5f24b67ab79f19051e4e6d67c0a155f639e1
2022-06-10 02:28:18 -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 e050f36b5a Write sensor reftype and refname (if present) to XML file.
PiperOrigin-RevId: 453926332
Change-Id: I61f4aa2dc6186149b22af71eb8bb0fb2ffd84209
2022-06-09 08:03:47 -07:00
Alessio Quaglino d61a575a8c Replace fabs with std::abs.
Using fabs with int arguments broke the clang build on GitHub Actions, with a `-Wabsolute-value` error.

PiperOrigin-RevId: 453872474
Change-Id: I5c1278e9e628b0ea3d6f26c7ee7d6925c6276850
2022-06-09 02:31:18 -07:00
Alessio Quaglino c7c765b6eb Refactor mjXUtil::WriteAttr using templates.
PiperOrigin-RevId: 453848941
Change-Id: I1f87f0c20f0c89caab89ea4891aee7583a92534e
2022-06-08 23:33:49 -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
Liu Liu f748018b28 Fix two asan detected memory bugs
I am running through simulate.swift (my port of simulate.cc) with
address sanitizer to discover related bugs.

Besides ones in my port, there are two in MuJoCo:

1. in maketext, the logic to find . is not protected against j is less
   than 0 (due to the decreasing logic above), creating out of bound
   access.

2. in mj_printFormattedData, qfrc_applied should use length nv not nq,
   otherwise out of bound access could be triggered.

Test Plan:

Run through the simulate.cc with asan. Before this fix, when presenting
profiler view, it will trigger bug #1. When print data, it will trigger
bug #2. Both are using model/humanoid/22_humanoids.xml.
2022-06-07 18:25:26 -04:00
Kevin Zakka 53d3220fcc Fix quaternion typos.
PiperOrigin-RevId: 453203844
Change-Id: I7d788c21bb00b7746f941fb2cf755f0b046e35f2
2022-06-06 08:24:21 -07:00
Alessio Quaglino 16baac9353 Throw an error if multiple orientation specifiers are used in the same element.
- Applies to [orientation specifiers](https://mujoco.readthedocs.io/en/latest/modeling.html#frame-orientations) in `body`, `inertial`, `geom`, `site`, `camera`.
- Before this change the check was done only for multiple *alternative* specifiers, but not for `quat` and an alternative specifier.
- Moved the check from the compiler to the parser.
- Added tests.

PiperOrigin-RevId: 453201981
Change-Id: I20907361f211dae904e734cd083e9df0efe4f654
2022-06-06 08:13:06 -07:00
Kevin Zakka d7ae7f5433 Improve error message when loading textures that are not PNGs.
PiperOrigin-RevId: 452052514
Change-Id: Ic2f0e8717e43d1a17b2d07ac0e07efe96c5ae1bd
2022-05-31 08:27:05 -07:00
Saran Tunyasuvunakool 5cc73c30bf Align all arrays in mjData's buffer to 64 byte boundaries.
The introduction of additional mjData arrays for the implicit integrator caused in a shift in data alignment in memory. In certain combinations of machines and models, this change resulted in ~5% performance regression that appears to be attributable to L2 cache misses.

This change aligns all arrays in mjData to the boundary of a typical L2 cache line size. Benchmarking shows that this resolves the performance regression on a Broadwell machine.

PiperOrigin-RevId: 451652783
Change-Id: I4ed2c2d03453a83a0b4a9b8e224e2fd7c0dadea9
2022-05-28 13:03:38 -07:00
Yuval Tassa 981fa22302 Don't enforce minimum inertia at mesh loading.
Inertias of moving bodies are enforced to be greater mjMINVAL at model compilation, there is no need to enforce inertias at mesh load time. Tiny meshes could be static or part of a larger geom assembly, in which case their tiny inertia is not a problem.

Also, make error message for small masses/inertias more precise.

PiperOrigin-RevId: 451625216
Change-Id: I4b48d7a881e620d6fbb591ec77fbdacc7c03496c
2022-05-28 06:43:24 -07:00
Yuval Tassa e94a46c20f Indent #ifdef blocks, improve comment for MSVC pragma.
PiperOrigin-RevId: 451614625
Change-Id: I5b46572521955b51da48f183d2195817df6ea28d
2022-05-28 04:49:58 -07:00
Saran Tunyasuvunakool 79082ea1ae Fix an out-of-bound read bug in mj_collision exclusion handling.
PiperOrigin-RevId: 451609651
Change-Id: Ifc10753ee65d176e609a9b742414d2c2f13d8bd0
2022-05-28 04:02:02 -07:00
Saran Tunyasuvunakool 1da4e1c784 Fix ASAN_(UN)POISON_MEMORY_REGION macros for MSVC.
Closes #306.

PiperOrigin-RevId: 451609183
Change-Id: Iadc2db7c5550261050340e38b7f7eb8a806013a1
2022-05-28 03:56:32 -07:00
Saran Tunyasuvunakool b5a6a725e5 Asan-poison padding regions in mjModel and mjData buffers.
This allows us to detect reads and writes that are logically out of bounds.

PiperOrigin-RevId: 451520772
Change-Id: I614a8062c404d97148166bcd37db399420956d8b
2022-05-27 17:34:29 -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 6faf1d93de Use explicit template instantiation for mjXUtil::ReadAttr.
PiperOrigin-RevId: 451481936
Change-Id: Ib26e41823606e612f017db0f606983262713066e
2022-05-27 14:35:05 -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
Nimrod Gileadi f713e81297 Explicitly reset xipos for worldbody.
Before this change, xipos[0,1,2] was only set to 0 by mj_resetData zeroing the entire buffer.

When using mj_resetDataDebug, the value would be wrong.

PiperOrigin-RevId: 450939814
Change-Id: I887dd977161c7d132a80b766db7be23350ffb50b
2022-05-25 09:22:06 -07:00
Alessio Quaglino 223874c4ca Correctly handle the case of explicit zero mass in xml_native_writer.
PiperOrigin-RevId: 450901455
Change-Id: I77aaf2a214ac05ed1ed1e6ffe473bf98f2fea8ef
2022-05-25 05:29:25 -07:00
Alessio Quaglino 43e3b3a3f9 If <composite flatinertia="true">, set mjCBody.explicit_inertial so that an <inertial> element is added in mj_saveLastXML. Bug found by the WriteReadCompare test.
PiperOrigin-RevId: 450702639
Change-Id: I978dfb6713d68ce8327f2e8eea1fc31f43a38b5e
2022-05-24 09:38:53 -07:00
Alessio Quaglino 20cc535ba6 xml_native_writer saves geom mass or density, if specified.
Fixes a bug introduced in CL/432455486, which stopped saving explicit inertias if they were inferred from geoms. But if we don't save inertias then we need to save mass/density specifiers.

BEGIN_PUBLIC

xml_native_writer saves geom mass or density, if specified.

END_PUBLIC

PiperOrigin-RevId: 450667775
Change-Id: Ibb5b269b58f1143013091729642bb501243ed943
2022-05-24 06:33:24 -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