Commit Graph

36 Commits

Author SHA1 Message Date
Emo Todorov ee6a1dba28 UI improvements. Fixes #1274.
Copybara import of the project:

--
a1297d997d0b3cc624bbd1e704ffb7fbb2c5db9d by Emo Todorov <etodorov@gmail.com>:

UI imrovements

When OpenGL buffer size is too small to hold entire UI with all sections open, older sections (as determined by latest mouse click) are automatically closed as needed.

To test this new functionality, uncomment the test near the top of mjui_resize().

UI items now have userid, which can be used for event handling.  It is set through the (new) last field of mjuiDef, called otherint.

Sections titles can now have a checkmark - in which case they are rendered differently. Set via mjuiDef.otherint: 0- none (as before), 1- rendering changed but box not shown, 2- box shown.  This can be used to label sections of special interest to the application.

--
b0405bfb3005586ef1d2656ea9cc43c608225927 by Emo Todorov <etodorov@gmail.com>:

more ui improvements

Implemented mjPRESERVE state for adding sections and separators, so you don't have to keep track of old states.

simulate.cc is now modified to use this new functionality.  I also made the separators in the Physics section collapsible. If you don't like it, change them back to state 1.

Also added functionality for handling section checkboxes.

--
10f4c49be62a6605a38b7c0c7bfae1629024ba31 by Emo Todorov <etodorov@gmail.com>:

even more ui improvements

Selection boxes that extend below the current UI height are finally rendered in full.

Sections and collapsible separators now have rounded corners. The radius can be controlled from theme spacing.

More theme color settings were added. In particular, color gradients can now be disabled (the two end colors are set independently).

--
96c2dc601a25d31c93b21f8e089d349e729e829e by Emo Todorov <etodorov@gmail.com>:

final ui improvements

Cleaned up the code a bit.

Added more control for color gradients.

--
c9eddb679f36df3f0745d37e3fa90c4e66ee6b98 by Emo Todorov <etodorov@gmail.com>:

bug fix

Fixed some rendering bugs in the new functionality.

COPYBARA_INTEGRATE_REVIEW=https://github.com/google-deepmind/mujoco/pull/1749 from emotodorov:ui_improve ddfc21dbcf0482b8f0d5eacab21847c302f71440
PiperOrigin-RevId: 646060325
Change-Id: Idb27aae7cd0311d00f26387bcadf5891175e867d
2024-06-24 05:33:51 -07:00
Yuval Tassa 6a532fc53e Fix bug in simulate noise injection logic.
Noise injection was occurring at every iteration of the physics thread, rather than before every call to `mj_step`, leading to time-step-dependent noise rate.

- Moved the logic from main.cc to a `Simulate::` method, called before `mj_step`.
- Reduced the maximum time-scale slider value back to 4 seconds (recent increase was due to this bug).

PiperOrigin-RevId: 643350296
Change-Id: I96832905e6614f92ac725298b16fcabe64ea1df1
2024-06-14 08:13:24 -07:00
Yuval Tassa f37f840880 Improvements to control noise in simulate:
- Use `ctrl` as filter state rather than external preallocated buffer.
- Scale and clip to control ranges.
- Exponential decay to the middle of the range.
- Scale is now [0 1] (scaled to range).
- Rate is now [0 20].

PiperOrigin-RevId: 642586333
Change-Id: Id45a0420736a6edcf09be1db53d9320e7df2c668
2024-06-12 05:35:41 -07:00
Saran Tunyasuvunakool 7bb0ce4211 [Python Viewer] Allow users to override rendering flags via user_scn.
Fixes #1190

PiperOrigin-RevId: 603672602
Change-Id: I3ff1bb0dca7e913b36f1b241aaea8b8bb95cadff
2024-02-02 06:39:08 -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
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
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
Levi Burner e7d1f2f110 simulate: fix display of loading message 2023-09-27 16:04:36 -04: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
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
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
Nimrod Gileadi d4414a0353 Initialize real_time_index to zero.
In the passive viewer, this value wasn't initialized.

PiperOrigin-RevId: 525760119
Change-Id: I6635270a30556600a0c51ba1d2767da226ba0440
2023-04-20 08:55:32 -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
Saran Tunyasuvunakool e40775fab3 Abstract out GLFW calls from Simulate.
PiperOrigin-RevId: 500129478
Change-Id: I7ba998e20439575ad9a3fe1a866c3db4c36b9328
2023-01-06 02:45:56 -08:00
Gianfranco Costamagna 0b33fd9eaa sed s/atomic_bool/atomic_int/g -i simulate/simulate.h
Change atomic_bool to atomic_int to make sure that the compiler will try the best to
generate machine code, instead of relying on an external atomic library
2022-12-08 21:24:00 +01:00
Copybara-Service f7b256de91 Merge pull request #419 from aftersomemath:simulate-python
PiperOrigin-RevId: 487496285
Change-Id: I17d15bd2a3886e5ce1631f4eb78afa94830d08cc
2022-11-10 04:12:34 -08:00
Levi Burner e12343ae51 remove stray #include 2022-10-04 14:55:26 -04:00
Levi Burner 95a4b1c551 simulate python: fix cmake, glfw usage, update Python version of physics loop 2022-10-04 14:37:06 -04:00
Alessio Quaglino bc1490b7a8 Add realtime parameter to visual global.
PiperOrigin-RevId: 478775714
Change-Id: Ic2d178a5c57d298d005215219ce8470392c4651b
2022-10-04 07:09:15 -07:00
Yuval Tassa 834e8dd506 Improvements to time synchronisation in simulate.
- Improved time-sync logic readability in `PhysicsLoop`.
- Fixed unattainable condition for breaking from stepping loop if data was reset.
- Added measurement of actual real-time tracking.
- Moved slowdown overlay to top left.
- Report slowdown as % of real-time, rather than fraction.
- Report actual slowdown if different than requested (very small timestep, PhysicsLoop cannot keep up) by more than 10%.
- Replaced slowdown increments of 2 with decimal-rounded increments of 10^(1/10). This is a finer-grained scale (approximately 3x as fine) and well suited for decimal percentage representation.
- Maximum slowdown increased to 1000.
- Added `Simulate.refreshrate` with a default of 60Hz, in case videomode refreshrate is 0 (can occur e.g. when forwarding over X11).
- Remove realtime reporting from regular info overlay.
- Various cleanups.

PiperOrigin-RevId: 471547481
Change-Id: Idd2514a4defb1dc431617f3a515cc747c4fd8971
2022-09-01 09:09:48 -07:00
Saran Tunyasuvunakool 3240596c3a Call GLFW functions via a dynamic dispatch table.
This allows us to use GLFW without needing to introduce a link-time dependency on the library, which in turn enables us to get GLFW through Python.

PiperOrigin-RevId: 470100999
Change-Id: I27c84ad3310afdbebd582ab0033b6a963ba6307e
2022-08-25 15:41:53 -07:00
Kevin Zakka 80b4ffdd6a Add screenshot button to simulate.
PiperOrigin-RevId: 465628684
Change-Id: I0eb86d6b18c25bb437f197229be6d1c57ccbc50a
2022-08-05 12:56:32 -07:00
Saran Tunyasuvunakool e40b9da181 Merge pull request #201 from aftersomemath:refactor-simulate
PiperOrigin-RevId: 465044152
Change-Id: I54e65a30764a444dbd175260314d685fd7ffa6a1
2022-08-03 15:32:15 +01:00
Levi Burner e036e9a229 Simulate: Make sure all class members are initialized 2022-07-08 16:04:12 -04:00
Levi Burner 655eec1d63 Link GLFW as a shared library by default
Use one option name to control building GLFW as static/shared since it
is not straightforward to set it seperately for the samples and simulate
2022-07-08 16:04:12 -04:00
Levi Burner 1788d23da6 Simulate: disable mjsimulate shared library, multiple linkages of glfw cause crash on MacOS 2022-07-08 16:04:12 -04:00
Levi Burner 70ec29a722 Simulate: fix header includes 2022-07-08 16:04:12 -04:00
Levi Burner a526a6bd78 Simulate: move all glfw calls to main thread to fix MacOS 2022-07-08 16:04:12 -04:00
Levi Burner ed82f055e8 Simulate: fixes for windows version 2022-07-08 16:04:12 -04:00
Levi Burner 033ca81db6 Simulate: fix reload button causing segfault, make interface changes needed for Python bindings 2022-07-08 16:04:12 -04:00
Levi Burner 447877abef Simulate creates and maintains its own thread 2022-07-08 16:04:12 -04:00
Levi Burner 65d5ade426 Refactor simulate to split UI from application
Fix name of glew library

Move simulate to new directory and refactor to use C++ conventions

Wrap simulate in mujoco namespace

fix namespaces, convert struct to class, use std::lock_guard

use GetMutex to better handle destruction ordering

rename mjSimulate to Simulate

nit: space before public and typo

move startup print

use nullptr instead of NULL

use GetInstance() to get simulate object

convert init to default constructor
2022-07-08 16:04:07 -04:00