Commit Graph

551 Commits

Author SHA1 Message Date
Levi Burner a0971ef749 rollout fix cosmetics 2025-02-21 08:44:17 -05:00
Levi Burner aca4e5d6ae rollout test for integer overflow in array size check 2025-02-20 21:12:52 -05:00
Levi Burner df71467eed rollout use size_t for array size check and pointer arithmetic 2025-02-19 22:46:12 -05:00
Yuval Tassa 19624aef9d Add an example of a textured height field to mjSpec notebook.
https://youtu.be/i6eXrzJNKeY

PiperOrigin-RevId: 728841769
Change-Id: I1aca838af69d8474aab13b06d8c1e5cf87fc6440
2025-02-19 15:34:21 -08:00
Copybara-Service 7a2ad8fd97 Merge pull request #2436 from aftersomemath:rollout-notebook-pr
PiperOrigin-RevId: 728706864
Change-Id: I8f3a507234c4265564a4fee9df0ab8111ff7dd85
2025-02-19 09:42:08 -08:00
Alessio Quaglino b0e9d08673 Move introspect to python/introspect
PiperOrigin-RevId: 728695024
Change-Id: I96433e1e9ee509704d66bd4c1be1906732e4cc55
2025-02-19 09:01:21 -08:00
Levi Burner 41a873b016 Notebook showcasing the Python rollout module 2025-02-18 10:57:03 -05:00
Alessio Quaglino 7f11a0df12 Add check for height fields size during compilation.
Fixes #2427.

PiperOrigin-RevId: 727805729
Change-Id: Idf3192e5fb238249faaeae6b4fb9de4c55755d96
2025-02-17 04:01:27 -08: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
Alessio Quaglino 5b924fec98 Add support for binding to arrays of mjs element.
Fixes #2402.

PiperOrigin-RevId: 726449592
Change-Id: I0cde44889837a71a222b20cf91fa56568b4af689
2025-02-13 06:01:30 -08:00
Alessio Quaglino 1b4258d274 Change set_default and default to classname in the bindings.
Having defaults in the names of the attribute or function names is confusing for the users since the defaults are not re-applied but are only used for writing to XML. The alternative would be to change mjs_setDefault to re-apply them, but this would overwrite any other attribute set by the user so far.

PiperOrigin-RevId: 726431090
Change-Id: I41f4a23e1722e278b0ecc0a00b07db9b384fe994
2025-02-13 04:52:02 -08:00
Yuval Tassa 7af9bcbf00 mjSpec tutorial: Move humanoid and Menagerie imports to the cells that require them.
PiperOrigin-RevId: 725945693
Change-Id: I3f0d4c867626ef61605815bb708a55c8e29d79e2
2025-02-12 01:02:17 -08:00
Copybara-Service d830691f53 Merge pull request #2291 from AaronYoung5:main
PiperOrigin-RevId: 725933976
Change-Id: I207cf272d30e28f00fb4d07bd237385ad4c26a84
2025-02-12 00:16:10 -08:00
Alessio Quaglino cef5b31a3f Drop find_ prefix in Python MjSpec methods accessing elements by name.
PiperOrigin-RevId: 725594833
Change-Id: Ibf8a9918e98b298751d0ef2e657714e28e5fa460
2025-02-11 05:50:49 -08:00
Alessio Quaglino e54f3c222d Autogenerate mjSpec find_* methods.
PiperOrigin-RevId: 725255440
Change-Id: Ia9112f6c582ea9bb0af38aa97a917e72a98a84f5
2025-02-10 10:03:44 -08:00
Alessio Quaglino 4156350708 Add to_file function to save the Spec to a file.
Fixes #2415.

PiperOrigin-RevId: 725161617
Change-Id: I6c374cc7f7cb3f1da1cc0da531dd7e5be5d62b6a
2025-02-10 04:33:14 -08:00
Yuval Tassa 73aba91297 Add simple procedural tree example to model editing tutorial.
https://youtu.be/7VJG61AapEc

PiperOrigin-RevId: 724729966
Change-Id: I48c288de8e01baa3cd8f40700bc7137744de37a0
2025-02-08 13:02:11 -08:00
Alessio Quaglino 06758e35ab Fix mjSpec colab after changing the default behavior of attach to be a shallow copy.
PiperOrigin-RevId: 724375710
Change-Id: I5fac7d24c1d0b1ad4d427c021022c47620accf53
2025-02-07 09:41:03 -08:00
Alessio Quaglino dec7b661c1 Add mujoco.MjSpec.MjStruct type.
PiperOrigin-RevId: 723552214
Change-Id: I8ecb43b4025b532ba8b48e15c9c6a2b350293d20
2025-02-05 10:01:35 -08:00
Alessio Quaglino 6bd88711a8 Add parent to MjSpec wrapper in Python bindings.
This keeps track of specs attached with the full attach function `attach`. It does not track fine-grained attach via `attach_body` and `attach_frame`.

PiperOrigin-RevId: 722597081
Change-Id: I56188f1718592128b7033538acc9a40553cbbed2
2025-02-03 04:04:11 -08:00
Alessio Quaglino 86ace5e562 Remove body.spec() function from the Python API
We can only use the MjSpec wrapper, not the raw::MjSpec struct in the API.

PiperOrigin-RevId: 722589064
Change-Id: I007150f92738487f27211d7435e328cab86214f7
2025-02-03 03:31:35 -08:00
Yuval Tassa 767be23207 Fix pretty printing in mjspec notebook.
PiperOrigin-RevId: 721367994
Change-Id: Ia1c4ee5b64540ff2f9c08a1953295ff366e0c72b
2025-01-30 06:32:35 -08:00
Alessio Quaglino 904b49848f Add worldbody assertions in attach tests.
This clarifies the difference between attaching a full spec, which converts the worldbody to a frame, and attaching a specific body (or frame).

PiperOrigin-RevId: 721297010
Change-Id: Iff87fe99b81746e6ab3a189a3057b274d3c9a939
2025-01-30 01:35:55 -08:00
Alessio Quaglino 0643017346 Add asset argument to MjSpec constructors.
PiperOrigin-RevId: 720628689
Change-Id: I189aa34973e58b9fb87951e34cb923d94e081a55
2025-01-28 10:39:27 -08:00
Alessio Quaglino 5b330ca19c Change keyword argument asset to include in spec.from_file and spec.from_string.
PiperOrigin-RevId: 720611881
Change-Id: I92f5e72cece8d3223bc552ea4f2ef742c47cb8c9
2025-01-28 09:55:48 -08:00
Alessio Quaglino 2546fcefa0 Add mujoco.MjSpec.to_zip()
PiperOrigin-RevId: 719003836
Change-Id: I310ac96b0080b3313c325cee76d3bf7f81fa9df0
2025-01-23 14:01:06 -08:00
Yuval Tassa f9fd2e4ba4 Add a test showing how to implement scipy's 'soft_l1' loss in minimize.least_squares
PiperOrigin-RevId: 718649580
Change-Id: I5cec0e2850c805301407c9eb543ab3ba69d42e79
2025-01-22 18:25:44 -08:00
Yuval Tassa 0090e1e908 Rename rollout variable nroll to nbatch.
PiperOrigin-RevId: 718196100
Change-Id: Ic36b1a96ea1af2de351539115d4eee051d195aaf
2025-01-21 21:04:15 -08:00
Copybara-Service ac76540eb8 Merge pull request #2377 from aftersomemath:rollout-fix-ndata-check
PiperOrigin-RevId: 718181763
Change-Id: Ie88bf1d26c77478ce3a5ca8fdf29ae90e54b5834
2025-01-21 20:11:33 -08:00
Alessio Quaglino 6a7a7a5f80 Add the override_assets attribute to MjSpec.
When specified, child asset with repeated names will override parent's, rather than throw an error. Default behavior is to override.

PiperOrigin-RevId: 717979621
Change-Id: I18022dc266619b4ba1a8636d1c60f85b0eb5f862
2025-01-21 10:39:02 -08:00
Alessio Quaglino 1412a29dac Merge child asset dictionary into parent spec during attach().
PiperOrigin-RevId: 717939728
Change-Id: I54f8ac87062cf19f55a16af37b777701545ed865
2025-01-21 08:57:09 -08:00
Alessio Quaglino 4bb6aeb19f Change site and frame attach API.
Old API:
```
site.attach(child_spec)
frame.attach(child_spec)
```

New API:
```
parent_spec.attach(child_spec, frame=frame_name_or_object)
parent_spec.attach(site_spec, site=site_name_or_object)
```

This enables accessing the parent object during attach, which will be used in a follow-up CL to automatically append the child assets to the parent.

PiperOrigin-RevId: 717908589
Change-Id: I0fb27e99694c954cb8ba8a8c98484ffd53a4d6db
2025-01-21 07:29:27 -08:00
Levi Burner cee122116e rollout: fix bugs in checking list lengths, add tests 2025-01-21 00:36:52 -05:00
Yuval Tassa baf1c43b3c Fix more misleading line for creating list of models in rollout_test.py
PiperOrigin-RevId: 717628943
Change-Id: I83a314565ce4ec683afeea18c8c8ce9e23d5452e
2025-01-20 14:27:31 -08:00
Yuval Tassa ff4783482c Fix misleading line for creating list of models in rollout_test.py
PiperOrigin-RevId: 717582208
Change-Id: I1b4e40fc5ccbfe68fb7dc240715c704f1f68d9fe
2025-01-20 11:13:21 -08:00
Alessio Quaglino 699a6765e3 Add find functions for joints, lights, and cameras to mjSpec bindings.
PiperOrigin-RevId: 717578768
Change-Id: I2087ccbb9cf8b3b8ec03e9eb2edb0707d4a4cac1
2025-01-20 11:02:34 -08:00
Silvia Cruciani 4903d5321c add find_geom property to mjSpec
PiperOrigin-RevId: 716225290
Change-Id: Ie6e229b0e802e7df06148f994d598334592e8ad1
2025-01-16 07:20:19 -08:00
Alessio Quaglino c2138c3fb0 Do not copy the spec during attach.
Use a reference count for managing the memory.

PiperOrigin-RevId: 716169486
Change-Id: Id270c4858c17b9250115e9544d5ea143584e2d5f
2025-01-16 03:53:17 -08:00
Gabe Oppenheimer 6436055c6c Update the version number to 3.2.8 following the 3.2.7 release.
PiperOrigin-RevId: 715870970
Change-Id: I9fc9a09d959043f3029faa7296a717ea56f75c89
2025-01-15 11:13:27 -08:00
Alessio Quaglino 05d4c3d670 Add mjs_getParent to retrieve the parent body of an object.
PiperOrigin-RevId: 715794859
Change-Id: Ib9792787cdb966f579938dde3f94ebabca8ef1fc
2025-01-15 07:42:43 -08:00
Alessio Quaglino 10c7207cea Process asset path before adding VFS buffer.
Also, handle VFS errors.

PiperOrigin-RevId: 715755127
Change-Id: Iaf455d448f16e37ab89ceaa5797319135acd73c9
2025-01-15 05:10:00 -08:00
Gabe Oppenheimer 61973a33c9 Update eigen3 and the changelog ahead of the 3.2.7 release.
PiperOrigin-RevId: 715467319
Change-Id: I4a6a168bc981c976890c46b784e94805afc86323
2025-01-14 11:51:12 -08:00
Alessio Quaglino ba183adb67 Add assets to MjSpec wrapper.
This enables associating assets with a spec object.

Also, remove `spec.compile(assets)` and replace it with the `spec.assets` attribute, which must be be set before compile if assets are present.

PiperOrigin-RevId: 714981385
Change-Id: Ic3a33c3b75d3a7e14868622aadb57b2a8461a649
2025-01-13 08:41:51 -08:00
Andrea Gesmundo 1c32b5d2dd Fix attach logic.
Replace .attach() with .attach_body() where a body is passed as a first argument instead of a spec that is expected by .attach().
+Fix typo.

PiperOrigin-RevId: 714933134
Change-Id: Idb242fbef0fe164075826c01d4e1995c7d4ae565
2025-01-13 05:41:49 -08:00
Yuval Tassa 2409a6e537 Add mjData.nA the number of non-zeros in the constraint inverse inertia matrix.
PiperOrigin-RevId: 714076988
Change-Id: I4c323a6e81dfb23f7972b662719bbcb688bacf4a
2025-01-10 09:23:55 -08:00
Alessio Quaglino 90049343b9 Fix texture indexing bug in bindings.
Fixes #2341.

PiperOrigin-RevId: 713667648
Change-Id: I7fa5da1506306c5374febf762ce54aff9146079b
2025-01-09 07:38:22 -08:00
Andrea Gesmundo 419da17395 Fix plot label.
PiperOrigin-RevId: 713635908
Change-Id: Icbeef26053b10747024ea65b23ca86816f4fdb2e
2025-01-09 05:23:32 -08:00
Saran Tunyasuvunakool 40ef08c8ed Don't pollute the global namespace when using mjpython.
Fixes #2265

PiperOrigin-RevId: 713442833
Change-Id: If155d9f57d4deef8b848478ebd8077a00417d5c5
2025-01-08 15:48:20 -08:00
Yuval Tassa 69c9ac074a Remove mjData.qLDiagSqrtInv, add corresponding argument to mj_solveM2.
- `qLDiagSqrtInv` is only required for the dual solvers. It is now computed as-needed rather than unconditionally.
- `mj_solveM2` now requires a new input array `sqrtInvD` which contains the square root of the inverse diagonal D (formerly saved in `qLDiagSqrtInv`).

PiperOrigin-RevId: 710805133
Change-Id: I0622d6a8da3882916824e9c10bad9223c122c321
2024-12-30 15:24:36 -08:00
AaronYoung5 3ef5ebcf01 removed trailing spaces 2024-12-17 12:57:48 -05:00