Commit Graph

5071 Commits

Author SHA1 Message Date
Pedro Morais 03e484116d Reflect mjvgeom texture field changes in the filament renderer 2026-07-16 10:29:00 -04:00
Pedro Morais 0a6b631d4b Make change non-breaking per haroonq's feedback 2026-07-15 11:53:22 -04:00
Pedro Morais d43c3ed426 Move texture block copy out of render context so it can be modified online via mjmodel 2026-07-09 11:08:43 -04:00
Michael Moss bdeb7e7c4d Revert addition of Clang-19 and 20 from Linux Compilers matrix.
PiperOrigin-RevId: 945098838
Change-Id: I1bd4aa48f52a7555c581096e4e3ebb45fbf9408e
2026-07-09 07:12:40 -07:00
Google DeepMind faf0dabc32 Fix damper kv inheritance from default classes in XML native reader
Ensured dampers correctly read inherited values from gainprm[2].

PiperOrigin-RevId: 945086959
Change-Id: I10900f3ad057036115da88ad6d649d3d058e7373
2026-07-09 06:44:22 -07:00
Kyle Bayes ac29b596fb Autogenerate src files for doc line numbers.
PiperOrigin-RevId: 945067341
Change-Id: I8980a6157e06d1c1e21c6aa45a389b2cca09a363
2026-07-09 05:50:55 -07:00
Michael Moss f04b0fcd3d Update the GitHub Linux Compilers matrix.
PiperOrigin-RevId: 945004453
Change-Id: I939bfd0d4ac55397d65bea207b05d60be3ac8238
2026-07-09 03:00:19 -07:00
Saran Tunyasuvunakool ce3fc0ccfb Replace history slider with a custom timeline scrubber.
Introduces a new timeline widget in the Studio UI, replacing the previous integer slider for simulation history. The new widget displays the current and maximum simulation times, formatted with appropriate units (µs, ms, s), alongside the actual step number, and allows scrubbing through the history via a custom-drawn spine and knob.

This change also modifies the history recording logic to record every solver step rather than only every rendered frame. This enables the step forward/backward buttons to navigate exactly 1 solver step at a time.

This change also fixes `SimHistory::SetIndex()` range checks in `sim_history.cc` to clamp `offset_` against `1 - size_` (`Size()`) rather than total vector capacity (`history_.size()`).

PiperOrigin-RevId: 944671699
Change-Id: Iaa34668a1e257e5c0c1840c827370d81c4935b3d
2026-07-08 13:35:07 -07:00
Omar Rayyan 040872fd65 Copybara import of the project:
--
a5221e754c88580d103bfc7bfaf1ed32927ca499 by omar rayyan <olr7742@nyu.edu>:

Fix .mjz loading in simulate

COPYBARA_INTEGRATE_REVIEW=https://github.com/google-deepmind/mujoco/pull/3384 from omarrayyann:fix-mjz-simulate a5221e754c88580d103bfc7bfaf1ed32927ca499
PiperOrigin-RevId: 944573851
Change-Id: Ifba77ee9f9b97a7d8c0b0a47ac82d390a273672b
2026-07-08 10:30:54 -07:00
Yuval Tassa 18147c50c8 Studio: Only show PAUSE overlay when info overlay is active.
PiperOrigin-RevId: 944428518
Change-Id: I8ba9bc24795ad4d3e35884c88cef12a0df910dec
2026-07-08 04:48:30 -07:00
Alessio Quaglino fb6d1cf18f Support pinned flex vertices with bending
The flexcomp compiler previously rejected pins on dim-2 flexes with
bending (elastic2d bend/both). Allow them: mj_flexPassiveBend treats a
pinned vertex (body without 3 free slide dofs) as static -- zero
velocity, and no bending force applied to it (the reaction is carried
by the pin) -- while its position still enters every neighbor's
bending force, which is exactly what the pin constrains.

PiperOrigin-RevId: 944410969
Change-Id: Ib0a69c8d5fb6f64d3e2a76af3b6b2c7be1898191
2026-07-08 04:02:31 -07:00
Haroon Qureshi c4c2cad503 Implement SceneDecorator class.
Helper class that creates "decor" renderables using an mjvScene.

PiperOrigin-RevId: 943915073
Change-Id: Iae1efbe376dc21430387b10d7200451187522828
2026-07-07 08:41:03 -07:00
Haroon Qureshi 4ab8617429 Get mjrfContext from the ModelObjects.
PiperOrigin-RevId: 943888955
Change-Id: Icfe6230e531a100ad5a09efe582977fd3de8f076
2026-07-07 07:44:47 -07:00
Taylor Howell 6608f1affa MJX Data.where. Fixes #3377
PiperOrigin-RevId: 943875492
Change-Id: I963e4ad052ce9184a7548a468aa4aea722d10469
2026-07-07 07:15:36 -07:00
Haroon Qureshi 6d02ee4756 Merge GetRenderable and GetSelectedRenderable
PiperOrigin-RevId: 943844092
Change-Id: Ia3888ea6c289d491ddb2fba0ea4f5799c367ef2c
2026-07-07 07:15:10 -07:00
Taylor Howell 641c1cf11b update MJX with nvmax
PiperOrigin-RevId: 943836220
Change-Id: I7092b5ed005a48a10812f3280709c50691aa497e
2026-07-07 07:14:47 -07:00
Kyle Bayes 8df03f860c Remove latent bugs in GJK code.
PiperOrigin-RevId: 943831655
Change-Id: Id6f93325610f429bea02923363e1903bb854c61f
2026-07-07 07:14:19 -07:00
Kyle Bayes 62e80eee38 Convert clip and sign operations to branchless one-liners.
Testing on 50 million random doubles we have branchless clip is 1.14x faster than the branched version and branchless sign is 2.27x faster than the branched version.

PiperOrigin-RevId: 943812426
Change-Id: If8003a602365601a31bec1d8b080c44d16000a4e
2026-07-07 04:27:26 -07:00
Matija Kecman ee28b334ef Add a Studio example for rendering time-delayed ghost overlays.
This example demonstrates how to use Studio's `extra_geoms` feature to render semi-transparent, time-delayed copies of the model's geoms, creating a "ghost" effect.

PiperOrigin-RevId: 943672439
Change-Id: I8ae640672945b55dd25dd3d444f52d0b2fa7f0f8
2026-07-06 22:25:04 -07:00
Matija Kecman 8079ab3d4d Refactor Viewer to be a base class owning the communication with the simulation, handler registry, core visualization objects and the render function
ViewerApp is simplified, interacting with the endpoint and handlers through the Viewer instance. This change makes it possible to write simulation viewers without using the UI/UX provided by ViewerApp (which should be renamed StudioApp)

PiperOrigin-RevId: 943642660
Change-Id: Id8eb3d4e6a27ceda93833367fec4699fa6bc838e
2026-07-06 20:50:29 -07:00
Sam Haves ae58855c15 Change compile sample to use mj_parse and mj_encode as input/output.
There is a single remaining exception for mjb as it's a special case by bypassing mjSpec.

PiperOrigin-RevId: 943556676
Change-Id: Iaf480ea6d2d42a6007b35c23435b25c9eb24ead0
2026-07-06 16:35:14 -07:00
Sam Haves 19e175c063 Fix MJZ decoder Windows path separator issue
On Windows, std::filesystem::path::string() returns backslashes while
zip entries use forward slashes. This caused lookup mismatches making
MJZ decoding fail on Windows with 'could not decode content'.

Use generic_string() (which always returns forward slashes) for all
path operations used in zip entry lookups, and normalize the archive
name at construction time.

PiperOrigin-RevId: 943538265
Change-Id: I50cafff82fd7f5f315ccfc890f660e138e4448a2
2026-07-06 15:53:20 -07:00
Yuval Tassa 528e791d6e Add context menus to joint/control sliders for resetting values.
PiperOrigin-RevId: 942950247
Change-Id: I5d1c011f85d7d9abe6b19a699bb34af803998627
2026-07-05 15:55:52 -07:00
Yuval Tassa 1ea2d884d2 Change mju_round to use standard round() function.
PiperOrigin-RevId: 942873144
Change-Id: I3fd0d630643c104ff464d619387ff36582c2a5d8
2026-07-05 10:48:13 -07:00
Matija Kecman 4cb14bef47 Resolve string-based type annotations in message handlers.
When `from __future__ import annotations` is active or forward references are used as strings, type annotations are not directly class objects. This change uses `get_type_hints` to resolve these string annotations to their actual types, ensuring correct validation of message handler signatures.

PiperOrigin-RevId: 942608060
Change-Id: Ic2b214ee85e835616cc3a18ec2699eba6deebb6a
2026-07-04 16:03:26 -07:00
Yuval Tassa 4a9364082e Fix data race lazy-init spin lock deadlock on Windows.
PiperOrigin-RevId: 942556300
Change-Id: Iffe7a3e71c0f6273603e2ada14bf8d924b0ee6cf
2026-07-04 12:07:34 -07:00
Yuval Tassa 11f1da0c44 Migrate types in mjs structs.
PiperOrigin-RevId: 942546629
Change-Id: I46f2b24b53a43361fdc67dc32f2af1c0ce8b1de8
2026-07-04 11:27:27 -07:00
Yuval Tassa 315bcfbf3a Remove mjData.qM
PiperOrigin-RevId: 942520660
Change-Id: I422358e299ca0fcfe4c49cd0ee90c014a4c319d7
2026-07-04 09:38:45 -07:00
Yuval Tassa 7c6f519879 Remove legacy factorI/solveLD and clean up benchmarks/tests
Deletes mj_factorI_legacy and mj_solveLD_legacy from the engine and headers.
Updates factorI, solveLD, and inertia benchmarks to remove legacy targets
and only benchmark CSR.
Rewrites engine_core_smooth_test to verify CSR solver against mj_mulM
instead of legacy solver.

PiperOrigin-RevId: 942507341
Change-Id: I4281decb7018cfa3e46cb446efd5fe1179f6ae1f
2026-07-04 08:34:30 -07:00
Haroon Qureshi 10d6c01dce Increase filament buffer sizes.
PiperOrigin-RevId: 942496954
Change-Id: I9e53bf48b7c56cf76992140fc372d88c6d2a9752
2026-07-04 07:43:45 -07:00
Matija Kecman bdc9e9cce3 Fix bug where backspace intended for an imgui widget reset the environment
PiperOrigin-RevId: 942496281
Change-Id: I8c5d315d22a7c01dbe69f19833964f25141e9663
2026-07-04 07:40:27 -07:00
Haroon Qureshi c665f0b59e Disable spec editor when no spec is available.
PiperOrigin-RevId: 942493527
Change-Id: I90e1a0049b9cc9a82a5ede3a4a74a41425d5bee3
2026-07-04 07:29:06 -07:00
Yuval Tassa 38f0ff3caa Improvements to testspeed
Support named CLI flags, physics overrides, and refactor global state.

  - **Named CLI Flags**: Replaced standard positional arguments with named flags (`--nstep`, `--nthread`, `--noisestd`, `--noiserate`, `--npoolthread`) and preserved Google-wide flags compatibility (via custom argv compacting and InitGoogle).
  - **Physics Option Overrides**: Added support for configuring loaded model settings directly from the command line (`--solver`, `--cone`, `--jacobian`, `--integrator`, `--iterations`, `--tolerance`, `--sleep_tolerance`, `--noslip_iterations`).
  - **Encapsulated Thread State**: Consolidated loose global variables and per-thread rollout statistics arrays into a single data structure, `RolloutRunner runner`, simplifying mutli-threaded data boundaries.
  - **Readable Physics Options Printing**: Logged configured non-default options dynamically prior to rollout. Enums and active bitmask flags (e.g. disableflags/enableflags) are decoded into friendly strings (e.g., `Sleep : Enabled`).
  - **Tests & Docs**: Added testspeed_test.sh running testspeed over dominos.xml to check all overrides, registered shell test target in BUILD and CMakeLists.txt, and updated samples.rst documentation.

PiperOrigin-RevId: 942285912
Change-Id: Idb966fadfa0ccba0f1862f9d62bf83458b61939a
2026-07-03 16:52:40 -07:00
Matija Kecman 7c0d527005 Support extra_geoms argument
PiperOrigin-RevId: 942283363
Change-Id: I7e0c3aa845c0d2ae1c4390fd5cc01d6ff2741720
2026-07-03 16:39:22 -07:00
Matija Kecman 16f2276fe2 Increase priority of ViewerApp ModelEvent handler
PiperOrigin-RevId: 942274710
Change-Id: Ib894420e2d8f1e57a1da2d953c944316a1ff42ae
2026-07-03 16:02:14 -07:00
Yuval Tassa 7e9ac58ff9 Migrate mjd_inverseFD mass Jacobian from qM to M
PiperOrigin-RevId: 942268237
Change-Id: I0ecfe161867ce9930cd6366d778077df2cd3197f
2026-07-03 15:35:52 -07:00
Saran Tunyasuvunakool 4b345457a8 Add a test to check that GIL remains disabled under free-threaded Python.
Also add manual `Py_GIL_DISABLED` macro definition in CMakeLists as well, since there are some STATIC libraries that aren't getting it automatically through pybind11. As originally proposed in PR #3259.

Co-authored-by: Devansh Raulo <151062727+devansh0703@users.noreply.github.com>
PiperOrigin-RevId: 942216446
Change-Id: I9ef5f457491ae776c452912fbfa8617b8509d47c
2026-07-03 12:11:58 -07:00
Taylor Howell 17feb4a64e Update Studio to close window
PiperOrigin-RevId: 942216322
Change-Id: I96b4665016df0acb0c5dec9caae27eeb9a87f874
2026-07-03 12:11:01 -07:00
Yuval Tassa 5618666a7d Add body/simple attribute to control simple body optimization.
PiperOrigin-RevId: 942164766
Change-Id: I1e83bb99b6a1955917eb9b2e9bed0dc7b8e6a161
2026-07-03 09:09:30 -07:00
Haroon Qureshi 4ecfe5c1f3 Add FontGlobalScale binding.
PiperOrigin-RevId: 942113414
Change-Id: Id87ce552e717d118574befd00dac65ca71e3ba0d
2026-07-03 06:24:40 -07:00
Yuval Tassa 14c0b0c92b Recompute sameframe flags in mj_setConst.
The `body_sameframe`, `geom_sameframe`, and `site_sameframe` flags are now recomputed within `mj_setConst` based on the current model geometry. This allows these flags to be updated if the model's body/geom/site frames are modified after the initial compilation. Tests are added to verify the correct recomputation and its effect on forward kinematics. The compiler also checks that its initial computation matches the result of `mj_setConst`.

Fixes #3029, #1628.

PiperOrigin-RevId: 941758649
Change-Id: I7b995f8c67ad305bca5b52732436ba578c905d73
2026-07-02 10:49:00 -07:00
Matija Kecman 0dfa4b509a Refactor Studio customization and message dispatch to use decorator-based handlers
This change replaces fixed callback protocols (e.g., ViewerGuiHook, ViewerUpdateHook, SimEventHandler) with a general-purpose, priority-based message and event handling mechanism.

Key changes:
- Handler decorator and registry: Introduced the `@messages.handler(priority=...)` decorator and `HandlerRegistry` (`handler_registry.py`). Methods marked as handlers are automatically discovered and dispatched by priority (CRITICAL, USER, LIBRARY, INTERNAL) or method resolution order.
- Local lifecycle events: Added `ViewerAppInitEvent`, `BuildGuiEvent`, and `UpdateEvent` to `messages.py`. Custom GUI rendering and per-frame update logic can now be implemented as standard event handlers without needing separate interface protocols.
- Streamlined launch and app APIs: Replaced individual hook and handler arguments in `launch_passive`, `ViewerApp`, and `ViewerHandle` with unified `viewer_handlers` and `sim_handlers` lists.
- Module restructuring: Extracted simulation-side message handling and `ViewerHandle` from `sim_app.py` into a dedicated `viewer_handle.py` module, removing `sim_app.py`.
- Sample updates: Migrated existing examples (such as `implot.py`) to use the new handler pattern and lifecycle events.

PiperOrigin-RevId: 941729322
Change-Id: I93e7c0edf0a13a8dc854f9e2083451f7c25a1825
2026-07-02 09:14:41 -07:00
Haroon Qureshi 1ca64b441b Add binding for DockSpaceOverMainViewport.
PiperOrigin-RevId: 941727670
Change-Id: Idfecadf5a44b237f8c72493a7294bddfcd948ae5
2026-07-02 09:09:51 -07:00
Yuval Tassa 2d283b5e9d Allow self-attach in MJCF
PiperOrigin-RevId: 941676717
Change-Id: I9ff8fc89716bc14b438a41e2b4075bbe5fdb83cf
2026-07-02 06:51:46 -07:00
Yuval Tassa cdc35dec38 Reformat MJCF array in xml_native_reader.cc.
Undo mistaken auto-format of the schema table, revert it to be more human-readable.

PiperOrigin-RevId: 941628625
Change-Id: Ifc51996da9a7df9d1a03392a0ade256fb8b1c151
2026-07-02 04:45:46 -07:00
Taylor Howell c3adb50898 _realloc_island
PiperOrigin-RevId: 941618362
Change-Id: Idef1deb0ff4976de42aa585993988ae3363cd1fc
2026-07-02 04:21:43 -07:00
Yuval Tassa 0e58c48504 Clean up MJCF attach code.
PiperOrigin-RevId: 941603845
Change-Id: I94f275e2073b1eb81cfabdc0bed80021c6f15b1c
2026-07-02 03:45:39 -07:00
Yuval Tassa f8462a156d Refine line search convergence criteria.
The line search now requires a negative cost (improvement) in addition to a small derivative to declare convergence, preventing premature termination when no actual improvement has been made.

Follows the proposal in github.com/google-deepmind/mujoco_warp/pull/1471

PiperOrigin-RevId: 941579503
Change-Id: I8fcd20f7b959e50d77cd5d6de0a3c6d95f86b9e1
2026-07-02 02:56:24 -07:00
Haroon Qureshi fb259a5edd Implement RenderableManager.
Similar to LightManager, the RenderableManager manages
renderables based on an mjModel and its mjData.

PiperOrigin-RevId: 941510745
Change-Id: I97b44cc857f136aa7c90ceb85a42e299fc759b73
2026-07-02 00:03:05 -07:00
Yuval Tassa c6c3ec3149 Add "frame" attribute to <attach> element.
The `<attach>` element now supports a "frame" attribute, allowing users to specify either a "body" or a "frame" to attach to, but not both. The XML parser has been updated to handle this new attribute and the mutual exclusivity constraint.

PiperOrigin-RevId: 941245904
Change-Id: I4c0edeed5f3a9e456aed96c373b1647fe79841d9
2026-07-01 12:49:55 -07:00