Commit Graph

957 Commits

Author SHA1 Message Date
Michael Moss 492585ca7a Enable MuJoCo Studio build and packaging on Windows.
Also:
- Patched Filament to support building with Clang, so the default MuJoCo build
  mode doesn't need to change. This should probably be upstreamed.
- Added missing Windows deps to MuJoCo Platform CMake config.
- Updated Studio CMake config to fix unresolved symbols issues on Windows.
PiperOrigin-RevId: 934612701
Change-Id: I3a34a5d274e1452c9cfef0e2868f2788b4b0c7e8
2026-06-18 16:50:31 -07:00
Michael Moss e7ef6528b7 Enable MuJoCo Studio build and packaging on macos.
Also:
- Packages MuJoCo Studio as MuJoCoStudio.app in the MuJoCo.dmg.
- Fixes a Filament compile issue.
- Patches libwebp to fix compile error related to universal builds and forces
  it to build as static.
- Removes the separate, obsolete "build_studio" step.
PiperOrigin-RevId: 934564785
Change-Id: I50c83283b5e138062e37d53926a5a77fdf99dbfa
2026-06-18 15:03:20 -07:00
Michael Moss 8db92ab4a9 Enable building Studio (Linux only) as a component of the main MuJoCo build.
And remove the separate, conditional (and hacky) "build_studio" step.

PiperOrigin-RevId: 934375150
Change-Id: I46514d0f33c17bb29625b818cdde3a285fd2c439
2026-06-18 08:44:16 -07:00
Michael Moss 1f8c6f1183 Add licenses for third-party dependencies brought in by Studio.
PiperOrigin-RevId: 934300272
Change-Id: I7be1fccb4a80ea86803696699f53687f7d37da91
2026-06-18 05:51:06 -07:00
Yuval Tassa 410c73168c Add policies for global attribute conflict resolution upon attach
For example when loading parent_merge.xml:

```
WARNING: Attach conflict when attaching 'child' to 'parent_merge', policy is 'merge'
timestep: parent has 0.005, child has 0.002, taking the minimum
iterations: parent has 50, child has 100, taking the maximum
flag 'Damper': added from child
```

When loading parent_error.xml:

```
XML Error: Attach conflict when attaching 'child' to 'parent_error', policy is 'error'
timestep: parent has 0.005, child has 0.002
iterations: parent has 50, child has 100
Element 'attach', line 10
```
PiperOrigin-RevId: 933620810
Change-Id: Ib477863b5ef763474d27fb4be5a4148be1d5d500
2026-06-17 03:36:10 -07:00
Michael Moss 30357c38a3 Silence C++20 deprecation warnings in MuJoCo Python enums.
PiperOrigin-RevId: 933618689
Change-Id: I7cd99ed47748a56990bef9e390a6c9072d5a6c0a
2026-06-17 03:28:40 -07:00
Yuval Tassa 6f8bb5ef55 Refactor compiler warning handling.
Compiler warnings are now accumulated in a vector of strings within the mjSpec object. New API functions `mjs_numWarnings` and `mjs_getWarning` are added to access these warnings. The compiler's log handler now chains warnings to the global log handler, ensuring they are still displayed immediately. Call sites in `mj_loadXML`, `mj_compile`, and the Python and WASM bindings have been updated to use the new warning API.

PiperOrigin-RevId: 933361650
Change-Id: I47cab98a460c57b0898c0a1a43fce2a5b9648eb1
2026-06-16 16:28:33 -07:00
nas 55c6332f20 Copybara import of the project:
--
8ce7d8199ace95d0f429b0ca9169d290d167cee1 by Anas <anaselghoudane@gmail.com>:

Use box midpoint to choose finite-difference direction in jacobian_fd

When bounds are provided, `jacobian_fd` chooses each coordinate's
finite-difference direction so the perturbation steps away from the nearer
bound. It compared `x` against `0.5 * (bounds[1] - bounds[0])`, which is half
the box *width*, not the box midpoint. For bounds that are not centered on the
origin this selects the wrong direction, and at the lower bound the perturbation
steps outside the box.

Compare against the midpoint `0.5 * (bounds[0] + bounds[1])` instead. Adds a
regression test checking that all residual evaluations stay within an off-center
box when `x` is at the lower bound; it fails before this change and passes after.

--
cfa085484c30df808362898e322de8adc6660b59 by Kevin Zakka <kevinarmandzakka@gmail.com>:

Expand jacobian_fd bounds test and avoid midpoint overflow

Use the distributive form `0.5*lo + 0.5*hi` instead of
`0.5*(lo+hi)` to avoid overflow for extreme bound values.

Expand the single-case test into a parameterized subTest covering
all four boundary positions (lower/upper of positive and negative
off-center boxes), and rename it to `test_jacobian_fd_respects_bounds`.

COPYBARA_INTEGRATE_REVIEW=https://github.com/google-deepmind/mujoco/pull/3301 from Nas01010101:fix/minimize-fd-box-midpoint cfa085484c30df808362898e322de8adc6660b59
PiperOrigin-RevId: 933224876
Change-Id: I833cfe3324876cdeb7ca680c23d1d8a4d16adcf1
2026-06-16 12:06:34 -07:00
Kevin Zakka 351f1ee2ba Bump usd-core to 25.11 to patch remaining Dependabot alert 2026-06-15 18:14:02 -07:00
Kevin Zakka 936d040022 Bump usd-core to 25.8 to patch critical Dependabot alert 2026-06-15 08:53:04 -07:00
Kevin Zakka b1725b4fc9 Bump pinned pip dependencies to patch Dependabot alerts 2026-06-15 08:53:04 -07:00
Michael Moss 3317921999 Add Studio assets into the python packaging.
PiperOrigin-RevId: 932432607
Change-Id: Id5122f3655c519f185b5647f3fb92f3ed54ba82c
2026-06-15 06:50:33 -07:00
Yuval Tassa 4e10f20be6 Fix set_to_muscle() to accept tuple arguments.
Correct argument types for timeconst and range parameters in pybind11
python bindings from C arrays to std::array.

Fixes #3282, #3282, #3318

Thanks to @Abzaek for original PRs

PiperOrigin-RevId: 932423401
Change-Id: Ic30ba076913693f5c0e545789690e8b0fa444390
2026-06-15 06:29:43 -07:00
Haroon Qureshi b1f4656d1a Parse all headers for possible functions.
Allows other files (e.g. mjrfilament) to define functions that
will be added to the introspection output.

PiperOrigin-RevId: 932403177
Change-Id: Ie2d2c6be67f0706463fdec4fc498364125e05dad
2026-06-15 05:39:54 -07:00
Matija Kecman 81bc303a8f Add an async example using multi threading
PiperOrigin-RevId: 932400523
Change-Id: I6649dfd3a657ce11b7dc6cf130f01be8a85a095c
2026-06-15 05:34:08 -07:00
Matija Kecman 7c22920720 Improve async example and remove Network demo code
- Move SimToView and ViewToSim dataclasses from async.py to viewer_protocol.py (adding a user_data field) to consolidate IPC protocol definitions.
  - Remove the simulated Network class and latency UI controls from async.py to simplify the example and focus on core multiprocessing communication.
  - Use parser.parse() in main() for cleaner and more direct MuJoCo model loading.
  - Add cancel_join_thread() to multiprocessing queues and a join timeout to prevent atexit handlers from blocking during process shutdown.

PiperOrigin-RevId: 932327625
Change-Id: If91777dba934814b3f9faa17f9055869920575d7
2026-06-15 02:31:07 -07:00
Yuval Tassa 67a1ea6dca Track authored flags for global attributes
PiperOrigin-RevId: 931585539
Change-Id: Ifdc8c59de6c5a553daf6e0af09d8192aff6b0610
2026-06-13 02:58:32 -07:00
Michael Moss 4bb02e299d Resolve Studio assets path dynamically.
PiperOrigin-RevId: 931162732
Change-Id: Ib44a74790facfa797ca2c4f107edb0062a89c117
2026-06-12 08:26:24 -07:00
Yuval Tassa f27503509e Fix GCC truncation warnings in Python bindings errors.h
Widen mju_error_msg buffer from 1024 to 2048 and replace strncpy with
snprintf to avoid -Wformat-truncation and -Wstringop-truncation.

PiperOrigin-RevId: 930982013
Change-Id: I0fcd726e5ed1ad28594bd4ef55b8b1ae72020043
2026-06-12 00:31:17 -07:00
Yuval Tassa 58f6d52491 Introduce new logging API, fixes #858
PiperOrigin-RevId: 930744288
Change-Id: I6ec1203b55c031390f3eef23192e2337508ce886
2026-06-11 14:36:57 -07:00
Matija Kecman 37084a5c0b Release GIL in MuJoCo Studio Python bindings.
This change adds py::gil_scoped_release to various functions in the parser, renderer, sim and ux modules of the MuJoCo Studio Python bindings. This allows other Python threads to execute while these C++ functions, which can sometimes be time-consuming, are running. The two heaviest operations Present() (rendering) and Advance() (physics) now both release the GIL in C++.

PiperOrigin-RevId: 930645361
Change-Id: Ib239fb54edc7ac0d8b1d94bec8c57a447d5f4d27
2026-06-11 11:32:09 -07:00
Michael Moss ab17ff5552 Add Python Studio CMake configs and integrate into python build and packaging
PiperOrigin-RevId: 930532579
Change-Id: I2c4b51664475cc8fba92d70d072528843aa03f0c
2026-06-11 08:03:44 -07:00
Michael Moss 41ac783d3a Add ImGui context sharing for UI rendering in Python MuJoCo Studio
PiperOrigin-RevId: 930507935
Change-Id: I7615931f9a71793b049e8b6b442be6a2d726f0b2
2026-06-11 07:10:41 -07:00
Michael Moss 684eccc146 Removed unused constexpr variables in ImPlot Python bindings
PiperOrigin-RevId: 930500399
Change-Id: I95bc9c4b580700d75a48d0784d611913956c0431
2026-06-11 06:53:10 -07:00
Michael Moss fbdf8a6215 Add Copybara rule to transform header paths under experimental.
PiperOrigin-RevId: 930498813
Change-Id: I18d4cdad18cd1f2e23c8ba48ebf2d2e5a3b54168
2026-06-11 06:49:08 -07:00
Matija Kecman 018fbc3223 Release GIL in native viewer.
Adds py::gil_scoped_release no_gil; to mujoco::studio::Viewer methods to release the Python GIL during C++ execution.

PiperOrigin-RevId: 930482271
Change-Id: I590794109418516ec5d9e8b536085560a1d36314
2026-06-11 06:13:45 -07:00
Matija Kecman d068c96d00 Expose ImGuiInputTextFlags_WordWrap to Python.
PiperOrigin-RevId: 930466666
Change-Id: Ic0d5bb39125c3a3986fe28f09d5ba8776c7fc2c7
2026-06-11 05:33:23 -07:00
Michael Moss 6f6a72f66b CMake updates for Studio integration
PiperOrigin-RevId: 929809674
Change-Id: Iabe670ced44f09fc1ea6d8dcde4b3c9ea4ad270a
2026-06-10 06:20:50 -07:00
Matija Kecman edbe6a6f74 Fix memory and resource leaks in failing resource provider open callbacks
When an mjpResourceProvider's open callback returns 0 (failure), MuJoCo does
not invoke the corresponding close callback. Previously, several resource
provider implementations allocated heap memory or system file handles before
encountering an error, failing to clean them up before returning 0. This change addresses these leaks across the codebase and clarifies the API contract.

PiperOrigin-RevId: 929803942
Change-Id: Ib7344033726895cdf037a8d9356ffc183c78c2d3
2026-06-10 06:08:17 -07:00
Michael Moss c31e94cee6 Support nested packages (needed for Studio extensions).
PiperOrigin-RevId: 929802580
Change-Id: I680a1a851256fb6b0cd576db928c241890076ce6
2026-06-10 06:04:22 -07:00
Haroon Qureshi e6e5229126 Format header to conform to style guide.
Also moves some types to the mjrender.h header.

PiperOrigin-RevId: 929189125
Change-Id: I19e5598210898c0defb663c60d7ecfb9a19bcd38
2026-06-09 07:43:16 -07:00
Matija Kecman 4be41d7b0b Add graphics modes list to viewer protocol
PiperOrigin-RevId: 929157105
Change-Id: I75586c37bc94666800f7822654225bad0717e51c
2026-06-09 06:29:04 -07:00
Matija Kecman 66c0131840 Internal change
PiperOrigin-RevId: 928689775
Change-Id: Idfbbafe44b74acf36ff82a72eabf026d4226d47c
2026-06-08 11:50:55 -07:00
Yuval Tassa a0f014593b Support float32 in mujoco.rollout Python wrapper and tests.
- Update rollout.py to use mujoco.MJTNUM_DTYPE instead of np.float64.
- Update rollout_test.py to use DTYPE for all state/control/sensor arrays to avoid copies and type mismatches.

PiperOrigin-RevId: 928539946
Change-Id: Iee2250c049de799cb0e23ffe5558fe6eea8b3fd8
2026-06-08 06:59:22 -07:00
Yuval Tassa 6c33e16bf1 Canonicalize mjVisual macros to include type and dimension.
PiperOrigin-RevId: 928506110
Change-Id: If5d031f9d87892f13486ae9ccde23c16131212de
2026-06-08 05:30:57 -07:00
Kevin Zakka 2b9960a617 Address reviewer feedback. 2026-06-04 09:53:17 -07:00
Kevin Zakka ab4102ea42 Add opt-in cond(J^T J) check to sysid optimize().
Pass check_conditioning=True to FD the Jacobian at the starting point
and warn if cond(J^T J) suggests numerical ill-conditioning.
2026-06-04 09:53:17 -07:00
Kevin Zakka d75b709892 Forward x_scale through the sysid mujoco backend.
mujoco.minimize.least_squares now supports x_scale natively, so the
sysid wrapper becomes a thin pass-through. 'jac' is adaptive per
iteration (was static at x0).
2026-06-04 09:53:17 -07:00
Kevin Zakka 5ae677f026 Warn and rescue sysid parameters that start at a box bound.
ParameterDict.move_off_bounds() shifts at-bound values into the interior;
optimize() warns when any non-frozen component starts at a bound.
2026-06-04 09:53:17 -07:00
Yuval Tassa 7b9b88060e Refactor mj_fullM. This change is part of the deprecation of mjData.qM.
PiperOrigin-RevId: 925669464
Change-Id: I4889c66591bc1df4c31135a13776052aad491f7a
2026-06-02 17:22:55 -07:00
Matija Kecman 49211a05c5 Add support for custom physics step functions in StudioApp.
This change allows users to provide an optional `step_fn` callable to `StudioApp.update` and `StudioApp.update_from_viewer`. When provided, this function is called to advance the physics simulation instead of the default `step_control.advance`.

PiperOrigin-RevId: 925439890
Change-Id: Ia833503f6dd0c22fb8d75af6c5f06757496853e5
2026-06-02 10:27:52 -07:00
Matija Kecman 0e4749501c Allow custom step function in StepControl::Advance.
The StepControl::Advance method now accepts an optional std::function to be used instead of mj_step. This allows for custom simulation logic to be executed within the stepping loop. The Python bindings for StepControl::advance have been updated to support passing a Python callable as the custom step function.

PiperOrigin-RevId: 925393132
Change-Id: Id2820c4b55cbdfee6b01adc2395e99a990d4e7a3
2026-06-02 09:20:06 -07:00
Matija Kecman 4cf4a5665d Configure Copybara export for Dear ImGui and ImPlot Python bindings
Following the export declarations in Dear ImGui and ImPlot METADATA, this change updates MuJoCo's Copybara configuration (copy.bara.sky) to export and transform the Python bindings. `//third_party/dear_imgui/google/py` exports to `python/mujoco/experimental/dear_imgui` and `//third_party/implot/google/py` exports to  `python/mujoco/experimental/implot`.

PiperOrigin-RevId: 925293624
Change-Id: Ie6e32d247a6f7fc24bb36ae7060f2075d8efeb26
2026-06-02 05:32:22 -07:00
Yuval Tassa 062b0f1ea6 Remove deprecated mju_{error,warning}_{i,s} functions.
PiperOrigin-RevId: 925204136
Change-Id: Ia877d08a135092db8037d04e6a237e81325a1d7c
2026-06-02 01:59:05 -07:00
Yuval Tassa 4548e81e4d Rename efc_diagApprox -> efc_diagA.
The field now stores either an approximate or exact diagonal of the constraint matrix A, so the name is made more general.

PiperOrigin-RevId: 924244954
Change-Id: I62b2f76531fb88b7b3bf96e6769940197596702b
2026-05-31 04:54:11 -07:00
Yuval Tassa 96bf8aea81 Move island-specific sparse matrices from arena to stack.
PiperOrigin-RevId: 923850345
Change-Id: I9683d7554b15b7cd8c45a8dce7814640aa266452
2026-05-30 03:09:46 -07:00
Copybara-Service ffe1eadd7e Merge pull request #3294 from kevinzakka:mujoco-minimize-x-scale
PiperOrigin-RevId: 923519000
Change-Id: I4a8fa1f031428cf41d194d17ea4c41975f93f745
2026-05-29 11:34:36 -07:00
Yuval Tassa df6942eb39 Support float32 precision for mjtNum in Python bindings.
PiperOrigin-RevId: 922959317
Change-Id: I384b3bdeabdc4d3f66c71cae41dabfaf51387be7
2026-05-28 13:56:58 -07:00
Kyle Bayes b935d4153c Add new mju_threadpool API function, and delete old threading API.
PiperOrigin-RevId: 922838541
Change-Id: Id9f7e0fb298ffde61fcc49a802dc78971858ce51
2026-05-28 10:11:44 -07:00
Alessio Quaglino 4c381635e1 Add mjs_makeFlex to the MuJoCo C and Python APIs.
- Add mjs_makeFlex C API that wraps mjCFlexcomp::Make(), creating
  a flex with auto-generated bodies, joints, and equality constraints
  from parameters (type, dim, dof, count, cellcount, spacing, scale,
  radius, mass, inertiabox, equality, rigid, flatskin, elastic2d,
  pos, quat, origin, file, vfs).
- Add Python binding body.make_flex() in specs.cc with keyword args.
- Refactor flex_spec_provision.py to use make_flex() instead of XML
  string templating + separate spec + attach. Eliminates textwrap
  dependency.
- Merge user_flexcomp into user_model BUILD target to resolve
  circular dependency.

PiperOrigin-RevId: 922725304
Change-Id: Ice13787c45f3173407fec659f9590a6453bc65dd
2026-05-28 05:59:20 -07:00