Commit Graph

28 Commits

Author SHA1 Message Date
Copybara-Service 699ad13a72 Merge pull request #2503 from Andrew-Luo1:rscope
PiperOrigin-RevId: 745266549
Change-Id: I15d2eb992aae643ac096650693cc0750421f14c6
2025-04-08 13:21:47 -07:00
andrew 65500cfbdc improve variable and function names 2025-03-30 22:19:55 -04:00
andrew 97092facd6 resolve PR comments 2025-03-27 19:35:36 -04:00
andrew faff1224ba fix memory leak 2025-03-17 10:42:11 -04:00
andrew f02fdfe2d1 add handles for text and image overlays 2025-03-14 21:41:28 -04:00
Google DeepMind 37d7591ce0 Add support for user-defined figures in the MuJoCo viewer.
PiperOrigin-RevId: 726983516
Change-Id: Ifb821f3cafb163d4f3077d76b0668037b4bc5a9c
2025-02-14 10:45:47 -08:00
Google DeepMind c8cc2d51b0 Allow the viewer handle to return the mjModel/mjData objects from the simulation.
PiperOrigin-RevId: 643982026
Change-Id: Ida5ccb851c46f7352e724798738006be6badad0a
2024-06-17 06:12:22 -07:00
Saran Tunyasuvunakool a84499e904 Fix non-graceful exiting behaviour in launch_passive.
The viewer currently hard crashes when the user script loops on the passive viewer handle without paying attention to `is_running`. This is considered user error, however this change makes the user script hang on the loop rather than hard crashing.

Startblock:
   diffbase is submitted
PiperOrigin-RevId: 572336261
Change-Id: Id53126a158242b947584da1f946304ae8e792d4a
2023-10-10 12:39:37 -07:00
Saran Tunyasuvunakool a1d0cbd654 Add show_{left,right}_ui kwarg to viewer.launch(_passive).
Fixes #857

PiperOrigin-RevId: 572333909
Change-Id: I12247fe856afddf808eb8f386a594acac47c34b5
2023-10-10 12:31:11 -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
Saran Tunyasuvunakool 48d0bfde44 Replace glfw.get_time with time.time in the Python viewer timing logic.
PiperOrigin-RevId: 563134207
Change-Id: Ic548701fc78336d8d87e94ea48833f94ee6395b8
2023-09-06 09:52:12 -07:00
Saran Tunyasuvunakool 06b70832ce Add keyboard event callback for Python passive viewer.
Fixes #766
Fixes #846

PiperOrigin-RevId: 549449372
Change-Id: I37d17f1162c66d0e8482d402aae22d9a16b59deb
2023-07-19 15:54:44 -07:00
Saran Tunyasuvunakool f7847ba73e Fix GLFW crash when Python exits while the passive viewer is running.
Fixes #790

PiperOrigin-RevId: 549440435
Change-Id: I808f6aaab6662225e5fe1131e0da72eca6011ba9
2023-07-19 15:20:46 -07:00
Saran Tunyasuvunakool 5f327b0c31 Add missing pybind definition for update_mesh.
PiperOrigin-RevId: 548395521
Change-Id: Id21a1ef6daa94a221062e7354db3e906611f0f36
2023-07-15 14:57:38 -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 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 cefc290eac Reorder arguments of Simulate::Load in Python to match C++.
PiperOrigin-RevId: 523973129
Change-Id: I58760e3e392a208dd8257c340da146aa8f745fb7
2023-04-13 05:22:13 -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 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
Saran Tunyasuvunakool 7d8e810ab1 Fix IPython history corruption when using launch_repl.
PiperOrigin-RevId: 508064761
Change-Id: I58fa2e4f35b57a1ab68c3172ba5c0d4495e40ced
2023-02-08 06:37:42 -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 9fcf3b0c2e Modify Python simulate so that the Reload button works.
Also allow a `Callable[[], [MjModel, MjData]]` to be provided as an argument to `launch` instead of a fixed MjModel/MjData instance. This allows users to customise the behaviour of the Reload button.

Context: https://github.com/deepmind/mujoco/discussions/576#discussioncomment-4161429
PiperOrigin-RevId: 492296268
Change-Id: Ic4b797d2ea8a6967f7e3e7316f2184ea94a86d8b
2022-12-01 14:12:35 -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
Levi Burner 95a4b1c551 simulate python: fix cmake, glfw usage, update Python version of physics loop 2022-10-04 14:37:06 -04:00
Levi Burner 0b6bf42840 WIP Python bindings for Simulate tested on Linux only 2022-10-04 12:34:49 -04:00