Commit Graph

62 Commits

Author SHA1 Message Date
Yuval Tassa 893c404230 Runtime disabling of actuators according to group.
Added `option-actuatorgroupdisable` attribute and associated `mjOption.disableactuator` integer bitfield, used to disable sets of actuators at runtime according to their group.

- The first 6 actuator groups are toggleable in the `simulate` viewer.
- Minor refactor and cleanup of actuator documentation.

https://youtu.be/H9qG9Zf2W44

Fixes #1092.

PiperOrigin-RevId: 578335600
Change-Id: I4cf663b90ea768e4380acfa2fe3b8c15c7cbb568
2023-10-31 16:24:38 -07:00
Nimrod Gileadi 393cfec1e8 Don't use PluginTest as the fixture name in xml_native_writer_test
PiperOrigin-RevId: 574129298
Change-Id: I8c3e10bf271d54cb414b8d2af3724d8c81b6fc80
2023-10-17 06:32:37 -07:00
Yuval Tassa d88675a034 Change the default of <compiler autolimits> from "false" to "true".
PiperOrigin-RevId: 573184793
Change-Id: I24075a8d953d0a3c3ddf65c67e1e18075cd029b6
2023-10-13 05:05:24 -07:00
Yuval Tassa 493ae95d69 Add stack leak test to WriteReadCompare
PiperOrigin-RevId: 572953669
Change-Id: Id6cad3fc86777d68f218119f67c9dc473bdcfcc8
2023-10-12 10:53:24 -07:00
Alessio Quaglino 5a70ad08ab Add Flex component.
PiperOrigin-RevId: 572830650
Change-Id: I6908228087b7b9683be3506c8d9cdc725ed5dcd5
2023-10-12 10:49:35 +01:00
Alessio Quaglino 36d2ffe4f2 Specify camera parameters using standard robotics conventions.
PiperOrigin-RevId: 569147555
Change-Id: I3443f95e5de56a17024f5e5c03f33888dd583edb
2023-09-28 05:19:19 -07:00
Alessio Quaglino d3d46e16a4 Remove cloth and rope composites and deprecate loop.
PiperOrigin-RevId: 568168329
Change-Id: Ida4a5236bef74828c7bf59affdc28adea3db53b1
2023-09-25 03:38:43 -07:00
Alessio Quaglino 1afd98ec4b Add [SdfLib](https://github.com/UPC-ViRVIG/SdfLib) plugin to first-party SDFs.
The following dependencies are disabled with a cmake patch file.
- Enoki
- OpenMP
- Assimp
- FCPW

PiperOrigin-RevId: 565352386
Change-Id: Icff9de68408e0afa2032bb83b24491fc4e41d181
2023-09-14 06:42:42 -07:00
Saran Tunyasuvunakool 94a8705ad0 Add mj_markStack and mj_freeStack as public API functions.
Also add asan instrumentation to detect stack frame leakages (i.e. `mj_markStack` without a corresponding `mj_freeStack` in the same caller function).

PiperOrigin-RevId: 562625645
Change-Id: I4e3ff66ca0b9d08ed0a95cef45393db8e3053e22
2023-09-04 17:04:11 -07:00
Saran Tunyasuvunakool daa2ac7f8b Rename nstack to narena, change it and pstack to count bytes.
PiperOrigin-RevId: 561066311
Change-Id: I4d0e645e6c254dd906bfc42159e0e99149a7c6c8
2023-08-29 10:13:33 -07:00
Yuval Tassa 55173e58f9 Save <compiler {boundmass/boundinertia}> if nonzero.
Fixes #928

PiperOrigin-RevId: 560967976
Change-Id: Idc8c043278362d8925ce41061c65f3e678ad50ce
2023-08-29 02:41:22 -07:00
Yuval Tassa cf310079e2 Don't allow quat="0 0 0 0" in XML.
PiperOrigin-RevId: 557535436
Change-Id: Ie71246da5fff67a7cc37cb1801dd88d4a79b5766
2023-08-16 10:47:23 -07:00
Kyle Bayes 5f246ef210 Add ReadAttrVec, ReadAttrArr, ReadAttrStr, and ReadAttrNum to XML utils.
Moving forward, the compiler objects should have encapsulated data, therefore the old ReadAttr* methods are being deprecated as they require raw pointers to read into.

No external changes other than minor improvements to ReadAttr and ReadVector.

PiperOrigin-RevId: 550880401
Change-Id: I632f40322ccd935f9af9b69e66b056c5cda6face
2023-07-25 07:31:23 -07:00
Kyle Bayes 24c1ec9aec Add support for printing to stdout in mj_saveLastXML.
PiperOrigin-RevId: 546849864
Change-Id: I799ea3fcd723cf036f82ef5c1ef8152c314072dc
2023-07-10 06:08:10 -07:00
Alessio Quaglino 46e06c4cac Add elasticity plugins to xml_native_writer_test. Fixes #961.
PiperOrigin-RevId: 545454207
Change-Id: I4e93499eaa53e5bc8c8afa682986657cef3ac20f
2023-07-04 08:30:30 -07:00
Yuval Tassa d40c395917 Add Visualization tab to simulate.
Also:
- Increased label width in mjUI tight theme spacing.
- Added `mjITEM_EDITFLOAT` for editing float values.
- Move mjUI numpad key codes to header file.
PiperOrigin-RevId: 535839953
Change-Id: Ibdc0a9a20be514caa5b487211212ed6f5b8a6ba9
2023-05-27 05:08:15 -07:00
Saran Tunyasuvunakool f887c1e928 Add ASAN and MSAN instrumentation for arena and mjData stack.
PiperOrigin-RevId: 535635490
Change-Id: Ia1e58771bae25bf72c861f57452fb8faa2b918fb
2023-05-26 09:17:26 -07:00
Saran Tunyasuvunakool fbbdf70401 Make XMLWriterLocaleTest hold a copy of the old locale string.
The rationale is the same as in 0d0a41d549. XMLWriterLocaleTest still sporadically fails with a stack buffer overflow error when built with MSVC 2019 prior to this change.

PiperOrigin-RevId: 534035241
Change-Id: I1c50457e386724021b8d97ab1fb9cc2ece795292
2023-05-22 05:34:24 -07:00
Yuval Tassa 770b4b363a Added optional smoothing to muscle dynamics:
- `muscle` actuators take a new `tausmooth` attribute (defaults to 0) which when positive, smooths the transition between activation and deactivation timescales.
- `mju_muscleDynamics` takes 3 parameters, adding width of smoothing sigmoid.

PiperOrigin-RevId: 531473354
Change-Id: I8ab6c0289ff04437e798c3ca6edda132a30fcc31
2023-05-12 04:58:53 -07:00
Yuval Tassa c65e046043 Don't save actdim="{0,1}" for state{less,ful} actuators, respectively.
actdim has a default value of -1 (==unset), which means it currently gets saved for all actuators. After this change, it will only be saved if the value is > 1, errors are thrown for stateful actuators with actdim=0 and stateless actuators with actdim>0.

PiperOrigin-RevId: 520627313
Change-Id: Ia498dae5c7314cfaa0995f8077d297c2339a5c35
2023-03-30 07:00:17 -07:00
Yuval Tassa 0becf8fd98 Remove unused headers in test files.
PiperOrigin-RevId: 520610859
Change-Id: I5ac906b422a7c02737af85f6a2aea46206f0cb28
2023-03-30 05:26:33 -07:00
Yuval Tassa 1d6a9e09bb Don't save body pos if "0 0 0".
PiperOrigin-RevId: 520598416
Change-Id: I5bb6ffaec386f228ac7a5fa221822000635900ae
2023-03-30 04:09:22 -07:00
Yuval Tassa 3f9defa8d0 Don't save an empty <default/> section.
PiperOrigin-RevId: 520594748
Change-Id: Ib5e1eb3a93e9d579adeda1052a2c29d724d6b497
2023-03-30 03:51:14 -07:00
Yuval Tassa ddfcd3b325 Don't save body gravcomp if 0.
PiperOrigin-RevId: 520592156
Change-Id: Ifb85c1e78498877bc576cfca224c41b3cf47c9ab
2023-03-30 03:34:04 -07:00
Saran Tunyasuvunakool 5e989d18c3 Enable compiler errors for implicit switch case fallthroughs.
Also unify warning options across Clang and GCC and fix minor issues that was surfaced by this.

PiperOrigin-RevId: 508619655
Change-Id: I59b777bf2dfea4422485670e2427c7d3f5cf6405
2023-02-10 03:49:00 -08:00
DeepMind 929e09f84a Improve URDF geom name loading API.
PiperOrigin-RevId: 505112774
Change-Id: I866e58e664089256a41908dddab9ad79745fb1da
2023-01-27 07:29:45 -08:00
DeepMind 703b33c064 Add geom names to URDF parsing in MuJoCo.
Fixes #566

PiperOrigin-RevId: 500750288
Change-Id: I00f94ee37bb2f15be59df3933d0d4dba583f0921
2023-01-09 10:34:22 -08:00
Yuval Tassa dee1d6020a Make "acc" the default computation stage for sensors of type user.
PiperOrigin-RevId: 492689134
Change-Id: I21c07c74cb4b94d39c091ae98b169fd1235769d4
2022-12-03 07:50:15 -08:00
Alessio Quaglino 638c9a6994 Support capsules in URDF import.
PiperOrigin-RevId: 489980760
Change-Id: I1c21e736a86f6637a00e2062727d2e6fd5694c42
2022-11-21 07:58:42 -08:00
Yuval Tassa 221c63d744 Sensors of type user no longer require objtype and objname. If unspecified, the objtype will be mjOBJ_UNKNOWN. Also, `user sensors datatype default is now "real"`.
PiperOrigin-RevId: 489652972
Change-Id: I0a8f21ee1a2f5292e6bbcfe3785536cfd1498b85
2022-11-19 02:05:42 -08:00
Alessio Quaglino fc24097b92 Compute nonzero default mass value only if geom is not in the default section.
Fixes #561.

PiperOrigin-RevId: 486604407
Change-Id: Ie62578808f96f0de3a2353c6bc4cc8bd3ae3afbc
2022-11-07 02:18:31 -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
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
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 6e004d7413 Fix bugs in adhesion default parsing.
- `gain` was not inherited, either from `<adhesion gain>` default or from `<general gainprm>` default.
- `dyntype` was not inherited from `<general dyntype>` default.
- Reported by @vaxenburg.

PiperOrigin-RevId: 480707156
Change-Id: I0160531d48186e7658952e72923ceb6cb034be9b
2022-10-12 13:44:56 -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 5af11ca083 Add XML parsing test case for large memory specification without suffix.
Startblock:
   diffbase is submitted
PiperOrigin-RevId: 479914967
Change-Id: I574612bf875c929803cf5abc3b1885e9855dee29
2022-10-09 06:39:50 -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
Kevin Zakka 48f2ed99a5 Enforce strict positivity of extent and znear attributes at parse time.
PiperOrigin-RevId: 477597498
Change-Id: Ic927655cd5ba2fd8fdb1a1a5f7e54ff5040c3370
2022-09-28 17:53:05 -07:00
Yuval Tassa 5dc26cf4a0 Fix bugs in actuator parsing.
- Adhesion actuator defaults were not parsed, now fixed.
- Both damper and adhesion actuators were requiring `ctrlrange` at parse time, which prevented this attribute from being inherited from defaults, now fixed.
- Added tests for all 3 cases.

PiperOrigin-RevId: 475145255
Change-Id: I8dd6196e20734136d990f522893ebd4d156cd7a8
2022-09-18 11:10:02 -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 090fe2db3f Add a disable flag for sensors.
PiperOrigin-RevId: 469473066
Change-Id: I296ed790c6261c4fb15b349540edcb77e53e0567
2022-08-23 09:02:56 -07:00
Kevin Zakka 0b2f19bbe7 Fix "actrange" parsing for "intvelocity" actuators.
PiperOrigin-RevId: 468759706
Change-Id: I1d9eeb723d28cccb64a6112b103345fcf451700f
2022-08-19 12:22:55 -07:00
Kevin Zakka 4bfc2c0311 Automatically infer *limited field from *range field for joints, tendons and actuators.
PiperOrigin-RevId: 467980594
Change-Id: If635c55a90cf949796b99a41395a6c2c4f7ea094
2022-08-16 11:35:34 -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
Alessio Quaglino 5c5449bf82 Compute moment of inertia for concave and boundary meshes. Resolve #338.
- Mesh inertias can now be computed exactly for well-formed (no holes) non-convex meshes.
- To activate this feature, set `<compiler exactmeshinertia="true">` (defaults to `false`). This default may change in the future.
- Added `<geom shellinertia="true/false">` (defaults to `false`). When true, geom inertia is computed assuming all the mass is concentrated on the surface, and `density` is interpreted as surface density (mass/area). Currently only mesh geoms are supported.

PiperOrigin-RevId: 464368395
Change-Id: I17afd99b9b221c9d24ae951f6e63d5c61ff89820
2022-07-31 04:32:28 -07:00
Alessio Quaglino 8dd9971409 Raise error if mesh has flipped faces.
PiperOrigin-RevId: 461860424
Change-Id: Ib23c50cf7f64de1173404d2f65ad87177fab45b3
2022-07-19 05:47:46 -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
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