newton.solvers.SolverMuJoCo#
- class newton.solvers.SolverMuJoCo(model, *, separate_worlds=None, njmax=None, njmax_nnz=None, nconmax=None, iterations=None, ls_iterations=None, ccd_iterations=None, sdf_iterations=None, sdf_initpoints=None, noslip_iterations=None, noslip_tolerance=None, solver=None, integrator=None, cone=None, jacobian=None, impratio=None, tolerance=None, ls_tolerance=None, ccd_tolerance=None, density=None, viscosity=None, wind=None, magnetic=None, use_mujoco_cpu=False, enable_multiccd=None, enable_sleeping=None, nvmax=None, sleep_tolerance=None, disable_contacts=None, disable_sensors=None, update_data_interval=None, save_to_mjcf=None, use_mujoco_contacts=True, use_speculative_contacts=False, include_sites=True, skip_visual_only_geoms=True, deterministic=None, strict_capacity=False, kinematic_switchable_roots=True)[source]#
Bases:
SolverBase,CouplingInterfaceThis solver provides an interface to simulate physics using the MuJoCo physics engine, optimized with GPU acceleration through mujoco_warp. It supports both MuJoCo and mujoco_warp backends, enabling efficient simulation of articulated systems with contacts and constraints.
Note
This solver requires mujoco_warp and its dependencies to be installed.
For installation instructions, see the mujoco_warp repository.
shape_collision_radiusfrom Newton models is not used by MuJoCo. Instead, MuJoCo computes bounding sphere radii (geom_rbound) internally based on the geometry definition.
- Joint support:
Supported joint types: PRISMATIC, REVOLUTE, BALL, FIXED, FREE, D6. DISTANCE and ROD joints are not supported.
joint_armature,joint_friction,joint_effort_limit,joint_limit_ke/joint_limit_kd,joint_target_ke/joint_target_kd,joint_target_mode, andjoint_fare supported.Equality constraints (CONNECT, WELD, JOINT) and mimic relationships between REVOLUTE, PRISMATIC, or D6 joints are supported.
joint_velocity_limitandjoint_enabledare not supported.
See Joint Feature Support for the full comparison across solvers.
Example
solver = newton.solvers.SolverMuJoCo(model) # simulation loop for i in range(100): solver.step(state_in, state_out, control, contacts, dt) state_in, state_out = state_out, state_in
Debugging#
To debug the SolverMuJoCo, you can save the MuJoCo model that is created from the
newton.Modelin the constructor of the SolverMuJoCo:solver = newton.solvers.SolverMuJoCo(model, save_to_mjcf="model.xml")
This will save the MuJoCo model as an MJCF file, which can be opened in the MuJoCo simulator.
It is also possible to visualize the simulation running in the SolverMuJoCo through MuJoCo’s own viewer. This may help to debug the simulation and see how the MuJoCo model looks like when it is created from the Newton model.
import newton solver = newton.solvers.SolverMuJoCo(model) for _ in range(num_frames): # step the solver solver.step(state_in, state_out, control, contacts, dt) state_in, state_out = state_out, state_in solver.render_mujoco_viewer()
- class CtrlSource(*values)#
Bases:
IntEnumControl source for MuJoCo actuators.
Determines where an actuator gets its control input from:
JOINT_TARGET: Maps from Newton’sjoint_target_q/joint_target_qdarrays.CTRL_DIRECT: Usescontrol.mujoco.ctrldirectly (for MuJoCo-native control)
- CTRL_DIRECT = 1#
- JOINT_TARGET = 0#
- class CtrlType(*values)#
Bases:
IntEnumControl type for MuJoCo actuators.
For
JOINT_TARGETmode, determines which target array to read from:POSITION: Maps fromjoint_target_q, syncs gains fromjoint_target_ke. ForPOSITION-only actuators, also syncs damping fromjoint_target_kd. ForPOSITION_VELOCITYmode, kd is handled by the separate velocity actuator.VELOCITY: Maps fromjoint_target_qd, syncs gains fromjoint_target_kdGENERAL: Used withCTRL_DIRECTmode for motor/general actuatorsDCMOTOR: Set by the MJCF importer andadd_actuator_dcmotor()for natively resolved DC-motor parameters. Use the helper or importer to populate the associated parameters. Runtime edits toactuator_gainprm,actuator_biasprm,actuator_dynprm, andactuator_forcerangeare ignored for these rows. Compiled MJCF and USD DC motors instead useGENERALwithactuator_gaintypeset to DC motor.
- DCMOTOR = 3#
- GENERAL = 2#
- POSITION = 0#
- VELOCITY = 1#
- class EqType(*values)#
Bases:
IntEnumMuJoCo equality constraint type.
- CONNECT = 0#
Constrains two bodies at a point (like a ball joint).
- JOINT = 2#
Constrains one scalar joint coordinate to a quartic polynomial of another.
- TENDON = 3#
Constrains one tendon length to a quartic polynomial of another, or to a constant offset.
- WELD = 1#
Welds two bodies together (like a fixed joint).
- class ObservableKind#
Bases:
ObservableKindStandard and MuJoCo-specific observable kinds.
Inherits all standard names from
SolverBase.ObservableKind. Backend support is reported bySolverMuJoCo.supported_observables.See Solver Observables for solver-specific kinds and backend support.
Experimental
Experimental feature. API, behavior, defaults, and supported use cases may change without prior notice.
- OVERFLOW = 'overflow'#
Per-world capacity-overflow bitmask for the most recent step; see MuJoCo overflow diagnostics.
- QFRC_ACTUATOR = 'qfrc_actuator'#
Actuator forces in Newton generalized-coordinate order.
- QFRC_BIAS = 'qfrc_bias'#
Coriolis, centrifugal and gravity forces
C(q, qd)in Newton generalized-coordinate order.
- QFRC_CONSTRAINT = 'qfrc_constraint'#
Constraint forces in Newton generalized-coordinate order, including DOF friction loss.
- QFRC_FRICTIONLOSS = 'qfrc_frictionloss'#
DOF friction-loss constraint forces in Newton generalized-coordinate order.
- class Observables#
Bases:
ObservablesStandard and MuJoCo-specific observable arrays.
When
use_mujoco_contacts=True, size contact storage usingSolverMuJoCo.get_max_contact_count(). Otherwise, use the collision pipeline’s contact storage.See Solver Observables for allocation, backend limitations, and examples.
Experimental
The solver observable API may change without prior notice.
- __init__()#
- overflow: wp.array[wp.int32] | None = None#
Per-world capacity-overflow bitmask of
SolverMuJoCo.OverflowBitsfor the latest step, shape(world_count + 1,).Entries follow the Newton world whose options each MuJoCo world uses. A single MuJoCo world reports in entry
0when world0owns bodies, also if it simulates global bodies too, and otherwise in the final entry, for global world-1, as in models built withoutbegin_world(). Separate MuJoCo worlds leave the final entry zero.
- qfrc_actuator: wp.array[wp.float32] | None = None#
Actuator forces [N or N·m], shape
(joint_dof_count,).
- qfrc_bias: wp.array[wp.float32] | None = None#
Coriolis, centrifugal and gravity forces from MuJoCo’s last force evaluation of the step [N or N·m], shape
(joint_dof_count,).That is the start of the step, except for RK4, where it is the last stage.
- qfrc_constraint: wp.array[wp.float32] | None = None#
Constraint forces [N or N·m], shape
(joint_dof_count,).From the same force evaluation as
qfrc_bias.
- qfrc_frictionloss: wp.array[wp.float32] | None = None#
DOF friction-loss forces [N or N·m], shape
(joint_dof_count,).Part of
qfrc_constraint;qfrc_constraint - qfrc_frictionlossis the constraint load on a DOF without its own friction. As in MuJoCo, the force opposes the DOF motion. From the same force evaluation asqfrc_bias.
- class OverflowBits(*values)#
Bases:
IntFlagBits of the per-world
Observables.overflowbitmask.Bits 0-15 carry MuJoCo Warp’s own
mujoco_warp.OverflowTypeflags (NEFC,NJMAX_NNZ,BROADPHASE, …). The members below are the bits Newton adds on top.See MuJoCo overflow diagnostics for allocation, interpretation, backend support, and shared-buffer attribution.
- CONTACT_PIPELINE = 65536#
The Newton collision pipeline generated more contacts than
rigid_contact_max.
- SOLVER_NCONMAX = 131072#
Newton contacts exceeded MuJoCo Warp’s
nconmaxcapacity.
- class SleepPolicy(*values)#
Bases:
IntEnumSleep policy for a MuJoCo kinematic tree.
- ALLOWED = 4#
Allow the tree to sleep.
- AUTO = 0#
Let the MuJoCo compiler choose whether the tree can sleep.
- INIT = 5#
Initialize the tree asleep.
- NEVER = 3#
Prevent the tree from sleeping.
- class TrnType(*values)#
Bases:
IntEnumTransmission type values for MuJoCo actuators.
- BODY = 4#
- JOINT = 0#
- JOINT_IN_PARENT = 1#
- SITE = 3#
- SLIDERCRANK = 5#
- TENDON = 2#
- UNDEFINED = -1#
- classmethod import_mujoco()#
Import the MuJoCo Warp dependencies and cache them as class variables.
- classmethod register_custom_attributes(builder)#
Declare custom attributes to be allocated on the Model object within the
mujoconamespace. Legacydof_passive_stiffnessanddof_springrefinputs are converted once intoModel.joint_stiffnessandModel.joint_rest_qduring finalization. Runtimedof_passive_stiffnessremains a deprecated alias to the core stiffness array. Runtimedof_springrefis a deprecated alias toModel.joint_rest_qwhen their layouts and values coincide and raises an error otherwise; see Passive spring migration. Custom attributes useCustomAttribute.usd_attribute_namewith themjc:prefix (e.g."mjc:condim") to leverage the MuJoCo USD schema where attributes are named"mjc:attr"rather than"newton:mujoco:attr".
- __init__(model, *, separate_worlds=None, njmax=None, njmax_nnz=None, nconmax=None, iterations=None, ls_iterations=None, ccd_iterations=None, sdf_iterations=None, sdf_initpoints=None, noslip_iterations=None, noslip_tolerance=None, solver=None, integrator=None, cone=None, jacobian=None, impratio=None, tolerance=None, ls_tolerance=None, ccd_tolerance=None, density=None, viscosity=None, wind=None, magnetic=None, use_mujoco_cpu=False, enable_multiccd=None, enable_sleeping=None, nvmax=None, sleep_tolerance=None, disable_contacts=None, disable_sensors=None, update_data_interval=None, save_to_mjcf=None, use_mujoco_contacts=True, use_speculative_contacts=False, include_sites=True, skip_visual_only_geoms=True, deterministic=None, strict_capacity=False, kinematic_switchable_roots=True)#
Solver options (e.g.,
impratio) follow this resolution priority:Constructor argument - If provided, same value is used for all worlds.
Newton model custom attribute (
model.mujoco.<option>) - Supports per-world values.MuJoCo default - Used if neither of the above is set.
For imported MJCF position drives using joint-target control and
dampratio, construction writes resolved damping into zero entries ofmodel.joint_target_kdand consumes the placeholders inmodel.mujoco.actuator_biasprm. These coefficients use the initial physical inertia, armature, and position gain; later inertia edits or solver reconstruction do not recompute them. Updatejoint_target_kdexplicitly to change damping. Other consumers of the same model see the initialized values. Direct actuators keep theirdampratio(a positivebiasprm[2]), which is resolved from each world’s current physical inertia and position gain whenever model changes refresh MuJoCo’s constants. Withuse_mujoco_cpu=True, only the template world is simulated whenseparate_worlds=True.- Parameters:
model (Model) – The model to be simulated.
separate_worlds (bool | None) – If True, each Newton world is mapped to a separate MuJoCo world. Defaults to not use_mujoco_cpu.
njmax (int | None) – Maximum number of constraints per world. If None, a default value is estimated automatically. An explicit value is preserved unless it cannot hold the initial MuJoCo constraints; in that case, it is increased with a warning.
njmax_nnz (int | None) – Sparse constraint Jacobian nonzero capacity per world. If provided, must be non-negative and large enough for the initial sparse Jacobian. If None, derived from the model’s constraint counts and njmax, plus friction nonzeros for every DOF and tendon.
nconmax (int | None) – Number of contact points per world. If None, a default value is estimated automatically. An explicit value is preserved unless it cannot hold the initial MuJoCo contacts; in that case, it is increased with a warning. With
use_mujoco_cpu=True, this limits contact export rather than simulation; excess runtime contacts are omitted from the export with a warning.iterations (int | None) – Number of solver iterations. If None, uses model custom attribute or MuJoCo’s default (100).
ls_iterations (int | None) – Number of line search iterations for the solver. If None, uses model custom attribute or MuJoCo’s default (50).
ccd_iterations (int | None) – Maximum CCD iterations. If None, uses model custom attribute or MuJoCo’s default (35).
sdf_iterations (int | None) – Maximum SDF iterations. If None, uses model custom attribute or MuJoCo’s default (10).
sdf_initpoints (int | None) – Number of SDF initialization points. If None, uses model custom attribute or MuJoCo’s default (40).
noslip_iterations (int | None) – Maximum noslip solver iterations; 0 disables the noslip solver. If None, uses model custom attribute or MuJoCo’s default (0).
noslip_tolerance (float | None) – Noslip solver tolerance for early termination. If None, uses model custom attribute or MuJoCo’s default (1e-6).
solver (int | str | None) – Solver type. Can be “cg” or “newton”, or their corresponding MuJoCo integer constants. If None, uses model custom attribute or Newton’s default (“newton”).
integrator (int | str | None) – Integrator type. Can be “euler”, “rk4”, “implicit”, “implicitfast”, or “discrete”, or their corresponding MuJoCo integer constants. If None, uses model custom attribute or Newton’s default (“implicitfast”).
cone (int | str | None) – The type of contact friction cone. Can be “pyramidal”, “elliptic”, or their corresponding MuJoCo integer constants. If None, uses model custom attribute or Newton’s default (“pyramidal”).
jacobian (int | str | None) – Jacobian computation method. Can be “dense”, “sparse”, or “auto”, or their corresponding MuJoCo integer constants. If None, uses model custom attribute or MuJoCo’s default (“auto”).
impratio (float | None) – Frictional-to-normal constraint impedance ratio. If None, uses model custom attribute or MuJoCo’s default (1.0).
tolerance (float | None) – Solver tolerance for early termination. If None, uses model custom attribute or MuJoCo’s default (1e-8).
ls_tolerance (float | None) – Line search tolerance for early termination. If None, uses model custom attribute or MuJoCo’s default (0.01).
ccd_tolerance (float | None) – Continuous collision detection tolerance. If None, uses model custom attribute or MuJoCo’s default (1e-6).
density (float | None) – Medium density for lift and drag forces. If None, uses model custom attribute or MuJoCo’s default (0.0).
viscosity (float | None) – Medium viscosity for lift and drag forces. If None, uses model custom attribute or MuJoCo’s default (0.0).
wind (tuple | None) – Wind velocity vector (x, y, z) for lift and drag forces. If None, uses model custom attribute or MuJoCo’s default (0, 0, 0).
magnetic (tuple | None) – Global magnetic flux vector (x, y, z). If None, uses model custom attribute or MuJoCo’s default (0, -0.5, 0).
use_mujoco_cpu (bool) – If True, use MuJoCo’s C implementation instead of mujoco_warp.
enable_multiccd (bool | None) – If True, enable multi-CCD contact generation (up to 4 contact points per geom pair instead of 1). If False, disable it. If None, use the model custom attribute or disable it by default. Note: geom pairs where either geom has
margin > 0always produce a single contact regardless of this flag. With the MuJoCo Warp backend anduse_mujoco_contacts=True, all geom and pair margins are zeroed when the model has box geoms and NATIVECCD (the default) or multi-CCD is enabled, or has mesh geoms and multi-CCD is enabled; see Margin zeroing in the MuJoCo solver docs. The CPU backend keeps them.enable_sleeping (bool | None) – Whether to enable MuJoCo Warp’s sleeping optimization. If None, uses the model custom attribute or defaults to False. Sleeping requires the GPU backend, the Newton solver, MuJoCo contact handling, island detection, and a non-RK4 integrator.
nvmax (int | None) – Maximum number of active degrees of freedom per world when sleeping is enabled. Must accommodate every initially awake degree of freedom. If None, allocates space for every degree of freedom, which is safe but provides no compact-solver memory savings.
sleep_tolerance (float | None) – Sleep velocity tolerance. If None, uses model custom attribute or MuJoCo default (0.001).
disable_contacts (bool | None) – If True, disable contact computation in MuJoCo. If False, enable it. If None, use the model custom attribute or enable it by default.
disable_sensors (bool | None) – If True, disable sensor computation in MuJoCo. If False, enable it. If None, use the model custom attribute or enable it by default.
body_qddandbody_parent_fare still computed on either backend when requested through solver observables or legacy output-state fields.update_data_interval (int | None) –
Frequency (in simulation steps) at which to update the MuJoCo Data object from the Newton state. If 0, Data is never updated after initialization. If None, Data is updated on every step.
Deprecated since version 1.8: Passing any value is deprecated; Data will always be updated on every step.
save_to_mjcf (str | None) – Optional path to save the generated MJCF model file.
use_mujoco_contacts (bool) – If True, use MuJoCo collision detection. If False, use Newton-generated contacts supplied to
step(). Must be True withuse_mujoco_cpu=True.use_speculative_contacts (bool) –
Add frictionless normal constraints for separated Newton contact candidates, bounding closing velocity by clearance divided by the physics timestep. Requires
use_mujoco_contacts=False, the MuJoCo Warp backend, and Euler or implicitfast integration. Enable velocity expansion innewton.CollisionPipelineand pass its contacts tostep(). This mitigates tunneling; it is not continuous collision detection and does not make penetrating contacts rigid.Experimental
The
use_speculative_contacts=Truemode may change without prior notice.include_sites (bool) – If
True(default), Newton shapes marked withShapeFlags.SITEare exported as MuJoCo sites. Sites are non-colliding reference points used for sensor attachment, debugging, or as frames of reference. IfFalse, sites are skipped during export. Defaults toTrue.skip_visual_only_geoms (bool) – If
True(default), geometries used only for visualization (i.e. not involved in collision) are excluded from the exported MuJoCo spec. This avoids mismatches with models that use explicit<contact>definitions for collision geometry.deterministic (DeterministicMode | None) – Deterministic mode for MuJoCo Warp solver kernels. Pass a
warp.DeterministicMode, orNoneto inheritwp.config.deterministic. Modes other thanNOT_GUARANTEEDcurrently fail to compile MuJoCo Warp’s kernels with Warp 1.19; the CPU backend (use_mujoco_cpu=True) is always deterministic. See Deterministic Simulation.strict_capacity (bool) – If
True, raise aRuntimeErrorwhen the Newton contact pipeline buffer capacity (contacts.rigid_contact_max) exceeds MuJoCo Warp’s buffer capacity (nconmax); the check runs at the start of every step and requires no GPU sync. This is a capacity mismatch, not evidence that contacts were actually dropped — the two buffers are sized by independent heuristics and routinely disagree even on scenes that never overflow — so it is not reported by default (False). Runtime overflow (contacts actually dropped during a step) is always reported GPU-side via awp.printfmessage; to detect it in Python without a GPU sync, requestObservableKind.OVERFLOWviaobservables()and check the bitmask after each step.kinematic_switchable_roots (bool) – If
True, every movable root gets an inactive weld so it can be switched to kinematic at runtime. IfFalse, only roots that are kinematic in some world at construction get one, which keeps the compiled MuJoCo model free of unused welds.
- close_mujoco_viewer()#
Close the MuJoCo viewer if it exists.
- coupling_eval_effective_mass(endpoint_kind, endpoint_index, endpoint_local_pos, out)#
Evaluate MuJoCo articulated effective masses for coupling endpoints.
- coupling_eval_effective_mass_block(endpoint_kind, endpoint_index, endpoint_local_pos, out_mass, out_inertia=None)#
Evaluate MuJoCo articulated effective mass and inertia blocks.
- coupling_eval_gravity_acceleration(out_body_acceleration, out_particle_acceleration)#
Evaluate MuJoCo’s internally applied gravity acceleration for coupling.
- get_max_contact_count()#
Return the configured rigid contact export capacity.
With
use_mujoco_cpu=True, this is the resolvednconmax. Excess runtime contacts are omitted from export with a warning.
- notify_model_changed(flags)#
- observables(kinds, *, contacts=None, requires_grad=None)#
Allocate solver observables with compatible contact storage.
Supply
contactswhen requesting contact-indexed fields; their capacities size the contact arrays.See
SolverBase.observables()for the shared allocation contract and errors, and Solver Observables for usage and native collision setup.- Raises:
ValueError – If MuJoCo’s contact export capacity exceeds the rigid contact capacity of
contacts.
- render_mujoco_viewer(show_left_ui=True, show_right_ui=True, show_contact_points=True, show_contact_forces=False, show_transparent_geoms=True)#
Create and synchronize the MuJoCo viewer. The viewer will be created if it is not already open.
Note
The MuJoCo viewer only supports rendering Newton models with a single world, unless
use_mujoco_cpuisTrueor the solver was initialized withseparate_worldsset toFalse.The MuJoCo viewer is only meant as a debugging tool. It shows the geoms compiled at construction, so it rejects models with body variants.
- Parameters:
- Raises:
NotImplementedError – If the model has body variants.
- reset(state, world_mask=None, flags=None)#
Reset joint state to model defaults and clear MuJoCo’s internal buffers.
MuJoCo carries solver state (acceleration warm-start, actuator activations) and applied-force inputs across
step()calls. After a divergence (e.g. NaNs), these buffers can poison the next step even once the joint state has been reset, becausestep()warm-starts from them. This method therefore always zeros, per world,qacc_warmstart,qfrc_applied,xfrc_applied,actandctrl. (qaccis left alone: the solver overwrites it fromqacc_warmstartat the start of every step.)In addition, the requested entries of the Newton
Stateare reset to the model defaults (model.joint_q/model.joint_qd) for the selected worlds, controlled by flags:Because MuJoCo is a reduced-coordinate solver,
state.body_q/state.body_qdare derived from the joint coordinates by forward kinematics on the nextstep(); the correspondingBODY_Q/BODY_QD(and particle) flags are not actionable here and are ignored.qpos/qvelare normally synced from the resetstateat the start of the nextstep(). When the deprecatedupdate_data_intervalis not 1, that per-step sync is disabled or sparse, so the reset joint coordinates are pushed intoqpos/qvelimmediately for the selected worlds. When sleeping is enabled, reset synchronizes immediately, rebuilds MuJoCo Warp’s cached position- and velocity-dependent data, and restores the initial sleep state in the selected worlds.- Parameters:
state (newton.State) – The simulation state to reset (modified in place).
world_mask (wp.array[wp.bool] | None) – Optional boolean mask of shape
(world_count + 1,)selecting which worlds to reset. The final entry represents global world-1and is a no-op because MuJoCo does not support global dynamic objects. IfNone, all worlds are reset.flags (StateFlags | int | None) – Optional
StateFlagsbitmask controlling which joint-state quantities are reset. IfNone, all are reset. The internal MuJoCo buffers are always cleared regardless.
- step(state_in, state_out, control, contacts, dt, *, observables=None)#
Advance the simulation by one timestep.
Follows a three-phase push-integrate-pull cycle:
Push — transfer
state_inandcontrolto MuJoCo’s working data. Whenuse_mujoco_contacts=False,contactsare also converted and fed to MuJoCo Warp before the integrator runs.Integrate — run MuJoCo (CPU) or MuJoCo Warp (GPU) forward by
dtseconds.Pull — populate
state_outfrom the integrated MuJoCo data. RequestObservableKind.CONTACT_Fto export contact geometry and forces into the supplied contacts and observables.
Overflow detection — capacity overflows (contacts dropped, constraint buffer exceeded, broadphase clipped) are reported through
Observables.overflow, a per-worldint32bitmask. Allocate it withobservables()usingObservableKind.OVERFLOWand pass the container to this method, then read the bitmask after each step (or afterwarp.capture_launch()when using CUDA graphs). The request is only supported with MuJoCo Warp (use_mujoco_cpu=False):observables = solver.observables({solver.ObservableKind.OVERFLOW}) solver.step(state_in, state_out, control, contacts, dt, observables=observables) overflow = observables.overflow.numpy() if overflow[0] & newton.solvers.SolverMuJoCo.OverflowBits.SOLVER_NCONMAX: # runtime contacts exceeded nconmax — increase nconmax ...
Bits 0-15 carry MuJoCo Warp’s own
mujoco_warp.OverflowTypeflags (NEFC,NJMAX_NNZ,BROADPHASE,NVMAX, …). The bits Newton adds areSolverMuJoCo.OverflowBits.CONTACT_PIPELINE, set when the Newton collision pipeline dropped contacts beyondrigid_contact_max, andSolverMuJoCo.OverflowBits.SOLVER_NCONMAX, set when runtime contacts exceedednconmax. The bitmask is reset at every step so it always reflects the current step only. Steps that are not passed the container leave it unchanged.See MuJoCo overflow diagnostics for the bit layout, public flag names, and shared-buffer attribution.
- Parameters:
state_in (newton.State) – Input state for this step.
state_out (newton.State) – Output state written by this step.
control (Control) – Joint targets and feedforward forces.
contacts (Contacts | None) – Contact storage. MuJoCo Warp consumes Newton collision input when
use_mujoco_contacts=False. With MuJoCo collision detection, supply output storage whenCONTACT_Fis requested.dt (float) – Timestep in seconds.
observables (Observables | None) – Optional solver observable arrays allocated by
observables().
- update_contacts(contacts, state=None)#
Update contact geometry and optional legacy force storage from MuJoCo.
Geometry-only export remains supported when
contacts.forceisNone.Deprecated since version 1.7: Exporting
contacts.forceis deprecated. RequestCONTACT_Fand pass the resulting container tostep()instead. Geometry-only export is not deprecated.
- SUPPORTED_OBSERVABLES: ClassVar[frozenset[str]] = frozenset({'body_parent_f', 'body_qdd', 'contact_f', 'overflow', 'qfrc_actuator', 'qfrc_bias', 'qfrc_constraint', 'qfrc_frictionloss'})#
Names of observables supported by this solver class.
Entries are string identifiers, such as
ObservableKind.BODY_QDD. Querysupported_observablesfor the capabilities of an instance.
- body_free_qd_start: wp.array[wp.int32] | None#
Per-body mapping to the free-joint qd_start index (or -1 if not free).
- connect_constraint_X_rel: wp.array2d[wp.transform] | None#
Relative body pose
inv(X_body2) * X_body1at the reference pose per MuJoCo CONNECT row, shape[world_count, neq].
- enable_sleeping#
Whether MuJoCo Warp sleeping is enabled.
- has_jnt_connect_constraints: bool#
Whether the model contains CONNECT constraints synthesized from loop-closure joints (revolute or ball).
- jnt_connect_hinge_side: wp.array2d[wp.int32] | None#
Side (
-1or+1) along the hinge axis of revolute loop-joint CONNECT rows,0otherwise, shape[world_count, neq].
- mjc_actuator_ctrl_source: wp.array[wp.int32] | None#
Control source for each MuJoCo actuator.
Values: 0=JOINT_TARGET (uses joint_target_q/joint_target_qd), 1=CTRL_DIRECT (uses mujoco.ctrl) Shape [nu], dtype int32.
- mjc_actuator_to_newton_ball_jnt: wp.array[wp.int32] | None#
Per-actuator template-world Newton joint index for BALL-joint actuators,
-1otherwise.The control kernel uses this to read the current world’s child-anchor rotation from
joint_X_c[world * joints_per_world + jnt % joints_per_world]. Shape[nu], dtypeint32.
- mjc_actuator_to_newton_idx: wp.array[wp.int32] | None#
Mapping from MuJoCo actuator to Newton index.
For JOINT_TARGET: sign-encoded DOF index (>=0: position, -1: unmapped, <=-2: velocity with -(idx+2)) For CTRL_DIRECT: MJCF-order index into control.mujoco.ctrl array
Shape [nu], dtype int32.
- mjc_actuator_to_newton_target_q_idx: wp.array[wp.int32] | None#
Per-actuator coordinate lookup for target conversion.
For position actuators, entries index
Control.joint_target_qusingModel.joint_target_q_start. For BALL-joint velocity actuators, entries index the current quaternion inState.joint_qusingModel.joint_q_start, so the target velocity can be rotated into MuJoCo’s current ball-joint frame.-1means unused. Note that the BALL velocity case reuses this existing target-q lookup slot. Shape[nu], dtypeint32.
- mjc_actuator_to_target_q_axis_idx: wp.array[wp.int32] | None#
Angular-axis selector (
0/1/2) for BALL-joint position and velocity actuators,-1otherwise. Shape[nu].
- mjc_body_to_newton: wp.array2d[wp.int32] | None#
Mapping from MuJoCo [world, body] to Newton body index. Shape [nworld, nbody], dtype int32.
- mjc_dof_to_newton_dof: wp.array2d[wp.int32] | None#
Mapping from MuJoCo [world, dof] to Newton DOF index. Shape [nworld, nv], dtype int32.
- mjc_eq_to_newton_eq: wp.array2d[wp.int32] | None#
Mapping from MuJoCo [world, eq] to Newton equality constraint index.
Corresponds to the equality constraints that are created in MuJoCo from Newton’s equality constraints. A value of -1 indicates the entry is unmapped – the MuJoCo constraint was synthesized from a loop-closure joint (CONNECT or WELD) rather than from an explicit Newton equality constraint. For CONNECT-only entries see
mjc_eq_to_newton_jnt.Shape [nworld, neq], dtype int32.
- mjc_eq_to_newton_jnt: wp.array2d[wp.int32] | None#
Mapping from MuJoCo [world, eq] to Newton joint index for CONNECT constraints only.
Corresponds to the CONNECT equality constraints synthesized from loop-closure joints (revolute or ball) that have no associated articulation (
joint_articulation == -1). WELD constraints (from FIXED loop joints) are excluded — theireq_datais managed entirely by MuJoCo and must not be overwritten by the CONNECT anchor kernels. A value of -1 indicates an unmapped entry (either an explicit Newton equality constraint or a WELD).Shape [nworld, neq], dtype int32.
- mjc_eq_to_newton_joint_mimic: wp.array2d[wp.int32] | None#
Mapping from MuJoCo [world, eq] to Newton mimic follower joint index.
Corresponds to equality constraints created from joint-owned mimic metadata. A value of -1 indicates an unmapped equality constraint.
Shape [nworld, neq], dtype int32.
- mjc_eq_to_newton_mimic: wp.array2d[wp.int32] | None#
Mapping from MuJoCo [world, eq] to Newton mimic constraint index.
Corresponds to the equality constraints that are created in MuJoCo from Newton’s mimic constraints. A value of -1 indicates that the MuJoCo equality constraint is not associated with a Newton mimic constraint.
Shape [nworld, neq], dtype int32.
- mjc_geom_to_newton_shape: wp.array2d[wp.int32] | None#
Mapping from MuJoCo [world, geom] to Newton shape index. Shape [nworld, ngeom], dtype int32.
- mjc_jnt_to_newton_dof: wp.array2d[wp.int32] | None#
Mapping from MuJoCo [world, joint] to Newton DOF index. Shape [nworld, njnt], dtype int32.
- mjc_jnt_to_newton_jnt: wp.array2d[wp.int32] | None#
Mapping from MuJoCo [world, joint] to Newton joint index. Shape [nworld, njnt], dtype int32.
- mjc_mocap_to_newton_jnt: wp.array2d[wp.int32] | None#
Mapping from MuJoCo [world, mocap] to Newton joint index. Shape [nworld, nmocap], dtype int32.
- mjc_tendon_to_newton_tendon: wp.array2d[wp.int32] | None#
Mapping from MuJoCo [world, tendon] to Newton tendon index.
Shape [nworld, ntendon], dtype int32.
- newton_dof_to_body: wp.array[wp.int32] | None#
Mapping from Newton DOF index to child body index. Shape [joint_dof_count], dtype int32.
- newton_shape_to_mjc_geom: wp.array[wp.int32] | None#
Inverse mapping from Newton shape index to MuJoCo geom index. Only created when use_mujoco_contacts=False. Shape [nshape], dtype int32.
- nvmax#
Maximum number of active degrees of freedom allocated per world.
- property supported_observables#
Return observables available for the configured MuJoCo backend.
See Solver Observables for backend limitations.