Commit Graph

146 Commits

Author SHA1 Message Date
Yuval Tassa d5059f484d Add license badge to README.
PiperOrigin-RevId: 460437521
Change-Id: I25514343a6b0f507c661261a20d1ad07465491fc
2022-07-12 05:40:28 -07:00
Yuval Tassa 138a01625e Fix typo.
PiperOrigin-RevId: 460312313
Change-Id: I4ff1f82afb28d1286e33aaee8b008f76f81935ac
2022-07-11 15:20:38 -07:00
Yuval Tassa 50a72d7227 Don't use var[restrict n] syntax.
This notation is unsupported by MSVC.

PiperOrigin-RevId: 460030944
Change-Id: Ib86b76c8767d83ab49e4db9d3d0fd1437721df20
2022-07-10 02:31:21 -07:00
Yuval Tassa ea956dfe34 Derivatives of ellipsoid fluid model.
PiperOrigin-RevId: 459751881
Change-Id: I52db87d82e20e10698b13065df2e983b9841bd7a
2022-07-08 07:19:48 -07:00
Yuval Tassa 7034851d0a Add slider-crank example to model/
PiperOrigin-RevId: 459746610
Change-Id: I6ff609718adba7166cef6a105331d83cc3ee3097
2022-07-08 06:43:14 -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
Yuval Tassa 5ba880506c Improve header and paragraph spacing.
PiperOrigin-RevId: 458935896
Change-Id: Ibbd084ddd18cf9c1a5fe59b3ca60b715595cf606
2022-07-04 11:05:16 -07:00
Tom Erez 3df3c95812 Update C# bindings.
PiperOrigin-RevId: 458919739
Change-Id: I7737d2736491dae8fce46bc36aa5135007a7a588
2022-07-04 08:47:29 -07:00
Nimrod Gileadi b1e185bb9e Fix ReadTheDocs config.
build.os is a required field, see docs: https://docs.readthedocs.io/en/stable/config-file/v2.html#build-os

PiperOrigin-RevId: 458465958
Change-Id: I24889d32996328290c2f470c4f2a593fa89a637d
2022-07-01 07:31:00 -07:00
Nimrod Gileadi 2b319c81bc Update sphinx and jq for documentation.
Old versions of Sphinx don't support Python 3.10.

sphinx-rtd-theme 1.0.0 supports Sphinx 4.x:
https://sphinx-rtd-theme.readthedocs.io/en/stable/changelog.html#features

PiperOrigin-RevId: 458455382
Change-Id: Ic34a7d350d5ecd1dfff53d88472a3b25a7245ec0
2022-07-01 06:27:14 -07:00
Nimrod Gileadi dbef8e6c2b Fix memory leaks when loading an invalid model from MJB.
PiperOrigin-RevId: 458445745
Change-Id: I99229a66fc86f7763cfe2b5382229b0304bdfa9c
2022-07-01 05:21:55 -07:00
Alessio Quaglino 2d0995b47c Add visualisation groups to skins.
PiperOrigin-RevId: 458441645
Change-Id: I14324e8efda5142b2718a5cc9215228c7556dbf7
2022-07-01 04:57:34 -07:00
Nimrod Gileadi 040deb161f Run cmake-format on test/xml/CMakeLists.xml
PiperOrigin-RevId: 458226371
Change-Id: I34f43a890dee7511597b48b303d5674ab9435d64
2022-06-30 07:59:39 -07:00
Nimrod Gileadi d567263959 Fix null pointer dereference in mj_loadModel.
mj_makeModel returns NULL if any of the array sizes are negative. Callers of the function need to handle that case.

PiperOrigin-RevId: 457948558
Change-Id: I9a5c8c0d3293ed0a92c5791f00d3ed34c848e024
2022-06-29 05:09:54 -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
Nimrod Gileadi a077db1b91 Implement __repr__ and __eq__ on MjrRect in Python bindings.
PiperOrigin-RevId: 457457401
Change-Id: I0d395ff301fbcf775b4766ac81c830a625b3be63
2022-06-27 05:55:38 -07:00
Nimrod Gileadi 263c92e301 Update lodepng to latest version.
This speeds up PNG loading significantly.

PiperOrigin-RevId: 457431911
Change-Id: I28da22a1fdbfc912d187a40cd731d9c04b83e07c
2022-06-27 03:06:55 -07:00
Kevin Zakka afc8395376 Make installation instructions more explicit in the README.
PiperOrigin-RevId: 456976659
Change-Id: I9bac31771eb62e069107b30122478437b67c2ebf
2022-06-24 03:48:26 -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
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