Skip to content

unienv_interface.world.funcworld

WorldStateT module-attribute

WorldStateT = TypeVar('WorldStateT')

FuncWorld

Bases: ABC, Generic[WorldStateT, BArrayType, BDeviceType, BDtypeType, BRNGType]

Functional counterpart to :class:World with explicit state passing.

backend instance-attribute

backend: ComputeBackend[BArrayType, BDeviceType, BDtypeType, BRNGType]

device instance-attribute

device: Optional[BDeviceType]

The world timestep in seconds. If None, the world is asynchronous (real-time)

world_timestep instance-attribute

world_timestep: Optional[float]

The world's physical timestep in seconds. There might be multiple world sub-steps inside a world step. If none this means it is not known

world_subtimestep class-attribute instance-attribute

world_subtimestep: Optional[float] = None

The number of parallel environments in this world

batch_size class-attribute instance-attribute

batch_size: Optional[int] = None

initial abstractmethod

initial(*, seed: Optional[int] = None, **kwargs) -> WorldStateT

Construct the initial world state.

step abstractmethod

step(state: WorldStateT) -> Tuple[WorldStateT, Union[float, BArrayType]]

Advance state by one world step.

reset abstractmethod

reset(state: WorldStateT, *, seed: Optional[int] = None, mask: Optional[BArrayType] = None, **kwargs) -> WorldStateT

Perform reset on the selected environments with the given mask Note that the state input and output should be with the full batch size

reload

reload(state: WorldStateT, *, seed: Optional[int] = None, **kwargs) -> WorldStateT

Prepare the world for reloading. This is called BEFORE nodes add entities.

Use this hook to: - Clear old scene data - Load asset definitions - Prepare for entities to be added by nodes

DO NOT compile the scene here. Compilation happens in after_reload() after all nodes have had a chance to add their entities.

By default, this just calls initial with the same parameters. Simulation environments should override this to prepare for entity addition.

The reload flow is
  1. world.reload() # World prepares (clear, load assets)
  2. node.reload() # Nodes add entities to scene
  3. world.after_reload() # World compiles scene with all entities
  4. node.after_reload() # Nodes cache references

after_reset

after_reset(state: WorldStateT, *, seed: Optional[int] = None, mask: Optional[BArrayType] = None, **kwargs) -> WorldStateT

Called after reset() completes.

Use this hook to perform post-reset initialization. Returns the (possibly modified) world state.

after_reload

after_reload(state: WorldStateT, *, seed: Optional[int] = None, mask: Optional[BArrayType] = None, **kwargs) -> WorldStateT

Compile the world scene AFTER all nodes have added their entities.

This is where the actual scene compilation should happen, since nodes have already added their entities during the reload() phase.

Use this hook to: - Compile the simulation scene - Cache references to entities - Perform validation that requires the compiled scene - Initialize state that depends on the final scene configuration

Returns the (possibly modified) world state.

close

close(state: WorldStateT) -> None

Release any resources referenced by state.

is_control_timestep_compatible

is_control_timestep_compatible(control_timestep: Optional[float]) -> bool

Check whether a node control period aligns with world_timestep.