Commit Graph

5356 Commits

Author SHA1 Message Date
Yuval Tassa 5800dfc929 Improve Studio help window with fixes, completions, and task grouping.
Fix, complete, and group Studio's help window by task.

PiperOrigin-RevId: 955869367
Change-Id: I5ae7b3661dd80a1273d8c9fecee303c361c102c3
2026-07-29 07:24:11 -07:00
Michael Moss 22f4a286f3 Update deprecated node 20 to node 24.
PiperOrigin-RevId: 955851551
Change-Id: I03dcfaa29e39c6b0b685982d3a12c4da82adf1ba
2026-07-29 06:42:30 -07:00
Alessio 55d13aec5f Replace the flex metric factorization with a block preconditioner
Every step, the flex block of the implicit effective metric M + K was
factorized by sparse Cholesky, because K depends on the configuration. On
model/flex/bag.xml, added here, that is roughly half the step, against a
comparable share for the constraint solve it exists to accelerate.

Keep only the metric's per-vertex 3x3 diagonal blocks, prefactored. Neither
consumer needs the exact inverse: the CG constraint solver only wants a
preconditioner, and qacc_smooth can come from an iterative solve using those
blocks. They are O(n) to build and to apply, but weaker, so CG runs about twice
the iterations and qacc_smooth becomes an iteration rather than a direct solve.
Net, the bag model steps roughly twice as fast.

The preconditioner, by metric state. Inactive, meaning no flex elasticity or an
explicit integrator: M^-1, unchanged. Bending only (nefmK == 0): M^-1 plus the
exact constant bending factor from mj_setConst on the dofs it covers,
unchanged; that factor is built at model compile time and costs nothing per
step. Per-step stiffness: M^-1 plus the 3x3 blocks, where before it was a
per-step sparse Cholesky, or, when M couples across the flex block, an inner
PCG of up to 50 iterations run once per outer CG iteration.

Only models carrying per-step stretch stiffness change in wall-clock. Both
ponchos hold their timing and take slightly fewer CG iterations than before,
because the preconditioner is now symmetric: it applies M^-1 and the covered
blocks to disjoint sets of dofs, where previously the two overlapped and the
operator was not symmetric, which PCG requires.

mjd_effSolve is the accurate solve of (M + K)x = b; what used to carry that
name only preconditions and is now mjd_effPrec. Its CG guarded the division by
pAp with mjMINVAL, an absolute floor on a quantity that scales with the square
of the right-hand side, so a small b aborted the solve while the curvature was
healthy: four flex models were quietly left short of tolerance. For an SPD
metric the guard is positivity, and with that the same solves converge. The qacc_smooth call site in
mj_fwdAcceleration is textually unchanged but now reaches the iterative solve,
which converges on opt.tolerance rather than a hardcoded threshold, floored in
mjUSESINGLE builds where the squared target is unreachable in float. Reaching
the iteration cap names the ill-conditioned flex stiffness and then reports it
through mjWARN_INERTIA, rather than returning an under-converged result.
Covered dofs are located by walking the covered rows of the stiffness matrix,
as they need not be 3-aligned from dof 0: any joint declared before a flexcomp
shifts them.

mjData.efm_L_rownnz, efm_L_rowadr and efm_L_colind described the sparsity of
the deleted factorization and are removed: left NULL with nonzero mjxmacro
extents they made the Python bindings hand back uninitialized arrays.
efm_active loses the value 2 for the same reason, nothing selects a solve path
on preconditioner exactness any more. Both are recorded under breaking changes.

model/flex/bag.xml is added because no shipped model carried per-step stretch
stiffness. The ponchos are bending-only and trampoline.xml uses an explicit
integrator, so the metric never activates there. It is excluded from
WriteReadCompareTest: stretch stiffness amplifies rest geometry that XML rounds
on save.
2026-07-29 14:36:15 +01:00
VihaanAgarwal 95f05402f1 Fix segfault on a mesh with convex inertia that no geom references
needhull_ was only set while iterating geoms, so a mesh whose inertia is
computed from its convex hull never got one unless some geom pointed at
it. mjCMesh::ComputeVolume and ComputeInertia then read graph_[1] and
GraphFaces() off a null pointer and the compiler crashed.

Whether a mesh needs its hull for inertia is a property of the mesh, not
of any geom, so move that condition out of the geom loop and apply it to
every mesh.

Fixes #3431
2026-07-29 06:18:08 +05:30
Michael Moss 559c2af751 Update MuJoCo Studio icons to have less padding.
PiperOrigin-RevId: 955416676
Change-Id: Ieb13b3ed37f5495a647a6ff58099150a79ba02ee
2026-07-28 12:53:25 -07:00
Copybara-Service d400914e97 Merge pull request #3437 from smallquail:flex-rotation-fix
PiperOrigin-RevId: 955127380
Change-Id: Ie31ab56f7d64dd1a2266828c0fcd3683b55768a5
2026-07-28 02:17:23 -07:00
Alessio d895888da4 Use the inlined mji_ 3x3 helpers throughout engine_derivative.c
Convert the four remaining mju_mulMat{,T}{Vec,Mat}3 call sites in this
file to their inlined mji_ equivalents, so the file is consistent after
the review change to the stretch paths. Aliasing is unaffected: the
inlined variants mark the result restrict, and every call already
required a distinct result (the public versions overwrite res while
reading vec).
2026-07-28 09:14:26 +01:00
Alessio a6743d8e0d Address review: blank line, and use the inlined mji_ 3x3 helpers
Per review on #3437: add the missing blank line above the new comment
block, and use the internal inlined mji_mulMat{,T}{Vec,Mat}3 helpers
rather than the public mju_ ones, matching fe9dc584. Six call sites in
the two stretch paths; pre-existing mju_ calls elsewhere in the file are
left alone.
2026-07-28 09:09:38 +01:00
Michael Moss 1db801460b Update MuJoCo version to 3.11.1 following the 3.11.0 release
PiperOrigin-RevId: 954833728
Change-Id: I1c006cdd72072c6821d7b3c28d8ac320de19b8c5
2026-07-27 14:35:26 -07:00
Michael Moss b85fdca54f Update changelog for the 3.11.0 release.
PiperOrigin-RevId: 954795939
Change-Id: I357468dd9072a5d1bab5af2529039e4924db12ed
2026-07-27 13:22:37 -07:00
Matija Kecman ca5337161d Export netimgui files in MuJoCo Copybara configuration for use with the upcoming Web Viewer
PiperOrigin-RevId: 954769526
Change-Id: I4cdee083082f7d55c2babd5e664ec0283a2aaf63
2026-07-27 12:33:41 -07:00
Alessio 55b43414dd Fix stretch stiffness basis for flexes in rotated parent bodies
The implicit effective metric assembles the stretch stiffness from
world-space edge vectors, but a flex vertex body's slide dofs are
expressed in its parent body's frame. When that frame is rotated the
assembled operator is therefore not the Jacobian of the passive stretch
force, which mj_flexPassiveStretch already maps into the dof frame with
xmat^T. The metric is then inconsistent with the force it linearizes:
implicit integration loses its stability guarantee, and models that the
same flex handles comfortably in an unrotated frame diverge.

Apply the matching change of basis in both places that build or apply the
stretch stiffness: mjd_flexStretch_mul rotates the input dof vector into
world and the scattered result back, and mjd_flexStiff_assemble sandwiches
each 3x3 block as R_bi^T * blk * R_bj. Both are no-ops when the parent is
unrotated. Bending needs no change: its blocks are isotropic, and
R^T (q I) R = q I.

This completes the fix in fe9dc584, which covered the passive force paths
and the interp (trilinear) derivative but not the standard stretch one.

On a mesh flex inside a body with a 90-degree rotation, the metric's
directional agreement with the force Jacobian goes from cos = 0.57 to
cos = 1.0, and a hanging sheet that previously reached 176% strain
settles at 0.87%.
2026-07-27 20:08:31 +01:00
Yuval Tassa c7b6e0b8dd Fix the array size of biasprm in mjsActuator specification.
Note mjNBIAS == mjNGAIN, this change is a no-op.

PiperOrigin-RevId: 954712145
Change-Id: I096246e5d060596c4025ea4c23e8e9e887c8cd50
2026-07-27 10:45:29 -07:00
Matija Kecman e4d0a88ffd Refactor viewer loop and shutdown handling to support conditional rendering and clean exits.
This change introduces a get_frame method to the viewer protocol, replacing the previous is_running check. This allows the viewer loop to skip rendering and lifecycle events when no active frame is ready (for example, when no browser is connected to the web viewer).

Additionally, this change:
- Adds a shutdown hook to ViewerHandle to wait for the viewer to cleanly release resources before exiting.
- Implements an ExitEvent handler in the viewer protocol to stop the run loop.
- Adds an http_port configuration option for the web viewer.
- Prevents double-closing in the viewer.

PiperOrigin-RevId: 954603868
Change-Id: Iaba7d131dc94191de51150464514dd10fa7834b0
2026-07-27 06:55:17 -07:00
Matija Kecman e23b504201 Change how ImGui clip rect scaling and scissor computation works in imgui_bridge to fix flickering and clipping errors in the web viewer
Avoid mutating ImGui draw lists in place by scaling clip rects locally during scissor computation instead of calling ScaleClipRects. This prevents clip rects from growing exponentially on persistent draw lists, such as streamed remote UI. Additionally, clamp the scaled clip rects to the viewport boundaries to prevent Filament's scissor test from rejecting out-of-bounds rects, while avoiding resetting to full-window scissors which would disable clipping.

The draw geometry is now immutable in the Update function (ImGui texture state is still mutated).

PiperOrigin-RevId: 954277141
Change-Id: Ifdf6866bb4eabaca44b020ea40acc246428b4f0b
2026-07-26 13:35:03 -07:00
Copybara-Service 0ae308c50c Merge pull request #3421 from mmossg:fork_main
PiperOrigin-RevId: 953956612
Change-Id: Idf457a84f8541c5a51946c5e649b3aab441441fe
2026-07-25 14:42:28 -07:00
Michael Moss 59d84a714d Update dependencies ahead of the 3.11.0 release (retry).
Also updates MuJoCo files needed to address changes in Filament.
- "build with clang on windows" patch to sync context lines, remove some
  upstream conflicts, disable Clang thread-safety attribute errors, and
  allow running on MSYS2.
- Skip building Filament samples.
- Add missing <string_view> to material_manager.cc.
2026-07-24 15:27:31 +00:00
Michael Moss 28bea62d78 Fix git apply and re-enable cmake cache on Windows.
This forces git to treat the current directory as the git checkout to apply the
patch to, which avoids issues where a non-git checkout (e.g. from an unpacked
cached tarball) can cause git to find a higher-level git checkout and try to
apply the patches there, which then fails when the files to patch aren't found.

PiperOrigin-RevId: 953377327
Change-Id: I86f51d4e2823b64c825070139479089c7f30e53e
2026-07-24 08:21:48 -07:00
Sam Haves dd4d0585ee Fix missing timer end calls on early returns in collision and actuation
PiperOrigin-RevId: 953348565
Change-Id: I64b563e29b2d620df46d50d12dde9215885f41d6
2026-07-24 07:05:45 -07:00
Matija Kecman 91d78346e1 Replace the Studio parser module with a pure Python implementation
PiperOrigin-RevId: 953181335
Change-Id: I1d2ce6f27f50aa4c30cce6d43caed80186ddef42
2026-07-23 23:52:56 -07:00
Michael Moss a9f56dabc2 Fix Windows CMake patch application and add more logging.
PiperOrigin-RevId: 953024686
Change-Id: I5527f52b7473e74a9203916d866a6a91c01a06c9
2026-07-23 16:44:24 -07:00
Alessio Quaglino fe9dc58477 Fix flexcomp instability when parent body has non-identity quaternion
Fast path in mj_flexPassiveInterp, mj_flexPassiveBendInterp, and
mj_flexPassiveStretch assumed body slide joints are world-aligned
(J = I). When parent body has a non-identity quaternion, joint axes
are rotated (J = R_body), causing wrong force mapping and instability
(NaN/Inf in QACC).

Fix: project world-frame forces onto body local frame via
mju_mulMatTVec3(R_body^T, force) before adding to qfrc_spring/damper.
Also fix the derivative paths:
- mjd_flexInterp_kernel fast path: R^T * K_rot * R * vec
- mjd_flexStiff_assemble (CSR): R_bi^T * K_rot_block * R_bj

The CSR-assembled stiffness matrix is the actual path used by the
implicit CG solver (mj_flexCG gate). The test uses solver="CG" to
activate this path; without it, flex stiffness is integrated
explicitly and no derivative fix can help.

Ported from GitHub PR https://github.com/google-deepmind/mujoco/pull/3379
Original author: Devansh (https://github.com/devansh0703)
Fixes https://github.com/google-deepmind/mujoco/issues/3364

PiperOrigin-RevId: 952789284
Change-Id: If924f7160dd16c0cc88170d80e6e605da0fe2e04
2026-07-23 09:02:21 -07:00
Michael Moss b04a18a00a Fix backslash escaping in KOKORO_GFILE_DIR on Windows.
This var was missing from the "clean up" step for all the path vars, causing
the cmake cache lookups to silently fail due to path mismatch.

PiperOrigin-RevId: 952410036
Change-Id: I5c542e821317497e899de95e5c62d76f88836e60
2026-07-22 16:59:14 -07:00
Copybara-Service c214e81627 Merge pull request #3418 from winklemad:fix/minimize-xtol-accepted-candidate
PiperOrigin-RevId: 952380184
Change-Id: Ied4ab1bfc91dbb55dbd9d2f2e64ab2288513c50e
2026-07-22 15:57:46 -07:00
Michael Moss 3429373b96 Rollback filament dependency updates and patches.
PiperOrigin-RevId: 952196997
Change-Id: I0c4284823bb642e847bc73d4732bcce6a72455c8
2026-07-22 10:23:50 -07:00
Michael Moss c0d1c399af Update patch context in filament-allow-clang-windows.patch.
PiperOrigin-RevId: 952161543
Change-Id: Ia832f692f1f42e905a6cf66365731d5714297db9
2026-07-22 09:19:02 -07:00
Haroon Qureshi e1f6953efa Remove ModelObjects as a dependency on ModelDecorations.
Also allow users to Clear() the decorations explicitly.

PiperOrigin-RevId: 952152025
Change-Id: Ieb21d59986b127b4646c8c5721d33920d14dff85
2026-07-22 09:01:26 -07:00
Sam Haves 1a5af23558 Add <stem>/model.xml search path to mjz_decoder.
PiperOrigin-RevId: 952128127
Change-Id: I8a514297d84026a6028b2416e43df9b5a2a92bbb
2026-07-22 08:11:56 -07:00
Haroon Qureshi b6ab11dc6b Rename LightManager to ModelLights and RenderableManager to ModelRenderables.
This better reflects the purpose of these classes.

PiperOrigin-RevId: 952123609
Change-Id: Ib14c54c3d9b137258ebc706590aca3b2e80015fe
2026-07-22 08:03:32 -07:00
Michael Moss 8c0a73482c Remove unversioned tarball fallback from FindOrFetch.cmake.
PiperOrigin-RevId: 952098246
Change-Id: Id3030fde3045223857711b3e8cce7e671490f8c7
2026-07-22 07:08:04 -07:00
Haroon Qureshi ed7ba6027f Move SceneDecorator to support module.
Also rename it to ModelDecorations.

PiperOrigin-RevId: 952088857
Change-Id: I476d616ec950962f781614e39b75d3d59fdcfcd1
2026-07-22 06:48:33 -07:00
Haroon Qureshi ba9a65031b Allow mesh data to be reuploaded without having to recreate the mesh.
Splits mjrfMeshData into config+data parts.

PiperOrigin-RevId: 952042545
Change-Id: I19a572a0f591fa0d33bbc2c32b974efc075310f4
2026-07-22 04:56:30 -07:00
Google DeepMind d3166cb630 Fix cylinder bias stack overrun in XML parsing
PiperOrigin-RevId: 952016771
Change-Id: I49657d41ad96a6bd1f7f9d5e6b6491c5a229d244
2026-07-22 03:53:45 -07:00
Matija Kecman 0b1ed5b356 platform/ux: general C++ platform UX updates & spec adjustments.
* Enhances ImGui dialogs to support keyboard shortcuts (Enter/Escape) and filters.
* Adjusts GUI layouts for simulation speed and compiler settings.
* Exposes additional model fields in the XML spec generator.

PiperOrigin-RevId: 951988061
Change-Id: I4927c12a8882ba4e91e6098355ec2f5db35c2747
2026-07-22 02:46:30 -07:00
Michael Moss 782c00bc49 Update dependencies ahead of the 3.11.0 release.
PiperOrigin-RevId: 951974346
Change-Id: Ie2b7a357442705e7d37d824463f7feb120a212e7
2026-07-22 02:13:00 -07:00
Matija Kecman e0224c6440 studio: share ImGui and ImPlot contexts across python child extension modules.
Each pybind extension module holds its own copy of the ImGui/ImPlot globals (extension modules are loaded RTLD_LOCAL), so the viewer that owns the contexts must share the pointers explicitly. Without this, client plotting GUIs and user plotting scripts (e.g. the implot sample) crash on null context pointers.

PiperOrigin-RevId: 951917287
Change-Id: I639a173c2ae9f1af4feaf57aff7b5c81854b7393
2026-07-21 23:41:20 -07:00
winklemad 72c9f2af63 Fix least_squares xtol result 2026-07-22 08:17:25 +05:30
Copybara-Service 91bb075108 Merge pull request #3250 from gholmes829:fix/accumulate-inertia-com-frame-order
PiperOrigin-RevId: 951758696
Change-Id: I99f3502b15b84e2fffc58f4b608844148479ca3e
2026-07-21 16:21:08 -07:00
Yuval Tassa 2b30c6bc0f Update MuJoCo contributing guidelines regarding PR imports.
Updates CONTRIBUTING.md to suggest that contributors who do not require Git authorship attribution let maintainers know in the PR, which allows for faster direct incorporation of changes.

PiperOrigin-RevId: 951751097
Change-Id: I521f1ad1978987c71a90e85c1bed71392a07ee7b
2026-07-21 16:06:04 -07:00
Yuval Tassa a7e6114ed7 improve aspect ratios in embedded videos
PiperOrigin-RevId: 951714570
Change-Id: I71b3705d9bb7bceca7f9f7d69344acb4f8f91239
2026-07-21 14:57:26 -07:00
Sam Haves 1f1bfa9e4e Documentation pass for model editing, model encoding, and mjz.
PiperOrigin-RevId: 951665744
Change-Id: I1dfe3b40f451cca686431c263815039a9c38efc8
2026-07-21 13:27:00 -07:00
Yuval Tassa 259e6c4dc6 Fix MSVC ASan compilation by avoiding GCC/Clang specific stack instrumentation
PiperOrigin-RevId: 951656966
Change-Id: I51294e6a95c39f4037e8feb2aee45e69cb51beb0
2026-07-21 13:09:23 -07:00
gholmes829 0e1e0c7f96 Fix COM frame composition in mjCBody::AccumulateInertia 2026-07-21 15:02:14 -05:00
Yuval Tassa 8ccd2b6db5 Update changelog regarding Python free threading support.
Also fix #3231

PiperOrigin-RevId: 951614688
Change-Id: I7d2e6238c1d593efe289e0a9b72717b8dd9e42d0
2026-07-21 11:49:35 -07:00
Yuval Tassa 072e963fa0 Add SO3 transmission and native orientation actuator.
https://youtu.be/17XpwnqyCXs

New transmission type mjTRN_SO3: a relative orientation, targeting a ball
joint or a site+refsite pair. It is the first transmission with more than
one force output: its length is the norm of the expmap vector of the
relative rotation and its moment axes are the 3 rows of the
relative rotational Jacobian, without projecting onto per-actuator gears.

New force law mjGAIN_SO3/mjBIAS_SO3: a geodesic PD servo, force =
kp * log(q_current^-1 * q_target) - kv * velocity, exact for arbitrary axis
combinations with a unique equilibrium at every commanded orientation.
Error, moment rows and velocity all live in the child frame (joint or
site): the right-difference error is the gradient of the geodesic
potential in that frame. The parent-frame (left) error is not: driving
child-frame torques with it pumps energy at large angles, settling into
steady-spinning limit cycles (the SO3LargeAngleConvergence test). The
integrator variant stores the 3D orientation setpoint in act (actnum = 3,
re-anchored to a bounded representative at integration time). Exposed in
MJCF as <orientation joint=|site=+refsite= kp kv|dampratio>, or via
<general gaintype="so3" biastype="so3">.

The setpoint input has two charts: an expmap target (3 controls, default)
or a quaternion target (4 controls) -- <orientation input="quat">, the
first actuator with different input and output widths. The signature is
recorded in a new per-actuator field actuator_ctrlspec (mjtCtrlChart),
whose meaning is scoped by the gain type the way gain/bias parameters are;
ctrlnum is derived from it at compile time and remains the layout
authority. An explicit field rather than width inference or a prm slot:
width-as-chart cannot express same-width signatures (upcoming servo input
subsets), and prm slots are the input_mode pattern this stack retires.
The force law normalizes the commanded quaternion, making it scale- and
antipodally-invariant. The all-zero ctrl still maps to the identity via
mju_normalize4, but it is a degenerate point (a nudge of any component
commands a half-turn), so quat inputs reset to the identity quaternion:
new mj_resetCtrl sets neutral ctrl values (zero, except qw = 1), called
by mj_resetData and the viewers' Clear All. The quat chart is
restricted to dyntype 'none': integrating a quaternion setpoint linearly
is not meaningful on the manifold. New mjsActuator.ctrlspec field carries
the signature through the spec and XML round-trip.

Actuator sensors (actuatorpos/vel/frc) now report one value per force
output; dim = 3 on an SO3 actuator.

As the first actuator with nu != nactuator, this commit also makes the
viewers multi-input aware: the control sliders in simulate and studio,
which indexed per-actuator arrays by control index (out of bounds on
this model class), are generated per control and labeled with the
actuator name plus an input suffix ("orient/qw"), via the new
introspection helper mj_actuatorInputName -- the single source of truth
for input names, extended by each new multi-input type (quaternion
components are w-first: qw, qx, qy, qz). Slider ranges now honor a
defined ctrlrange even when ctrllimited is false: range is the UI hint,
limited is the clamp -- wrapped and expmap setpoints are unbounded but
still want finite sliders, while quat components are truly bounded.

The rotational demo model is orientation.xml under
test/engine/testdata/actuation/, upgraded to a three-way contrast:
per-axis wrapped servos vs an expmap-commanded vs a quat-commanded
orientation actuator, on identical checker-textured boxes. It is loaded
by the mixed-axis contrast and input-name tests, and doubles as the
viewer test model (slider groups of 3 independent, 3 grouped, 4 grouped).

PiperOrigin-RevId: 951607063
Change-Id: If235dba8e2f2ca72672e7c62531a27e967c6a373
2026-07-21 11:36:13 -07:00
Haroon Qureshi a8545ac7cc Improve flex rendering.
RenderableManager is responsible for rendering the "skinned" flexes
which represent the correct "final" look of a flex. This now includes
1D flexes which are rendered as a sequence of capsules (similar to
tendons).

SceneDecorator is responsible for rendering the debug (unskinned)
versions of flexes. This includes the vertices (small spheres for each
vertex), edges (thin cynlinders for each edge), and faces (triangles
for each face, including sublayers).

PiperOrigin-RevId: 951595046
Change-Id: Iebc6fd7a747a602813b6457333bd9fa5915e28d3
2026-07-21 11:15:37 -07:00
Copybara-Service 7bfa10e1e2 Merge pull request #3354 from Nas01010101:fix/ktx-classic-renderer-skip
PiperOrigin-RevId: 951520219
Change-Id: Ib6a1a8c553140e2e6c99055a579facf51e0d7f5a
2026-07-21 09:01:02 -07:00
Yuval Tassa 426cb5481d Fix sparse-path rotational Jacobian misalignment in mj_jacSum
PiperOrigin-RevId: 951341459
Change-Id: I18bc27765b3147a5eb520e3026317e9a5a2dfc30
2026-07-21 02:02:12 -07:00
Copybara-Service a1f38c8e6e Merge pull request #3396 from teerthsharma:topo/linear-island-scratch
PiperOrigin-RevId: 951110709
Change-Id: I0c9c96365a5667172c1d676026ab797b7f8e8137
2026-07-20 16:16:35 -07:00
teerthsharma 57faf5f63a Credit linear-memory island discovery
Signed-off-by: teerthsharma <teerths57@gmail.com>
2026-07-20 22:27:43 +05:30