Commit Graph

6 Commits

Author SHA1 Message Date
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
Sam Haves 723b8b1ea6 Introduce explicit VFS in Python MjVfs
This change introduces MjVFS, an explicit object to mirror the C mjVFS. This is meant to replace the MjSpec.assets dict. This latter while convenient guides users towards harmful authoring patterns with respect to data duplication and spec attachment workflows. Making VFS management explicit should encourage better memory usage and allow us to make better compile time optimizations.

From this change, `spec.assets` is deprecated. However we will temporarily support backwards compatibility due to the wide spread usage. An error will be thrown if calling code tries to use a spec that uses both the assets dict and the new MjVfs.

PiperOrigin-RevId: 908772050
Change-Id: I77c6d0369307fc300c954768fed17401261e18da
2026-05-01 09:34:17 -07:00
Sam Haves e37c2268a6 Release gil when compiling spec.
When compiling with threading, we will block the main thread anyways waiting for all threads to complete.

PiperOrigin-RevId: 854230560
Change-Id: Ief689d381afaa3aacc5d712a8df0cb4b6762251c
2026-01-09 09:50:15 -08:00
Sam Haves ce74475c39 Delete VFS created from assets dict before throwing error.
PiperOrigin-RevId: 853838173
Change-Id: Id0dd33b69657813275d1f42db54fae222c337791
2026-01-08 12:13:55 -08:00
Alessio Quaglino cc52d0242b Do not strip the path when compiling an mjSpec.
The path has already been stripped while parsing. This will enable prefixes that contain a `/` while attaching.

Also use `spec.meshdir` for asset paths in `spec.to_zip()`.

PiperOrigin-RevId: 794573523
Change-Id: Ic36bb641c3d72848399006cf718afd8542e91ed4
2025-08-13 07:43:25 -07:00
Sam Haves 5c12ea871f Split MjSpec out into header to allow use by other pybind modules.
This should enable other pybind modules to accept arguments of type MjSpec.

PiperOrigin-RevId: 745580987
Change-Id: I435a8d264149369e3fbee14c5d2c628ef74b2541
2025-04-09 07:31:23 -07:00