Commit Graph

123 Commits

Author SHA1 Message Date
Yuval Tassa 2ea01bf2f6 Add Related Software section to README.md.
BEGIN PUBLIC

Add Related Software section to README.md.

Fixes #312.

END_PUBLIC

PiperOrigin-RevId: 456528399
Change-Id: Icf97a31a5ea16e93edf9856f70dec650c7b70791
2022-06-22 09:06:43 -07:00
Yuval Tassa 03c2011463 Enable activation clamping when using implicit integrator.
- Introduced private function `mj_advance()` as single point of state & time advancement.

PiperOrigin-RevId: 456525969
Change-Id: Iae17217e305c7baf07cb5ecd1e1b84b936421097
2022-06-22 08:55:48 -07:00
Nimrod Gileadi 2a26bf1ba5 Disable MSAN poisoning when printing using engine_print.
When using MSAN, mjData->buffer is marked as poisoned, despite being initialized with zeroes.
This is useful for catching computations that accidentally use uninitialized values.

However, when using engine_print, it's OK to assume the buffer is initialized to zeros.

PiperOrigin-RevId: 456085776
Change-Id: I9d85e37fa82958eb54ac413140543a6581aa46ad
2022-06-20 08:57:54 -07:00
Yuval Tassa 08b2db2f62 Allow in-place mju_rotVecMat and mju_rotVecMatT (res=vec)
PiperOrigin-RevId: 456021131
Change-Id: Id38ff5fabd15706d3087bc95d341b4f7a673449f
2022-06-20 01:57:45 -07:00
Nimrod Gileadi b1faec1dc2 Use _Generic instead of string comparisons for code that depends on field type.
This will allow us to add fields that can't be cast to int or double, without breaking print.

PiperOrigin-RevId: 456005913
Change-Id: I1fccfd11466f4745f69172af0ae61be07642927c
2022-06-20 00:03:17 -07:00
Saran Tunyasuvunakool 37fe45d41e Change macOS bundle structure.
This allows us to sign and notarize the bundle with mujoco.tbd in place, which is required for AppleClang to be able to build against the embedded framework.

PiperOrigin-RevId: 455952502
Change-Id: I366f1c17e7a6c06d956467ced6f16f3c37aebf6a
2022-06-19 14:13:23 -07:00
Saran Tunyasuvunakool 0e5ce18cff Manually parse inf and nan.
The C++ standard library `std::istringstream` is not guaranteed to parse "inf" and "nan" as valid floating point numbers. In our testing, libc++ does this, but libstdc++ and MSVCRT do not.

PiperOrigin-RevId: 455435431
Change-Id: I99c00303b08c2e4e62acfa3ca52a21a3008f4545
2022-06-16 11:57:52 -07:00
Alessio Quaglino 69a506e6ba Use C++ strcpy_arr in xml_native_reader_test.
PiperOrigin-RevId: 455375707
Change-Id: Ia3dbb11886ab29c4ad3192e4f78b4b60b94baad0
2022-06-16 07:15:14 -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 e0b6ba4a13 Raise warning if there are NaNs in the XML.
For Windows, throw an error if NaNs are present.

PiperOrigin-RevId: 455340787
Change-Id: Ibd95e2335ab15b706ee3328816983e5b57b2315e
2022-06-16 03:09:24 -07:00
Yuval Tassa 8958e13878 Improve best-practice description of included models in GitHub issues.
PiperOrigin-RevId: 455060429
Change-Id: I6a4544e99436749590a8d46ada09777ce2e90330
2022-06-15 01:06:15 -07:00
Kevin Zakka 2de8aa9e92 Fix redundant actuators in modeling doc.
PiperOrigin-RevId: 454942117
Change-Id: Id5ffa3339cb0188863570071dc56f6ead794e5a4
2022-06-14 13:29:42 -07:00
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 959ed08246 Merge pull request #320 from djbutler:main
PiperOrigin-RevId: 454562743
Change-Id: Ia0d3067f7a37f30b1d2ae3b7a5755b7cbad3a114
2022-06-13 03:13:42 -07:00
Kevin Zakka f8b9e3e00f Add CMake entry for engine_util_spatial_benchmark_test.
PiperOrigin-RevId: 454424726
Change-Id: If79e9452c18220ddf0107157d78a2f08ce099a04
2022-06-12 01:01:46 -07:00
Nimrod Gileadi 5ac797965c Use batch mode in step_benchmark_test.
d8880e9a12 introduced measuring performance of a fixed batch of 50 steps, with a fixed starting state.
The Google Benchmark library has a more direct API for doing this, which ends up with nicer looking reported numbers.

PiperOrigin-RevId: 454133316
Change-Id: I368b985dc871084b9ed8c41a87016408719b53ad
2022-06-10 04:22:18 -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
Yuval Tassa d8880e9a12 Modify step_benchmark_test.cc to benchmark a fixed, 50-step sequence.
- Also remove multithreaded benchmark results.

PiperOrigin-RevId: 454102292
Change-Id: I5bd5fb1642adc547e695d2d3553bcaf0cf5c7bed
2022-06-10 00:52:43 -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
Copybara-Service 3bf377a10d Merge pull request #311 from lucas-inacio:main
PiperOrigin-RevId: 453879533
Change-Id: Ic535ad0a2bc919e98af0561fd9bad1708e9019f6
2022-06-09 03:16:40 -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
Kevin Zakka 78c7e6e21f Add an example benchmark for methods in engine_util_spatial.
PiperOrigin-RevId: 453609626
Change-Id: I4986196ea3573bc22669c146ab6a311566035b73
2022-06-07 23:56:43 -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
Yuval Tassa f428c1bf56 Improve example XML snippet in "URDF Extensions" section.
`discardvisual="false"` is often required when importing URDF models.

[Relevant issue](https://github.com/deepmind/mujoco/issues/326).

PiperOrigin-RevId: 453429187
Change-Id: I6dccc5656114224d11010c87e6a127321cce93c1
2022-06-07 07:12:26 -07:00
Yuval Tassa c062531fc7 Fix formatting bug in overview.rst
PiperOrigin-RevId: 453257852
Change-Id: I9312f6a30e0b73199148435da8f6dd8ed1249e10
2022-06-06 12:28:29 -07: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
Yuval Tassa 652bab3eec Improve documentation of <freejoint> element.
PiperOrigin-RevId: 453192974
Change-Id: I14b02c8c37f6208a67b35efc17887668f6555aef
2022-06-06 07:15:41 -07:00
Yuval Tassa 8e38a8a020 Add "Asking Questions" section to README.md
PiperOrigin-RevId: 453178202
Change-Id: I0cb3a52983930fb3665cc40e26d5d19b44ac99f1
2022-06-06 05:23:55 -07:00
Yuval Tassa 880304abba Update the asset/mesh section of the XML reference to mention OBJ files.
Also clean up some formatting.

PiperOrigin-RevId: 453173729
Change-Id: I069b9433542dda0e3effe71d162cb51a46ce2f4e
2022-06-06 05:02:41 -07:00
Dan Butler c0282237f1 Update documentation for 'boundmass' attribute of 'compiler' xml element to include usage 2022-06-02 19:35:06 -07:00
Lucas Inácio Viegas edd7fd8695 Merge branch 'deepmind:main' into main 2022-05-31 12:52:25 -03:00
Lucas Inácio Viegas 2c54ec67cb Using CMAKE_CURRENT_SOURCE_DIR to properly refer to mujoco's include directory 2022-05-31 12:36:14 -03: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
Alessio Quaglino 8902c2089a Add dyntype to IncompleteActlimited test.
The test is meant to illustrate a failure of an incomplete actrange when the rest of the line is correct.

PiperOrigin-RevId: 451895379
Change-Id: I9782fae7055c9bed87ccbc0fda18495aacb2ae8a
2022-05-30 10:37:10 -07:00
Tom Erez 02f300c762 Refactor: separate buffer indexing and swizzling.
This also fixes a sensor data reading bug: previously, _sensorIndex was multiplied by 3 by MjEngineTool.

PiperOrigin-RevId: 451699887
Change-Id: I864bcbf8159857764854b25311a26ec5672125d9
2022-05-29 00:24:30 -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