Previously mjx dataclasses would return np.ndarray as bytes for jax tracing to hash since they are not inherently hashable. This meant that any tracing that was cached would hold on to a copy of the numpy arrays in the dataclass. Children such as mjx.Model that store large numpy arrays would end up duplicating that data 3+ times in some cases.
This eliminates O(N * array_size) memory duplication across N cached
pytree traces, saving a lot of memory on models with heavy mesh/texture data.
PiperOrigin-RevId: 880985898
Change-Id: I58d4e91fda4112e4c633818f92907d20138e962a
- handle when body0 or body1 are the default prim/world
- add site-based equalities to the constrainst list so they aren't skipped
- support connect constraints by checking for spherical joints
This can be useful, e.g. writing tests that don't depend on rendering.
PiperOrigin-RevId: 879012859
Change-Id: Ifb8d7d5bb06a2456c1b4543f0bf4945fe8155039
This will allow us to add additional renderers to the `render` folder.
PiperOrigin-RevId: 878913300
Change-Id: I205ae41250cbbcded406ad303d4e801d4cff892e
The relpose in mujoco represents the anchor in body1 space and the relative orientation of body2 in body1 space. Previously we were computing it as the relative position of body2 from body1 space.
Further, we now properly account for the setting of strictly the anchor and not the relpos by setting localPos0 *only*.
PiperOrigin-RevId: 878506356
Change-Id: I83fc7e97cd1a891e17f0bb091f8950b581be0e01
The Renderer should configure the context and flip the image when
in classic mode and not rely on the Window to do so.
PiperOrigin-RevId: 878480986
Change-Id: I1af899107647469659662abd85527cdf66f507f4
The SpecEditor improves spec editing by keeping
track of what's being edited and how it changes
over time.
PiperOrigin-RevId: 878410011
Change-Id: I7c323eeb30178dad31946095a727a21b3955f19a
The frustum_top and frustum_bottom assignments in mjv_updateCamera used
the wrong elements of the zver array, causing the principal point cy
offset to be applied with an inverted sign. This shifted the rendered
image vertically by 2*cy pixels.
Repro instructions (note compiler cache and threading must be enabled):
Assume we have a cube.stl mesh containing face data and the following XML:
<mujoco>
<asset>
<mesh name="cube" file="cube.stl"/>
<mesh name="unused" file="cube.stl"/>
</asset>
<worldbody>
<geom type="mesh" mesh="cube"/>
</worldbody>
</mujoco>
Suppose Thread A processes "cube" and Thread B processes "unused". Thread A will generate the mesh hull and will generate polygon data from faces from qhull. Thread B will NOT generate the mesh hull and will generate polygon data from faces coming from mesh file. Thread A beats Thread B to caching the mesh.
When "unused" is later pulled from the cache it gets the polygon data that was generated from "cube" which is not the same that was generated from "unused".
PiperOrigin-RevId: 878336494
Change-Id: I275b09b44490c54b2a5f09d91d0cc047026090f2
Hiding the dock icon after the viewer window closes triggers an
asynchronous screen/dock reconfiguration via SkyLight. Without
draining the main run loop, the resulting NSScreen invalidation
notification is dispatched to a GCD worker thread, which hits
NSScreen's main-thread assertion and crashes the process.
Drain the main NSRunLoop briefly after setActivationPolicy: so the
reconfiguration is processed on the main thread.
WaitForAtomicNoGil spins until the render loop consumes a pending
set_texts/set_figures/set_images request (atomic == expected). If the
user closes the viewer window after a request is submitted but before
the render loop consumes it, the render loop exits and the atomic is
never updated. The calling thread spins forever, preventing the
process from terminating.
Check exitrequest inside the spin loop so the wait bails out once the
viewer is shutting down.