Commit Graph

162 Commits

Author SHA1 Message Date
Alessio Quaglino 231d9632cd Avoid duplicated code in mjCModel by adding ResetTreeLists().
PiperOrigin-RevId: 653575505
Change-Id: I61ee1462deae2a371cf6f36ca1cf3dbbd88d174c
2024-07-18 05:08:18 -07:00
Yuval Tassa dd25973481 Remove unnecessary def_map copying.
Introduced in 5b080bacc4
Made obsolete by 27b9ddda5b
[Context](https://github.com/google-deepmind/mujoco/commit/27b9ddda5bdd12345abdfbc0a6efce121d40cd6c#r144157607)

PiperOrigin-RevId: 653254345
Change-Id: Ie944d2c3924d3eb91f7743c0d0c8413cd2cd79cc
2024-07-17 09:10:31 -07:00
Alessio Quaglino 2664cc1391 Allow passing a null pointer in mj_recompile.
Fixes #1819.

PiperOrigin-RevId: 653242587
Change-Id: I36dbd6ed54abdf21abeb62cf41ee88f159008d01
2024-07-17 08:29:01 -07:00
Alessio Quaglino 9a7c1df130 Set unused inherited opaque pointers to nullptr.
PiperOrigin-RevId: 652444674
Change-Id: I3e82b1e1ae029f2f01ddcdf5ce2ccb45624e7062
2024-07-15 05:15:45 -07:00
Alessio Quaglino cf61d88e41 Move pointer assignments from CopyFromSpec() to PointToLocal().
Note that these internal pointers are inherited from the public structs and are unused internally.

PiperOrigin-RevId: 652414750
Change-Id: I5e42503bce8e9019291ec0a1f8c4278438474e9b
2024-07-15 02:47:32 -07:00
Alessio Quaglino 6e64dd10e8 Fix bug in RemoveFromList.
The function was interpreting that the elements that were expected to be detached contained useful user errors, and therefore it was not detaching them. Also, the function tried to compare the namespace between two models, but the namespace is already fused in the references at detach time.

PiperOrigin-RevId: 651738364
Change-Id: Ifdaa9bd5b658bfd18b544b7138a5c2c56b66e936
2024-07-12 05:08:00 -07:00
Yuval Tassa f1aa52aa9b Never use more threads than meshes for multi-threaded compile.
PiperOrigin-RevId: 651728817
Change-Id: Ib607d528c25a10e2cdb8c2b0b0da2189683d2691
2024-07-12 04:18:35 -07:00
Yuval Tassa 3d1d1d0718 Multithreaded mesh compilation.
PiperOrigin-RevId: 651358120
Change-Id: Id6272aac84ec6ac1b709d2f4a44b7593307bd158
2024-07-11 04:21:49 -07:00
Alessio Quaglino 27b9ddda5b Add attach tag to MJCF.
PiperOrigin-RevId: 651117953
Change-Id: I57b0e53ed44607d479b3785d908e0837c0804cf3
2024-07-10 12:41:43 -07:00
Copybara-Service 5b080bacc4 Merge pull request #1799 from JewelryForge:main
PiperOrigin-RevId: 651069985
Change-Id: I758e27e2f4bf19bba38d9e1189a41accae40d028
2024-07-10 10:29:22 -07:00
Yuval Tassa b483ce608e Use std::thread in compiler on all platforms.
PiperOrigin-RevId: 651005412
Change-Id: I8dfb142dc2d87ab0af79583f2df168c105b50138
2024-07-10 07:10:45 -07:00
Chengrui Zhu 5bd13b4982 Copy all keys of def_map when copying a mjCModel. Fixes #1798 2024-07-10 16:40:36 +08:00
Alessio Quaglino 462cfa5ceb Attach the tree of defaults recursively and with namespacing.
PiperOrigin-RevId: 650664018
Change-Id: I17751a02a406dcb2a2ca218c316b5eb0370071b8
2024-07-09 09:54:09 -07:00
Nimrod Gileadi 393895bb29 Explicitly specify actdim on PID plugin actuators, to allow them to be used with keyframes.
Support actdim attribute on plugin actuators.

Remove the actuator_actdim callback. This callback leads to crashes when loading keyframes for models that have a stateful plugin.

PiperOrigin-RevId: 650649505
Change-Id: I40d1994d02ae4e20ce631b2702a984766cf2628e
2024-07-09 09:08:48 -07:00
Alessio Quaglino e0d33eb1d0 Remove mjCBase::def and use mjCBase::classname instead.
PiperOrigin-RevId: 650629741
Change-Id: I10a9955b99e4a5ff0b5a742e22635ccad1455f1a
2024-07-09 08:02:32 -07:00
Nimrod Gileadi c5f958bdff When reporting compilation errors, include warning strings.
This allows plugins to call mju_warning, and have the string propagate to users.

PiperOrigin-RevId: 650621601
Change-Id: I608e7a3a1ad126ab8da2ff0634fa708458fb9ccc
2024-07-09 07:33:11 -07:00
Alessio Quaglino f57dc90669 Refactor Default class to use pointers instead of indices.
This in order to make it easier to append the default tree to another tree.

PiperOrigin-RevId: 649812975
Change-Id: I2915ac7e37957e45eadc24d6caaf7beea236bf29
2024-07-06 03:51:30 -07:00
Alessio Quaglino a5a3c9efc7 Discard all keyframes when attaching models.
PiperOrigin-RevId: 649415647
Change-Id: Ie2defe248df7078684d987351985cb66bd754e5b
2024-07-04 08:04:40 -07:00
Alessio Quaglino a0945e4b5a Add non-tree element lists to python bindings.
Fixes #1752.

PiperOrigin-RevId: 649405039
Change-Id: Ie0b575a3ec912b773141694397ac2f394bff1227
2024-07-04 07:24:02 -07:00
Tom Erez df7ea3ed33 Add support for multiple textures in one material (mjModel).
PiperOrigin-RevId: 648732764
Change-Id: I29b60dd62a069789a32017ff0d55e36b57e0052b
2024-07-02 08:50:23 -07:00
Yuval Tassa af3233f98d Delete unused code.
PiperOrigin-RevId: 648658198
Change-Id: I1bec6b07becd7cec22af4c67e9cc1a9bcda669b0
2024-07-02 03:32:55 -07:00
Saran Tunyasuvunakool 0e19722c61 Split name2id and id2name into a separate source file.
PiperOrigin-RevId: 647373431
Change-Id: I3bab0ea7157750b79826739e3d739e4114fa0af7
2024-06-27 10:50:21 -07:00
Alessio Quaglino 6be4e0697e Simplify mjs_addDefault.
PiperOrigin-RevId: 646534046
Change-Id: I658224e4800849231e68ed02d8fad07b8d796231
2024-06-25 10:51:57 -07:00
Yuval Tassa d8b85245a7 Informative error if mis-naming the top-level default class.
Also:
- Move the the top-level default class name into the mjCModel constructor.
- Fix bug in default class propagation in frame elements.
PiperOrigin-RevId: 646384669
Change-Id: Icc6154124361a234b84a07e2b5ecaa7c8b18ebf7
2024-06-25 01:46:18 -07:00
Alessio Quaglino 7bd7065e0e Renamed mjs_fullInertia to mjuu_fullInertia and moved it to user_util.
PiperOrigin-RevId: 644769379
Change-Id: I83511eeb4c0972ce9f46f0e3443d438cccdd4d9f
2024-06-19 09:39:02 -07:00
Yuval Tassa 8e2f830fd2 Fix type errors in compiler and tests.
In preparation for a float32 build of MuJoCo.

PiperOrigin-RevId: 644407674
Change-Id: I60069f0f865ef89fbf613f5a2ca0c336cc63461e
2024-06-18 09:12:44 -07:00
Yuval Tassa 07fc95ca9a Add orthographic cameras.
Orthographic cameras are specified by setting the `orthographic` attribute of the `<camera>` element. The `fovy` attribute is still used to specify the field-of-view, but its semantic is different for orthographic cameras. For orthographic cameras, the field-of-view is expressed in units of length, rather than degrees.

Other related changes:

* Fix bug in the ordering of `cam_xxx` elements in `mjModel`.
* Make camera visualization translucent only when the frustum is visualized.
* Added a button to `simulate` to toggle between perspective and orthographic free cameras.

https://youtu.be/ZXBTEIDWHhs

PiperOrigin-RevId: 642293435
Change-Id: Id090a421ad88ab404b5b27ddbbd6bfc81ad49bc5
2024-06-11 09:23:18 -07:00
Alessio Quaglino 7a06bcfdaf Make model editing API public, fixes #364
Still missing:

- Detailed documentation.
- Python bindings.

PiperOrigin-RevId: 641445626
Change-Id: I20e67b707cf1bebae7e0cc94d17f7b76a89171f0
2024-06-07 22:28:01 -07:00
Alessio Quaglino f6084b4328 Change user_api handle types.
PiperOrigin-RevId: 640978033
Change-Id: I53496671ac823b50e6f90ceee15bf3b314b06db8
2024-06-06 12:06:10 -07:00
Alessio Quaglino ba8a2d4c8a Dynamic model editing.
PiperOrigin-RevId: 640838852
Change-Id: I559b1d60f2a3a2d866788d4006be31757454c619
2024-06-06 03:30:59 -07:00
Alessio Quaglino 936866be0f Add mjModel and mjData arguments to mj_makeModel and mj_makeRawData. If they are NULL, then the functions allocate the memory, otherwise they will use the memory allocated by the caller.
PiperOrigin-RevId: 639283021
Change-Id: I765f95fe1b5c27202ae033b05a13ae7b5fb8dbc3
2024-06-01 01:08:56 -07:00
Alessio Quaglino dec55b59fa Allow detaching from a compiled model.
PiperOrigin-RevId: 638299270
Change-Id: I944d2a24578b63463eddfa55d89f39fcfbafd2b4
2024-05-29 08:47:30 -07:00
Kyle Bayes 13bf9ae6bd Encapsulate mjCModel internal lists.
PiperOrigin-RevId: 631760335
Change-Id: I9b67f6ed2e65a01877de15a92a04a1b31a6b3ff4
2024-05-08 05:02:21 -07:00
Alessio Quaglino 96844db926 Update BVH during fusestatic. Fixes #1069 and #1577.
PiperOrigin-RevId: 631748750
Change-Id: I4e1ae01207568c90fc49bcd7d9f760f5187f1afa
2024-05-08 04:13:16 -07:00
Alessio Quaglino 7eb8c4b9f4 Set all flex edges to rigid when the flex is rigid.
PiperOrigin-RevId: 629740153
Change-Id: Ib2fb6f64e3d160268d2521d63830f41e44d03b20
2024-05-01 09:06:01 -07:00
Yuval Tassa 1b70907060 Convert user_api header and user_init source files to valid C code.
PiperOrigin-RevId: 629691192
Change-Id: I9be78aca27ae584fff0b733e9015b2bb3b927ca4
2024-05-01 04:53:01 -07:00
Alessio Quaglino ec84ddb5a4 Use plane-convex for plane-sdf collisions, using the marching cube mesh.
PiperOrigin-RevId: 629437563
Change-Id: Ic7fb6ec8a5c6680dd2c0a71baa7cc78636d478b1
2024-04-30 09:30:39 -07:00
Alessio Quaglino 26f23066d1 Add replicate element to MJCF. Fixes #553
PiperOrigin-RevId: 629393578
Change-Id: Ia1db1b9e47eba8868117b0f7b85edcd0cc1b6d79
2024-04-30 06:29:18 -07:00
Alessio Quaglino d6553ed192 Update contype and conaffinity if fusestatic is true. Fixes #1577.
PiperOrigin-RevId: 628073529
Change-Id: I2fe88736d12ec16d72bbd4dce5d349b930147b50
2024-04-25 07:46:00 -07:00
Yuval Tassa f457789de1 Improve full inertia user API.
PiperOrigin-RevId: 627399310
Change-Id: Ie2bdc6778e80b2b8127b52c73a3cc4b4755d8e0a
2024-04-23 08:40:01 -07:00
Yuval Tassa 8ebc9ed2c8 Add mjModel.ngravcomp, number of bodies with nonzero gravcomp attribute.
PiperOrigin-RevId: 627087335
Change-Id: Ie85ae4150962463b8a8c8435fec068c44877aa16
2024-04-22 10:45:43 -07:00
Yuval Tassa caf215e342 Add metallic and roughness scalar attributes to materials.
Rename `light_radius` -> `light_bulbradius`, make the default value 0.02.

PiperOrigin-RevId: 627032170
Change-Id: I1e01e2eca028c0aefc2e7dc384e8b34abac184aa
2024-04-22 07:39:06 -07:00
Alessio Quaglino cc78db41f4 Add mjs_detachBody to C API.
PiperOrigin-RevId: 626947850
Change-Id: I7c897048098ecd4f2247725ef2d378dbd00ef4a0
2024-04-22 01:11:13 -07:00
Alessio Quaglino 4a76496533 Compile frames during compilation instead of parsing.
PiperOrigin-RevId: 625717564
Change-Id: Ib82230f6cb423bb3091efd04a7fa0b1411e7cdf1
2024-04-17 09:56:24 -07:00
Yuval Tassa 0cd28d2423 Add light radius attribute.
Also fix bug: light defaults were not being saved.

PiperOrigin-RevId: 625142278
Change-Id: I8ec3a5a06e9f314e98b7c34346db3c24b34d7e0b
2024-04-15 17:55:15 -07:00
Yuval Tassa 7b3f1a0261 Add mjModel.mesh_scale: scaling applied to asset vertices.
PiperOrigin-RevId: 625083195
Change-Id: I36290282379e57ad23ec771d65d1bd6bf2a75b07
2024-04-15 14:26:06 -07:00
Alessio Quaglino 70f00b05a1 Allow attaching a model to itself.
PiperOrigin-RevId: 623806812
Change-Id: I9b0e36308be754e838790ead8ec717953e4b2350
2024-04-11 06:28:48 -07:00
Yuval Tassa 47ba72ea59 Add actuatorgravcomp joint attribute, to treat gravity compensation forces as applied by actuators, rather than passive buoyancy.
PiperOrigin-RevId: 620049593
Change-Id: I2c8a9dc152c087b408e4f904838034271a7dd910
2024-03-28 14:01:52 -07:00
Alessio Quaglino 96f923282c Add SetNuser function.
PiperOrigin-RevId: 619892712
Change-Id: Id528620d6af19976d965f34a3be95a48a1f9c0b2
2024-03-28 05:26:41 -07:00
Alessio Quaglino dfe2b75378 Convert mjElement to struct rather than opaque pointer.
By making mjElement the parent of mjCBase, mjCModel, and mjCDef, this CL enables safer casting using static_cast instead of reinterpret_cast and C-style casting.

PiperOrigin-RevId: 619526291
Change-Id: Ifa2b4bd3ecd95bade61f41a7005c62212f456c00
2024-03-27 07:37:49 -07:00