Commit Graph

33 Commits

Author SHA1 Message Date
Kyle Bayes 1490336955 Change LoadModelFromString to return a smart pointer, add MakeData, and update tests to have C++ RAII clean up model and data.
PiperOrigin-RevId: 935980153
Change-Id: I41d25bfab4935494dc984168820cb7cad123cadf
2026-06-22 04:19:01 -07:00
Yuval Tassa cedaa47d61 Migrate tests to use MockWarningHandler for warning interception.
PiperOrigin-RevId: 933656759
Change-Id: Ia21514c302799034bf598445933dd90427284737
2026-06-17 05:06:57 -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
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
Yuval Tassa 58f6d52491 Introduce new logging API, fixes #858
PiperOrigin-RevId: 930744288
Change-Id: I6ec1203b55c031390f3eef23192e2337508ce886
2026-06-11 14:36:57 -07:00
Yuval Tassa d80a847bae Move CompareModel to a separate library.
PiperOrigin-RevId: 927174846
Change-Id: Ia8b8b2c8593133d8910399be755e614282bf3252
2026-06-05 02:44:53 -07:00
Yuval Tassa 393c1e4217 Migrate mjtByte to mjtBool for boolean-valued fields.
PiperOrigin-RevId: 921408093
Change-Id: Icb00457836359779f0f72fc02d6a7c0dc9f6bd23
2026-05-26 05:35:49 -07:00
Alessio Quaglino fa912dffa0 Add flex arrays to CompareModel check.
Due to a bug, all flex mjModel fields were previously ignored.

PiperOrigin-RevId: 912546202
Change-Id: Ica95ecfcbbe366fd81de6e8f7d83ed57a7d23033
2026-05-08 08:47:51 -07:00
Kyle Bayes cd8bfb90c3 Improve polygon creation logic in compiler.
PiperOrigin-RevId: 875070301
Change-Id: I06e851f3450035fff68b99997406d6ea471ce3b8
2026-02-25 03:40:07 -08:00
Saran Tunyasuvunakool 5274e5f720 Clean up X macros and usages for mjOption, mjStatistic, and mjVisual.
* Replace various MJOPTION_ macros with a single MJOPTION_FIELDS.
* Use XVEC macro to denote vector members where there is a mixture of
  vector and scalar members in a given struct type.
* Split up MJVISUAL_FIELDS into separate macros for each substruct.
* Modify engine_print.c and Python bindings struct.h/cc to use the
  new X macros.

PiperOrigin-RevId: 869760513
Change-Id: Idac4fe9aa99f0258e7c79802ca9023a0d4486e2d
2026-02-13 09:10:36 -08:00
Yuval Tassa 30b903b6c0 Migrate mjModel size fields from int to mjtSize.
This change updates all size-related members within the `mjModel` struct from `int` to `mjtSize`. This allows MuJoCo to handle models with a larger number of elements. Corresponding changes were made to macros, function signatures, and I/O routines to accommodate the new `mjtSize` type.

PiperOrigin-RevId: 860144595
Change-Id: I701c6d607715d240766b6210a9773cd9e4258c59
2026-01-23 09:41:49 -08:00
Haroon Qureshi cb9a9c159c Remove getdir from mjpResourceProvider.
All known implementations were effectively the same as the default fallback. It was just adding unneeded complexity. Removing this now will help with upcoming improvements to resource providers.

PiperOrigin-RevId: 855163273
Change-Id: I529fc18d0d03a8dc676c909ec9e4b1da1454d414
2026-01-12 04:07:42 -08:00
Haroon Qureshi 398e3dcf15 Use mj_parseXMLString instead of a test-specific LoadFromModelString.
This removes the need for a custom mjResourceProvider, but does require
reimplementing part of mj_loadXML in the fixture.

PiperOrigin-RevId: 854170820
Change-Id: Ib455cc5cdb5138213eb7e996dc32ac156f22a859
2026-01-09 06:34:27 -08:00
Yuval Tassa f61f89bf54 Update use of absl::MutexLock in fixture.cc
PiperOrigin-RevId: 806203271
Change-Id: Ia058d117aedb12c1014912bf5ff192fcc9782964
2025-09-12 02:46:22 -07:00
Alessio Quaglino 51babec9c5 Move tactile sensor to the engine.
PiperOrigin-RevId: 788863133
Change-Id: I3172ebb7641fa8146469da25cba7db794760e7b1
2025-07-30 05:27:44 -07:00
Alessio Quaglino 84ad22a590 Add mj_copyBack for copying real-valued arrays from mjModel back to mjSpec.
Also add `SaveAndReadXML` function to test fixture using `mjSpec` as input.

PiperOrigin-RevId: 765393821
Change-Id: Ic257addd2fc89678fc11b226c168c077626cc51e
2025-05-30 17:17:14 -07:00
Alessio Quaglino ee6f4837f3 Auto-generate 3D mesh from convex OBJ if dim=3 in flex.
This requires the user to explicitly specify an origin.

PiperOrigin-RevId: 712483526
Change-Id: Ie316a5eccb676bb918d4bb746795019145c10f5b
2025-01-06 04:35:59 -08:00
Nimrod Gileadi 0610c1d0e9 Use std::abs instead of mju_abs to compare integerst in fixture.cc.
PiperOrigin-RevId: 659534808
Change-Id: I4eb9f72078f2d7224bcfd3b537e4053d220750c8
2024-08-05 06:35:07 -07:00
Alessio Quaglino 67922f41b9 Exclude nbuffer from CompareModel.
This will give more informative errors when the test fails.

PiperOrigin-RevId: 653571444
Change-Id: I78b0a2bfc7794dae81607a9dbbdb91439af48b0c
2024-07-18 04:50:25 -07:00
Nimrod Gileadi 73cd15344e Fix a couple of mjtNum build errors.
PiperOrigin-RevId: 645024056
Change-Id: Id283f550a4e2d927c214a86e77d42b90fb02824e
2024-06-20 07:31:28 -07:00
Yuval Tassa 8e2f830fd2 Fix type errors in compiler and tests.
In preparation for a float32 build of MuJoCo.

PiperOrigin-RevId: 644407674
Change-Id: I60069f0f865ef89fbf613f5a2ca0c336cc63461e
2024-06-18 09:12:44 -07:00
Yuval Tassa 86ef1746b0 Add convex collision test models.
PiperOrigin-RevId: 643567019
Change-Id: I233553f04ea7d67216a2440f834362965d9e8c58
2024-06-15 01:38:13 -07:00
Alessio Quaglino 26f23066d1 Add replicate element to MJCF. Fixes #553
PiperOrigin-RevId: 629393578
Change-Id: Ia1db1b9e47eba8868117b0f7b85edcd0cc1b6d79
2024-04-30 06:29:18 -07:00
Alessio Quaglino 9ac048e262 Add recompilation test to user_api_test.
PiperOrigin-RevId: 613192683
Change-Id: Ibb44e1c2d63ac0afb7b5f3a15dff26378deb6c82
2024-03-06 06:27:28 -08:00
Alessio Quaglino 9efa4ebe0b Move CompareModel to fixture.
PiperOrigin-RevId: 612759913
Change-Id: Ia5741a858003211c58c47a20d447dcbc041c8b5d
2024-03-05 02:24:32 -08:00
Kyle Bayes 24eb4c9f09 Improve include meta-element to load included resourced from the directory relative to the included XML file, fully backwards compatible.
PiperOrigin-RevId: 608312069
Change-Id: I80eadb32d7d78fb35bd24975f2e514021c2aa009
2024-02-19 05:40:31 -08:00
Nimrod Gileadi c59a33dd81 Use std::string_view instead of absl::string_view in fixture.cc.
Clean up some lint warnings.

Fixes #1306.

PiperOrigin-RevId: 595988916
Change-Id: I0e8584ff8704ea7294cf649664ab447cb1d4ff46
2024-01-05 07:20:58 -08:00
Kyle Bayes f86e8b449f Refactor VFS logic out of ResourceProvider plugin code.
PiperOrigin-RevId: 561302536
Change-Id: I952f9e76e85a7e3a111e0338f307378a6ff58197
2023-08-30 04:47:24 -07:00
Kyle Bayes 67f0f5154f Add various improvements for resource providers.
PiperOrigin-RevId: 529706437
Change-Id: I20385e031446674584349c301982dbe13b812477
2023-05-05 07:03:49 -07:00
Kyle Bayes 23961e24b7 Refactor user codebase to use LoadResource helper method.
* Fix small bug when registering resource providers.
* Add test cases for OS filesystem fallback with VFS.
* Rewrite LoadModelFromString using a resource provider (now can pass custom VFSs).

PiperOrigin-RevId: 526959705
Change-Id: Iee1773e5584535d868aab6b206d1bf362e600c8a
2023-04-25 07:24:45 -07:00
Alessio Quaglino c17375fa32 Stop profiling mju_halton in testspeed and bechmarks.
PiperOrigin-RevId: 490239351
Change-Id: Id73c101672e5b974f16b6b4da3aae757a657de15
2022-11-22 07:41:02 -08:00
Alessio Quaglino 9fc9823a8c Speed improvements in mj_solveLD (14% on Intel Skylake Xeon 36 cores).
PiperOrigin-RevId: 486960670
Change-Id: I8fce96427158ec36069dea893500059e93bd40db
2022-11-08 08:38:45 -08:00
Saran Tunyasuvunakool 1913a02b40 Initial open sourcing of MuJoCo.
PiperOrigin-RevId: 450374687
Change-Id: Ie3225a46ce095fc28ae8e63c326a640261f562bb
2022-05-23 01:08:49 -07:00