Commit Graph

78 Commits

Author SHA1 Message Date
Yuval Tassa 4c066a26b5 Change mjVISSTRING of connect and weld equality constraints from "Constraint" to "Equality". This is more consistent with the 'E' shortcut key and with mjDISABLESTRING ("constraint" means all constraints, "equality" means bilateral constraints).
Also remove unused ampersands from `mjVISSTRING` names, these are a remnant from a very old version of the UI framework.

PiperOrigin-RevId: 593469811
Change-Id: I0f6f73c9f5d2c61b2280f395f76434b0710ce4f3
2023-12-24 12:06:59 -08:00
Nimrod Gileadi 7cb7c87f70 Fix a few issues with the passive viewer.
1. Create an arena for the mjData instance used by the passive viewer visualization.

When using the passive viewer, stuff gets copied from the real mjData into a minimal struct.
That struct didn't have a stack, and now visualization for Flex does stack allocs.

2. Add missing a missing field in scene state for flex visualization.

3. Fix a memory leak where mjvScene wasn't released on exit in the passive viewer.

4. Add some locks in places where the render thread and Simulate::Sync collide.

This fixes #1280.

PiperOrigin-RevId: 591891676
Change-Id: I592f286cab9719c8d9af84e42f9756ea1f9f1971
2023-12-18 07:33:19 -08:00
Yuval Tassa dc0d0c59d4 Fix bug in simulate where the "LOADING..." label was not properly showing.
PiperOrigin-RevId: 591257979
Change-Id: Id09754b1e5a87decfb68b9fe305388aa8f0f5ed3
2023-12-15 08:12:28 -08:00
Yuval Tassa 35f095d7c5 When paused in simulate, add index of history scrubber if not 0.
PiperOrigin-RevId: 590184966
Change-Id: Id0914c41a1339cf71ebdea02ec486c52c3d37179
2023-12-12 06:43:37 -08:00
Alessio Quaglino 7cb84d45c1 Prevent integer overflow in history buffer for large models.
PiperOrigin-RevId: 585949038
Change-Id: Iabec5feedd1632b635583a608a5488b39e6bb9a2
2023-11-28 06:04:00 -08:00
Yuval Tassa 25ddb3e6e8 simulate: Add states to history when stepping with right arrow key.
PiperOrigin-RevId: 585613870
Change-Id: I7fb051946e8a91a900442e3d7048dfa8b8bd7c5c
2023-11-27 04:45:51 -08:00
Yuval Tassa 8693e0bba5 Stop actuator group disable from mistakenly binding to the number keys (should toggle geom groups, not actuators).
PiperOrigin-RevId: 583038620
Change-Id: Ibf339aed339b7ad862f61ac72298f43e717e3973
2023-11-16 07:34:58 -08:00
Yuval Tassa 7051ab99e0 Enable keyframe loading and saving in passive viewer. Fixes #1175
PiperOrigin-RevId: 582332757
Change-Id: Iff23359e670906c0e88a2d34273c493bc8cbe2af
2023-11-14 08:38:04 -08:00
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
Yuval Tassa 8eb36d9a7c Improvements to simulate UI
- Improved Help overlay text, mention shortcuts for UI toggle.
- Removed buttons for UI toggle.
- Moved Spacing / Color / Font to the end of the Option section.

PiperOrigin-RevId: 576480554
Change-Id: Ie1427b97cb784421490c276a8544d570a6042188
2023-10-25 04:03:38 -07:00
Nimrod Gileadi 9393c690d4 Correctly handle full screen and vsync buttons.
Fixes #1110.

The code was using outdated indices since 48eb75ae92. It now uses the more stable pdata pointer.

PiperOrigin-RevId: 574805349
Change-Id: If6112fb2af7d60f17b35599233b24f33b6a8cac6
2023-10-19 03:38:11 -07:00
Alessio Quaglino 5a70ad08ab Add Flex component.
PiperOrigin-RevId: 572830650
Change-Id: I6908228087b7b9683be3506c8d9cdc725ed5dcd5
2023-10-12 10:49:35 +01:00
Saran Tunyasuvunakool ba03ebdadd Fix a segfault in the passive viewer on macOS.
The segfault is caused by a call to mjui_update outside of the macOS main thread, introduced in 3e12f0d50c.

PiperOrigin-RevId: 572531447
Change-Id: Ib8424c746d18a776c0b91087d9501aa8ee463026
2023-10-11 04:06:23 -07:00
Saran Tunyasuvunakool 2e15574b58 Allow user-defined visualization geoms to be added to the passive viewer.
Fixes #1023, #1082

PiperOrigin-RevId: 572303635
Change-Id: Ia8399f816f311b38a7b137f5bd4f359f77a1da1c
2023-10-10 10:52:21 -07:00
Saran Tunyasuvunakool a1b39d5959 Fix a segfault in simulate on mouse scroll without a loaded model.
Fixes #1089

PiperOrigin-RevId: 571985561
Change-Id: I4acc7c2a6032d678023783646c3f00cfe30641f2
2023-10-09 11:01:08 -07:00
Yuval Tassa e9613f0cc9 Rename simulate.fully_managed_ to simulate.is_passive_ with flipped semantics.
PiperOrigin-RevId: 570815258
Change-Id: Iaffdb0e52bcdb31cff7bd29cb820913e3838f0ee
2023-10-04 14:49:52 -07:00
Yuval Tassa 3e12f0d50c Add history scrubbing mechanism to simulate.
[screen capture](https://www.youtube.com/watch?v=YSvWn_poqWs)

PiperOrigin-RevId: 570676968
Change-Id: Id9a1fccc9418b851e007ddcf3fa89acd4edff3e9
2023-10-04 06:36:34 -07:00
Yuval Tassa 177aec68dc Add overlay positions in the center of viewport edges, move PAUSE and LOADING... overlays to the top center.
PiperOrigin-RevId: 570054949
Change-Id: If0046df382e67ad3a48e7138a75e9e200c0626b9
2023-10-02 07:05:50 -07:00
Levi Burner e7d1f2f110 simulate: fix display of loading message 2023-09-27 16:04:36 -04:00
Yuval Tassa 9cf1f6eba4 Remove mjOption.collision and associated option/collision attribute.
PiperOrigin-RevId: 566427090
Change-Id: I6e5873b8db707586820b17b53c7ab4bbff0f0b2b
2023-09-18 15:15:54 -07:00
Yuval Tassa 86d8b912f4 Rejigged solver statistics in preparation for islanding.
- See public description below.
- Stopped incrementing the iteration count in saveStats().
- `sizeof(mjSolverStat) == 40`, so this ends up costing 160KB, up from 40KB.

BEGIN_PUBLIC

Changed the size of `mjData.solver`, the structure used to collect solver diagnostic information. The array is now of length `mjNISLAND * mjNSOLVER`, where each row of length `mjNSOLVER` contains separate solver statistics for each constraint island. Until solver islanding is implemented, only row 0 is used.

- The new constant `mjNISLAND` is set to 20.
- `mjNSOLVER` is reduced from 1000 to 200.
- Added `mjData.solver_nisland`, the number of islands for which the solver ran.
- `mjData.solver_niter` (renamed from mjData.solver_iter) and `mjData.solver_nnz` are now integer vectors of length `mjNISLAND`.

END_PUBLIC

PiperOrigin-RevId: 565030093
Change-Id: I773e918805c6ced79f0dab5f19ea23956760c8c5
2023-09-13 06:18:37 -07:00
Yuval Tassa 48eb75ae92 In simulate, by default, keep updating profiler and sensor figures in Pause mode. Add UI option to disable.
PiperOrigin-RevId: 564710460
Change-Id: I893535e258ec2485d2ec997ecadfbdafba05bb99
2023-09-12 07:06:09 -07:00
Google DeepMind 040d3efce2 Add options for controlling early termination criteria of CG/Newton linesearch.
Useful for performance tuning models.

PiperOrigin-RevId: 563175078
Change-Id: Id64a510d6080038ea8d5876dabbf0b2b311435bb
2023-09-06 12:02:58 -07:00
Nimrod Gileadi 5279ce6f6f Fix comment typo in simulate.cc
PiperOrigin-RevId: 561921946
Change-Id: I423378df566be7a6ad88fb3526769d298ac32a3b
2023-09-01 04:56:34 -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
Alessio Quaglino fdb041580c Add Signed Distance Field to collision geometries.
PiperOrigin-RevId: 557507088
Change-Id: I358a642407aee1ba8dfc9d405eb9a4f609435fe9
2023-08-16 09:15:23 -07:00
Yuval Tassa ac3ac0d28f Fix timing plots issue in simulate.
Before this change timing plots would report zeros if the render thread was faster than the physics thread, making them unreadable when slowdown was used.

PiperOrigin-RevId: 557432042
Change-Id: Ie9a18fb84cab788d11dfbede4e3052f24441b4c4
2023-08-16 04:03:50 -07:00
Yuval Tassa 3e034e38b2 Add constraint island discovery
PiperOrigin-RevId: 557067599
Change-Id: Ic41e1d0efef02b7a79142518afe49cf9d4e74725
2023-08-15 02:30:05 -07:00
Yuval Tassa 6d7b49ccf5 Remove collision pruning statistics from simulate info panel.
PiperOrigin-RevId: 554452244
Change-Id: I4f9f1d5e38d4b4bc37b5a2f0980b352db04a73c6
2023-08-07 06:05:13 -07:00
Saran Tunyasuvunakool 0ccfef7314 Add update_{hfield,mesh,texture} methods to the passive viewer.
Fixes #812.
Fixes #958.
Fixes #965.

PiperOrigin-RevId: 548181282
Change-Id: I6eb0cd2ce52c66083e83dd08d69e0cfb4178dbba
2023-07-14 11:43:36 -07:00
Yuval Tassa 906a8e8b27 Correct shortening of camera name in simulate.cc (for UI menu item)
Fixes #963

PiperOrigin-RevId: 545187656
Change-Id: Ib213d693569d884915fba99f150df4fd5f53984c
2023-07-03 04:32:27 -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
Yuval Tassa bb8044e5f3 Set minimum tree slider depth to 0.
PiperOrigin-RevId: 534003561
Change-Id: I42ccd0eab15b5a3c9852f8944c6b191f7999c113
2023-05-22 02:39:58 -07:00
Yuval Tassa 20e06ba353 Add missing braces.
PiperOrigin-RevId: 533419351
Change-Id: Iad54f6cb6d63c05e6a2f81526b22a914e2a23ba2
2023-05-19 04:35:12 -07:00
Saran Tunyasuvunakool c2115a1f51 Fix a mjvSceneState leak in the passive viewer.
PiperOrigin-RevId: 526957248
Change-Id: I4f30faf097da64189607a4b98c6dff04fec773fa
2023-04-25 07:11:42 -07:00
Yuval Tassa a2a1ac9fc2 Pass mjvOption to plugin visualize callback.
PiperOrigin-RevId: 526047180
Change-Id: Ia63f02184f5c6a7e3b588298639fa0ab4a6da649
2023-04-21 08:44:20 -07:00
Saran Tunyasuvunakool 94779a722a Rename Differ to IsDifferent and tidy up its implementation.
Startblock:
   diffbase is submitted
PiperOrigin-RevId: 526024927
Change-Id: I718f3b98539f5c33a42f6254bc817a07459f694c
2023-04-21 07:14:26 -07:00
Saran Tunyasuvunakool da17fdfcfd Fix a macOS segfault in simulate.cc.
The segfault was caused by updating the UI outside the main thread.

PiperOrigin-RevId: 526019783
Change-Id: I3a211ce8a65f10716778bb3310bb568e00309a32
2023-04-21 06:46:09 -07:00
Saran Tunyasuvunakool b362cb4972 Expose a handle for the Python viewer.
This change also requires user scripts to explicitly synchronize changes to physics state to the viewer. The Simulate class was reconfigured so that certain UI events are handled during this sync operation, outside of the render loop on the main thread. These correspond to operations that require access to the full mjModel/mjData.

To support other, more interactive operations (e.g. camera movements), a new mjvSceneState struct is introduced which captures only the portion of the physics state required for scene re-rendering. The mjvSceneState is updated from mjModel/mjData during the viewer sync operation, and is significantly cheaper than a full mj_copyModel and mj_copyData.

Fixes https://github.com/deepmind/mujoco/issues/796

PiperOrigin-RevId: 525723636
Change-Id: Id08d0210a2c067d5afe85e2bf104f276aeddd75e
2023-04-20 05:59:19 -07:00
Saran Tunyasuvunakool 5646c905cd Rename a few functions and variables to be a bit more Googley.
PiperOrigin-RevId: 523963645
Change-Id: Ife7ed3f44aa83c64dfbdc3ca78ee6de2092b0d63
2023-04-13 04:24:31 -07:00
Alessio Quaglino 5f132af625 Add midphase and broadphase statistics to mjData.
PiperOrigin-RevId: 521387641
Change-Id: Id50f2549d119e364216491a23b107e04d9ebb5b6
2023-04-03 00:59:59 -07:00
Nimrod Gileadi 0e7e299bf6 Declare loop variables inside for loop in C++ files.
PiperOrigin-RevId: 518852339
Change-Id: I0174d873d89e48f11b816d337728f213c2798248
2023-03-23 07:22:36 -07:00
Nimrod Gileadi c6ab23d6b4 Add a missing mjITEM_END when creating the UI for the collision tree.
This fixes #774.

PiperOrigin-RevId: 517469175
Change-Id: I24a127c59f4a8dd7a5b306558425b90a80ec44f3
2023-03-17 11:51:06 -07:00
Alessio Quaglino 70959c1a2c Added a collision midphase on geom pairs using rotated AABBs static trees.
PiperOrigin-RevId: 517357695
Change-Id: I068fee714d9638be2fb6d042d5d86f8ff970635b
2023-03-17 02:37:29 -07:00
Yuval Tassa 8c7f6ce5a0 New implicitfast integrator and sparse RNE derivatives for implicit.
PiperOrigin-RevId: 516910733
Change-Id: I29a0465c0f0b1749a73e3d7e01925200d025ddd0
2023-03-15 13:17:41 -07:00
Saran Tunyasuvunakool 2f0fb1e4ef Workaround for broken VSync in Simulate on macOS.
OpenGL VSync became broken again in macOS 13 (https://github.com/glfw/glfw/issues/2249). This workaround is similar to https://github.com/glfw/glfw/pull/2277 but is implemented entirely outside of GLFW.

PiperOrigin-RevId: 516320722
Change-Id: Ib8a651a942f592c74e00ad3c7b22f2dfd156be5f
2023-03-13 14:19:17 -07:00
Alessio Quaglino 3abf2ae2cd Increase maximum number of geoms in simulate from 5000 to 20,000.
PiperOrigin-RevId: 516246198
Change-Id: I8a07a075b370ad0c212db8ed68b3d61389eba197
2023-03-13 10:16:12 -07:00
Yuval Tassa 2607e67f8d Add contact labels showing which geom pairs are in contact.
PiperOrigin-RevId: 510422404
Change-Id: Ia73570098752e7c7175e4b5a5f2a0f8b08a6c006
2023-02-17 07:03:19 -08:00
Yuval Tassa bc0184d67e Increase precision of simulate sensor plot y-axis by 1 digit.
- Before this change, the y-axis scale had only one digit, leading to user confusion. Small changes in senor values could appear as if the values remained at the nearest integer value, while in fact the y-axis itself was changing, but this was not evident in the GUI due to the reduced precision.
- Fixes #719.

PiperOrigin-RevId: 506841881
Change-Id: I583036bba389cef8d9ecf1c1bbcfb573ef2285e6
2023-02-03 01:48:18 -08:00
Saran Tunyasuvunakool 4b4ee27f64 Turn off reflection and shadow in simulate when a GPU is not present.
Note that The GLFW adapter currently assumes that a GPU is always present, so this new code path is never reached at the moment.

PiperOrigin-RevId: 504617048
Change-Id: I04a323c33d9cff73686d39e4a6676ca6a4484c98
2023-01-25 11:33:20 -08:00