Implementation:Google deepmind Mujoco MJWarp Util Misc
| Knowledge Sources | |
|---|---|
| Domains | Physics_Simulation, GPU_Computing, NVIDIA_Warp |
| Last Updated | 2026-02-15 04:00 GMT |
Overview
MJWarp Util Misc provides miscellaneous utility functions including Halton sequences, tendon wrapping geometry, muscle dynamics, and point-in-geom testing.
Description
This module collects miscellaneous GPU-compatible utility functions used by various MJWarp subsystems. It includes the Halton quasi-random sequence generator (used for SDF sampling), 2D line segment intersection testing, circle arc length computation, tendon wrapping around cylinders and spheres (wrap, wrap_circle, wrap_inside), muscle gain/bias/dynamics functions for musculotendon actuators, a sigmoid function for smooth muscle activation dynamics, and a point-in-geometry test (inside_geom) for all standard geometry types.
Usage
Called by multiple subsystems: the Halton function is used in SDF collision sampling and benchmarking, wrapping functions are used by the tendon system, muscle functions support musculotendon actuator computation, and inside_geom is used by sensor evaluation.
Code Reference
Source Location
- Repository: Google_deepmind_Mujoco
- File: mjx/mujoco/mjx/third_party/mujoco_warp/_src/util_misc.py
- Lines: 1-632
Key Functions
# Quasi-random sampling
def halton(index: int, base: int) -> float
# 2D geometry
def is_intersect(p1, p2, p3, p4) -> bool
# Tendon wrapping
def length_circle(p0, p1, ind, radius) -> float
def wrap_circle(end, side, radius) -> Tuple[float, wp.vec2, wp.vec2]
def wrap_inside(...)
def wrap(...)
# Muscle model
def muscle_gain_length(length, lmin, lmax) -> float
def muscle_gain(len, vel, lengthrange, acc0, prm) -> float
def muscle_bias(len, lengthrange, acc0, prm) -> float
def muscle_dynamics(control, activation, prm) -> float
def muscle_dynamics_timescale(dctrl, tau_act, tau_deact, smooth_width) -> float
# Point-in-geometry test
def inside_geom(pos, mat, size, geomtype, point) -> bool
Import
from mujoco.mjx.third_party.mujoco_warp._src.util_misc import halton
from mujoco.mjx.third_party.mujoco_warp._src.util_misc import wrap
from mujoco.mjx.third_party.mujoco_warp._src.util_misc import muscle_gain
from mujoco.mjx.third_party.mujoco_warp._src.util_misc import inside_geom
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| index | int | No | Sequence index for Halton generator |
| base | int | No | Base for Halton sequence (prime number) |
| pos | wp.vec3 | No | Geometry position for inside_geom test |
| mat | wp.mat33 | No | Geometry rotation for inside_geom test |
| size | wp.vec3 | No | Geometry size for inside_geom test |
| geomtype | int | No | Geometry type for inside_geom test |
| point | wp.vec3 | No | Query point for inside_geom test |
Outputs
| Name | Type | Description |
|---|---|---|
| result | float/bool | Halton value, muscle force, or containment boolean |