Commit Graph

33 Commits

Author SHA1 Message Date
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
Saran Tunyasuvunakool e40775fab3 Abstract out GLFW calls from Simulate.
PiperOrigin-RevId: 500129478
Change-Id: I7ba998e20439575ad9a3fe1a866c3db4c36b9328
2023-01-06 02:45:56 -08:00
Saran Tunyasuvunakool df25d7d602 Raise an informative error when running on macOS under Rosetta 2.
Current users only get a cryptic "Illegal instruction" crash.

Context: https://github.com/deepmind/mujoco/issues/611
PiperOrigin-RevId: 491705647
Change-Id: I1285897a36e858300ee3d125957e90754be9a7f7
2022-11-29 12:19:06 -08:00
Saran Tunyasuvunakool ecac5758e2 Replace NULL with nullptr.
PiperOrigin-RevId: 491385488
Change-Id: Iec34af99edb7ccd64834130a8cc6280a02b166c2
2022-11-28 10:44:30 -08:00
Yuval Tassa 062cb53a4a In simulate, move "pause" label to the top left rather than the top right.
PiperOrigin-RevId: 491035420
Change-Id: I94ad7ca2764716f9821df6009e5c4b50675a04be
2022-11-26 05:40:52 -08: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
Yuval Tassa 5004a4c8c5 Better memory setting and reporting, updated example models.
- Memory heuristic rounds up to the nearest MB.
- `simulate` reports total memory currently allocated in the info box.
- All example models use `<size memory/>` rather than legacy attributes.
- Regenerated `example_saved.xml` and reformatted original model in [overview chapter](https://mujoco.readthedocs.io/en/latest/overview.html?#examples).
- `<size>` top-level section does not get written if empty.

PiperOrigin-RevId: 486702670
Change-Id: I0306e335f32344c59562ba606664ec9d2101f8a8
2022-11-07 10:36:37 -08: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
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
Kevin Zakka 7e89d8dab0 In simulate UI, clear shortcut string for flags with no shortcuts.
PiperOrigin-RevId: 478467279
Change-Id: Icc4317d9e35b41871143572275d03adf7e13d956
2022-10-03 04:31:17 -07:00
Yuval Tassa 0a0acb3419 Display real-time percentage in paused mode, if different than 100%
PiperOrigin-RevId: 474519561
Change-Id: I54eea97f305dc9b57b9513d6ab5cd75368c2cd45
2022-09-15 03:26:12 -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
Copybara-Service 396fdf00c3 Merge pull request #425 from aftersomemath:cull-face-flag
PiperOrigin-RevId: 466904386
Change-Id: Icd5515c2bbb8f8f3417501ea43c8e5ae22b32f91
2022-08-11 02:44:37 -07:00
Yuval Tassa 4d24d56c64 Fix simulate window title.
PiperOrigin-RevId: 465763279
Change-Id: I21405891071ae151c057c40725be645fc28cd748
2022-08-06 07:53:11 -07:00
Kevin Zakka 80b4ffdd6a Add screenshot button to simulate.
PiperOrigin-RevId: 465628684
Change-Id: I0eb86d6b18c25bb437f197229be6d1c57ccbc50a
2022-08-05 12:56:32 -07:00
Levi Burner 581f009c02 Cull face flag 2022-08-05 11:53:46 -04:00
Yuval Tassa b966a37855 Add optional azimuth and elevation to initial free camera.
- Add `azimuth` and `elevation` to `visual.global`.
- Add `mjv_defaultFreeCamera`.
- Use `mjv_defaultFreeCamera` in `simulate`.

PiperOrigin-RevId: 465505244
Change-Id: I61e60f14a990d4e2d220958adb75c325001978ee
2022-08-05 01:04:02 -07:00
Levi Burner 7fb1ffe712 Invert condition variable predicate 2022-08-03 15:59:14 -04: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 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 95510a07d4 Simulate: fix MacOS build (still crashes due to GLFW misusage) 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 1d4461fce6 Simulate: Use new cmake system fix build errors introduced with rebase 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