Skip to content

Types

Simulation and environment state types are NamedTuple subclasses, which gives automatic JAX pytree registration for jax.jit and jax.vmap. RenderConfig is a standard Python dataclass because rendering runs outside the JIT-compiled simulation.

Batching model: for a fixed morphology, SimState is batched while topology, constants, and actuator mappings can be shared. When morphology varies, its material and actuator data may also vary across the batch; see the dense-grid guide.


The evolving state passed through every simulation step. Each step returns a new state; the NamedTuple is immutable. Vmapped across population during training.

FieldShapedtypeDescription
positions(n_points, 2)float32Current point positions in world space (x, y)
velocities(n_points, 2)float32Current point velocities
positions_last(n_points, 2)float32Positions from the previous timestep, used by the integrator
velocities_true(n_points, 2)float32Finite-difference velocities, used for observation and reward
masses(n_points, 2)float32Per-point mass (broadcast across x/y)
fixed(n_points, 2)boolWhether each point is pinned (zero velocity applied)
point_mask(n_points,)boolActive point mask; padded points are False
spring_rest_length(n_springs,)float32Current rest length used by the spring force computation
spring_rest_length_goal(n_springs,)float32Target rest length that actuators drive toward
spring_init_rest_length(n_springs,)float32Rest length at spawn time; reference for deformation measurement
spring_const(n_springs,)float32Spring stiffness coefficient
spring_mask(n_springs,)boolActive spring mask; padded springs are False
rigid_spring_mask(n_springs,)boolTrue for springs eligible for Phase 2 PBD. Current builders mark RIGID springs and FIXED springs that remain in dynamic mixed objects.
external_forces(n_points, 2)float32Per-point external forces applied before integration
tangential_deformation(n_points, 2)float32Optional tangential memory for non-slope static friction models
friction_anchor(n_points, 2)float32Optional world-space PBD anchor for non-slope terrain friction
friction_anchor_active(n_points,)boolActive mask for friction anchors
friction_anchor_no_contact_count(n_points,)int32Persistence counter for friction anchors
static_manifold_*variesmixedLegacy static-contact memory fields; slope manifold behavior is inactive in the stable boundary

These are constructed once per world and can be shared across rollouts with the same morphology.

Scalar hyperparameters that govern the simulation.

FielddtypeDescription
dtfloatTimestep duration in seconds
gravityfloatGravitational acceleration (positive = downward)
viscous_dragfloatLinear drag coefficient applied to all velocities
collision_const_groundfloatImpulse strength for robot-ground collisions
collision_const_objfloatImpulse strength for robot-object collisions
collision_vel_dampingfloatVelocity damping applied on collision contact
ground_vel_dampingfloatGround-plane normal damping extension
collision_base_distfloatMinimum separation distance before collision response
dynamic_friction_constfloatFriction coefficient for dynamic contacts
friction_constfloatObject-object friction constant (default 1200)
ground_friction_constfloatGround friction constant (default 10)
actuator_convergencefloatRate at which spring rest length converges toward goal
integratorintIntegration scheme: 0 = RK4, 1 = symplectic Euler
static_friction_constfloatOpt-in non-slope terrain stiction coefficient
terrain_stiction_stiffnessfloatOpt-in non-slope terrain stiction stiffness
ground_stiction_stiffnessfloatOpt-in ground-plane stiction stiffness
floor_static_friction_constfloatOpt-in flat floor stiction coefficient independent of terrain stiction
floor_stiction_stiffnessfloatOpt-in flat floor stiction stiffness
ground_static_friction_constfloatOpt-in ground-plane static-friction coefficient
terrain_stiction_scopeintScope selector for non-slope static terrain stiction; slope-only scope is currently inert
friction_modelintCompatibility selector for projected friction memory on non-slope stiction contacts
friction_constraint_modeintOptional terrain PBD anchor mode for non-slope stiction contacts
slope_contact_*mixedCompatibility fields retained as no-ops for geometry-only experimental slopes
slope_grip_*mixedCompatibility fields retained as no-ops for geometry-only experimental slopes

Use default_physics_constants() to get the standard configuration. Flat ground and flat static-terrain friction are stable. Experimental slope terrain does not use tangential friction/support fields.

The fixed connectivity graph of the spring-mass system. Shared across batch.

FieldShapedtypeDescription
a_idx(n_springs,)int32Index of the first endpoint point for each spring
b_idx(n_springs,)int32Index of the second endpoint point for each spring

Maps actuator cells to the springs they control. Shared across batch.

FieldShapedtypeDescription
cell_spring_indices(n_actuator_cells, 2)int32Indices of the two springs controlled by each actuator cell
spring_act_count(n_springs,)float32Number of actuator cells sharing each spring (for averaging)
actuated_spring_mask(n_springs,)boolTrue for springs that belong to at least one actuator cell

Extended actuator bookkeeping that separates horizontal and vertical springs, used by controllers that apply axis-aligned actions.

FieldShapedtypeDescription
h_spring_pairs(H*W, 2)int32Horizontal spring pair indices for every grid cell
v_spring_pairs(H*W, 2)int32Vertical spring pair indices for every grid cell
h_compact_cell_indices(N_compact_max,)int32Indices of cells with active horizontal actuators
v_compact_cell_indices(N_compact_max,)int32Indices of cells with active vertical actuators
h_compact_spring_pairs(N_compact_max, 2)int32Horizontal spring pairs for compact actuator cells only
v_compact_spring_pairs(N_compact_max, 2)int32Vertical spring pairs for compact actuator cells only
h_compact_count()int32Number of active horizontal actuator cells
v_compact_count()int32Number of active vertical actuator cells
actuated_spring_mask(n_springs,)boolTrue for springs controlled by any actuator
spring_act_count(n_springs,)float32Actuator cell share count per spring

Precomputed dynamic collision structures for robot-terrain and robot-robot contacts. Built once from the world geometry and reused each step.

FieldShapedtypeDescription
boxel_corners(n_boxels, 4)int32Corner point indices for each collision boxel
boxel_edge_a(n_boxels, 4)int32First endpoint index of each boxel edge
boxel_edge_b(n_boxels, 4)int32Second endpoint index of each boxel edge
boxel_mask(n_boxels,)boolActive boxel mask
surface_edge_mask(n_boxels, 4)boolTrue for edges that face outward (participate in contact)
boxel_object_id(n_boxels,)int32Object identifier for each boxel
boxel_is_robot(n_boxels,)boolTrue if the boxel belongs to the robot
boxel_world_vy(n_boxels,)int32Grid row of the boxel in world space
boxel_world_vx(n_boxels,)int32Grid column of the boxel in world space
corner_edge_indices(4, 2)int32Lookup table: for each corner, which two edges share it
n_real_pointsint—Count of non-padded points
triple_i/j/k(MAX_TRIPLES,)int32Point-edge-point triples for dynamic collision pairs
triple_active(MAX_TRIPLES,)boolActive mask for each collision triple
triple_pair_slot(MAX_TRIPLES,)int32Broadphase slot that produced each triple
self_triple_i/j/k(MAX_SELF_TRIPLES,)int32Self-collision triples (robot against itself)
self_triple_active(MAX_SELF_TRIPLES,)boolActive mask for self-collision triples
candidate_pair_i/j(MAX_TRIPLES,)int32Broadphase candidate pairs before narrowphase
candidate_pair_active(MAX_TRIPLES,)boolActive mask for candidate pairs
n_triplesint—Diagnostic count of active collision triples
n_self_triplesint—Diagnostic count of active self-collision triples
n_candidate_pairsint—Diagnostic count of broadphase candidate pairs
n_robot_surface_boxelsint—Count of active robot boxels that have at least one exposed surface edge

Precomputed collision representation of fixed terrain. Points are constant throughout simulation.

FieldShapedtypeDescription
point_positions(n_static_points, 2)float32Fixed world-space positions of terrain vertices
cell_vertices(n_static_cells, 4)int32Vertex indices for each static cell (padded to 4)
cell_vertex_count(n_static_cells,)int32Actual vertex count per cell (3 for triangles, 4 for quads)
cell_edge_a(n_static_cells, 4)int32First endpoint index of each cell edge
cell_edge_b(n_static_cells, 4)int32Second endpoint index of each cell edge
surface_edge_mask(n_static_cells, 4)boolTrue for outward-facing (collidable) edges
cell_types(n_static_cells,)int32Voxel type constant for each static cell
cell_aabb_min(n_static_cells, 2)float32Static cell AABB minimum
cell_aabb_max(n_static_cells, 2)float32Static cell AABB maximum
column_cell_indices(n_columns, max_cells_per_column)int32Column acceleration structure
column_cell_count(n_columns,)int32Active static cells per column

Describes a single object (robot or terrain block) before it is instantiated into a world. Holds 35+ fields covering the grid layout, voxel types, spring topology, mass and stiffness assignments, point masks, and axis-aligned actuator metadata. You generally do not construct this directly — it is produced by the robot/terrain loaders and consumed by the world builder.

A complete description of a world layout, ready to be built into a BuiltWorld.

FieldTypeDescription
grid_hintTotal world grid height in voxels
grid_wintTotal world grid width in voxels
robot_namestrIdentifier string for the robot morphology
object_templatestuple[ObjectTemplate, ...]Ordered sequence of all objects in the world
robot_template_indexintIndex into object_templates identifying the robot

Pairs a primary world with an optional mirror for symmetric training.

FieldTypeDescription
primaryWorldTemplateThe canonical world
mirrorWorldTemplate | NoneHorizontally mirrored world, or None if unused
mirror_modeLiteral["none", "paired"]How the mirror is used during training

The fully instantiated, ready-to-simulate world. All arrays are sized and padded; this is what environments hold at construction time.

FieldTypeDescription
sim_stateSimStateInitial simulation state at spawn
topologySpringTopologyFixed spring connectivity graph
constantsPhysicsConstantsPhysics hyperparameters
collision_dataCollisionDataDynamic collision structures
static_collider_dataStaticColliderDataStatic terrain collision data
actuator_infoActuatorInfoActuator-to-spring mapping
per_axis_infoPerAxisActuatorInfoPer-axis actuator bookkeeping
deformation_infoDeformationInfoRobot deformation measurement data
robot_point_indicesjnp.ndarrayIndices into sim_state.positions for robot points
robot_point_maskjnp.ndarrayBoolean mask over all points identifying robot points
dynamic_terrain_point_indicesjnp.ndarrayIndices for moveable terrain points
fixed_terrain_sample_positionsjnp.ndarrayStatic sample positions used for terrain observations
render_infoRenderInfoStatic rendering metadata
grid_hintWorld grid height
grid_wintWorld grid width

Each environment carries a sim_state plus the minimal bookkeeping needed to compute rewards and detect episode termination.

Used by the locomotion (walker) environment.

FieldShapedtypeDescription
sim_stateSimState—Full simulation state
step_count()int32Steps elapsed in the current episode
done()boolWhether the episode has ended
prev_com_x()float32Robot centre-of-mass x from the previous step, for velocity reward

Used by shape (height / wingspan) environments. Rewards are based on the robot’s spatial extent rather than locomotion.

FieldShapedtypeDescription
sim_stateSimState—Full simulation state
step_count()int32Steps elapsed
done()boolEpisode ended flag
prev_span()float32Previous step’s height or wingspan measurement

Used by environments that penalise deviating from the robot’s initial orientation (e.g. balance or directed locomotion tasks).

FieldShapedtypeDescription
sim_stateSimState—Full simulation state
step_count()int32Steps elapsed
done()boolEpisode ended flag
prev_com_x()float32Previous centre-of-mass x
initial_robot_positions(n_robot_points, 2)float32Spawn positions used as orientation reference

Used by the jump environment. Tracks both x and y components of the centre of mass.

FieldShapedtypeDescription
sim_stateSimState—Full simulation state
step_count()int32Steps elapsed
done()boolEpisode ended flag
prev_com_x()float32Previous centre-of-mass x
prev_com_y()float32Previous centre-of-mass y, for vertical reward

Used by the climb environment. Rewards upward movement only.

FieldShapedtypeDescription
sim_stateSimState—Full simulation state
step_count()int32Steps elapsed
done()boolEpisode ended flag
prev_com_y()float32Previous centre-of-mass y

The reusable lattice and connectivity data produced by precompute_grid(H, W) for the dense-grid pipeline. It describes grid structure independently of the morphology occupying it.

FieldShapedtypeDescription
positions((H+1)*(W+1), 2)float32Initial vertex positions on the grid lattice
spring_a_idx(n_springs,)int32First endpoint index of each spring
spring_b_idx(n_springs,)int32Second endpoint index of each spring
spring_rest_length(n_springs,)float32Rest length of each spring
spring_types(n_springs,)int32Spring orientation: 0 = horizontal, 1 = vertical, 2 = diagonal
spring_cell_a(n_springs,)int32Primary cell owning each spring
spring_cell_b(n_springs,)int32Secondary cell sharing each spring (if any)
cell_corner_indices(H*W, 4)int32Corner point indices per cell: [BL, BR, TR, TL]
cell_grid_vy(H*W,)int32Grid row of each cell
cell_grid_vx(H*W,)int32Grid column of each cell
cell_horiz_bottom(H*W,)int32Bottom horizontal spring index for each cell
cell_horiz_top(H*W,)int32Top horizontal spring index for each cell
cell_vert_left(H*W,)int32Left vertical spring index for each cell
cell_vert_right(H*W,)int32Right vertical spring index for each cell
cell_diag1(H*W,)int32First diagonal spring index for each cell
cell_diag2(H*W,)int32Second diagonal spring index for each cell
Hint—Grid height in voxels
Wint—Grid width in voxels

Indices needed to compute per-voxel deformation observations from spring rest lengths.

FieldShapedtypeDescription
voxel_horiz_springs(n_robot_voxels, 2)int32Indices of the top and bottom horizontal springs per voxel; -1 if missing
voxel_vert_springs(n_robot_voxels, 2)int32Indices of the left and right vertical springs per voxel; -1 if missing
n_robot_voxelsint—Number of active robot voxels

Static, Python-side metadata built once and used each render call. Contains numpy arrays (not JAX).

FieldShapedtypeDescription
cell_vertices(n_cells, 4)int32Vertex indices per cell
cell_vertex_count(n_cells,)int32Actual vertex count (3 or 4) per cell
cell_types(n_cells,)int32Voxel type constant for each cell
cell_mask(n_cells,)boolActive cell mask
surface_edge_mask(n_cells, 4)boolOutward-facing edge mask for rendering borders
cell_is_robot(n_cells,)boolTrue for robot cells
cell_is_dynamic(n_cells,)boolTrue for non-static cells
cell_object_id(n_cells,)int32Object identifier per cell
robot_point_indices(n_robot_points,)int32Which global points belong to the robot
grid_hint—World grid height
grid_wint—World grid width
actuator_cell_indices(n_actuator_cells,)int32Cell indices for actuator colouring
cell_h_spring_pairs(n_cells, 2)int32Horizontal spring pair indices per cell
cell_v_spring_pairs(n_cells, 2)int32Vertical spring pair indices per cell
spring_init_rest_length(n_springs,)float32Initial rest lengths for deformation visualisation
static_point_positions(n_static_points, 2)float32Fixed terrain vertex positions

The record captured by make_render_episode_step for rendering a rollout.

FieldShapedtypeDescription
positions(n_points, 2)float32Current point positions
spring_rest_length(n_springs,)float32Current spring rest lengths (for deformation colour)
reward()float32Reward received this step
done()boolWhether the episode ended

The record returned by the make_*_episode_step factories for lax.scan. An environment’s step() itself returns (obs, state, reward, done).

FieldShapedtypeDescription
obs(obs_dim,)float32Observation vector for the current step
reward()float32Reward received this step
done()boolWhether the episode ended
positions(n_points, 2)float32Current point positions (for logging / visualisation)

A @dataclass (not a NamedTuple) controlling the renderer. All fields have defaults.

FieldDefaultDescription
enabledFalseCaller-side preference; does not disable direct rendering calls
width600Output frame width in pixels
height300Output frame height in pixels
fps50Target playback frame rate
real_timeTrueMatch physics timing by computing the frame skip automatically
frame_skip7Manual frame skip used when real_time=False
show_gridFalseOverlay the voxel grid
show_edgesTrueDraw cell border edges
dynamic_actuator_colorsTrueColour actuators by current activation level
camera_padding0.3World units of padding around the robot
viewport_width4.0World-space units visible horizontally
camera_mode"fit_robot"Fit the viewport to the robot; any other value uses a fixed viewport width
camera_smoothing0.18Camera interpolation factor (0 retains the previous centre, 1 tracks instantly)
supersample2Anti-aliasing multiplier (render at N× then downscale)
grid_major_every5Draw a heavier grid line every N cells
show_minor_gridFalseDraw minor grid lines
edge_width_px2Edge stroke width in pixels
output_dir"renders"Directory for saved GIFs
target_framesNoneOptional frame budget cap
sim_time_per_stepNoneOverride the simulated duration of each environment step for real-time pacing
max_colors256Palette size cap for GIF optimisation
optimizeFalseApply GIF frame optimisation
ditherTrueEnable Floyd-Steinberg dithering in GIF output

from jax_evogym import default_physics_constants
constants = default_physics_constants()

Returns a PhysicsConstants instance with the standard simulation parameters. Slope contact/grip fields remain present on the tuple for compatibility, but they are no-ops under the current geometry-only slope boundary. Override individual fields using ._replace():

constants = default_physics_constants()._replace(integrator=1)