Skip to content

unienv_interface.world.funcenv_composer

Classes:

Name Description
WorldFuncEnvState

State object used by FuncWorldEnv, bundling world and node states.

FuncWorldEnv

Composes a FuncEnv from a FuncWorld and one or more FuncWorldNode instances.

WorldFuncEnvState dataclass

WorldFuncEnvState(world_state: Any, node_state: Any)

State object used by FuncWorldEnv, bundling world and node states.

Attributes:

Name Type Description
world_state Any
node_state Any

world_state instance-attribute

world_state: Any

node_state instance-attribute

node_state: Any

FuncWorldEnv

FuncWorldEnv(
    world: FuncWorld[WorldStateT, BArrayType, BDeviceType, BDtypeType, BRNGType],
    node_or_nodes: Union[
        FuncWorldNode[
            WorldStateT,
            NodeStateT,
            ContextType,
            ObsType,
            ActType,
            BArrayType,
            BDeviceType,
            BDtypeType,
            BRNGType,
        ],
        Iterable[
            FuncWorldNode[
                WorldStateT,
                Any,
                Any,
                Any,
                Any,
                BArrayType,
                BDeviceType,
                BDtypeType,
                BRNGType,
            ]
        ],
    ],
    *,
    render_mode: Optional[str] = "auto",
)

Bases: FuncEnv[WorldFuncEnvState, None, BArrayType, ContextType, ObsType, ActType, RenderFrame, BDeviceType, BDtypeType, BRNGType]

Composes a FuncEnv from a FuncWorld and one or more FuncWorldNode instances.

If multiple nodes are passed, they are automatically wrapped in a CombinedFuncWorldNode.

Bind a functional world and node tree into one FuncEnv facade.

Methods:

Name Description
get_node

Look up a node by name or nested path.

get_nodes_by_fn

Collect nodes in the tree that satisfy fn.

get_nodes_by_type

Collect nodes in the tree that are instances of node_type.

reload

Rebuild the world and recreate node state through the reload lifecycle.

initial

Create the initial world state and root node state.

reset

Reset the composed functional environment, optionally forcing reload.

step

Run one control step through the functional node/world composition.

close

Close the node tree first, then the underlying world.

render_init

Return a no-op render state for node-based functional environments.

render_image

Render through the root node when rendering is enabled.

render_close

Return the unchanged state because no extra render state is held.

update_observation_post_reset

Merge masked reset observations back into a full batched observation.

update_context_post_reset

Merge masked reset contexts back into a full batched context.

has_wrapper_attr

Checks if the attribute name exists in the environment.

get_wrapper_attr

Gets the attribute name from the environment.

set_wrapper_attr

Sets the attribute name on the environment with value.

Attributes:

Name Type Description
node
world
observation_space
action_space
context_space
backend
device
batch_size
render_mode Optional[str]
control_timestep Optional[float]

Simulation time represented by one environment control step.

render_fps Optional[int]
metadata Dict[str, Any]
unwrapped FuncEnv
prev_wrapper_layer Optional[FuncEnv]

node instance-attribute

node = node_or_nodes

world instance-attribute

world = world

observation_space property

observation_space

action_space property

action_space

context_space property

context_space

backend property

backend

device property

device

batch_size property

batch_size

render_mode property

render_mode: Optional[str]

control_timestep property

control_timestep: Optional[float]

Simulation time represented by one environment control step.

This is the resolved control timestep: the explicit node control_timestep when configured, otherwise the effective update timestep, otherwise the world timestep. It is None when none of these are defined (e.g. an asynchronous real-time world).

render_fps property

render_fps: Optional[int]

metadata class-attribute instance-attribute

metadata: Dict[str, Any] = {'render_modes': []}

unwrapped property

unwrapped: FuncEnv

prev_wrapper_layer property

prev_wrapper_layer: Optional[FuncEnv]

get_node

get_node(
    nested_keys: Union[str, Sequence[str]],
) -> Optional[
    FuncWorldNode[
        WorldStateT, Any, Any, Any, Any, BArrayType, BDeviceType, BDtypeType, BRNGType
    ]
]

Look up a node by name or nested path.

get_nodes_by_fn

get_nodes_by_fn(
    fn: Callable[
        [
            FuncWorldNode[
                WorldStateT,
                Any,
                Any,
                Any,
                Any,
                BArrayType,
                BDeviceType,
                BDtypeType,
                BRNGType,
            ]
        ],
        bool,
    ],
) -> list[
    FuncWorldNode[
        WorldStateT, Any, Any, Any, Any, BArrayType, BDeviceType, BDtypeType, BRNGType
    ]
]

Collect nodes in the tree that satisfy fn.

get_nodes_by_type

get_nodes_by_type(
    node_type: Type[
        FuncWorldNode[
            WorldStateT,
            Any,
            Any,
            Any,
            Any,
            BArrayType,
            BDeviceType,
            BDtypeType,
            BRNGType,
        ]
    ],
) -> list[
    FuncWorldNode[
        WorldStateT, Any, Any, Any, Any, BArrayType, BDeviceType, BDtypeType, BRNGType
    ]
]

Collect nodes in the tree that are instances of node_type.

reload

reload(
    state: WorldFuncEnvState, *, seed: Optional[int] = None, **kwargs
) -> Tuple[WorldFuncEnvState, ContextType, ObsType, Dict[str, Any]]

Rebuild the world and recreate node state through the reload lifecycle.

initial

initial(
    *, seed: Optional[int] = None, **kwargs
) -> Tuple[WorldFuncEnvState, ContextType, ObsType, Dict[str, Any]]

Create the initial world state and root node state.

reset

reset(
    state: WorldFuncEnvState,
    *,
    seed: Optional[int] = None,
    mask: Optional[BArrayType] = None,
    reload: bool = False,
    **kwargs,
) -> Tuple[WorldFuncEnvState, ContextType, ObsType, Dict[str, Any]]

Reset the composed functional environment, optionally forcing reload.

step

step(
    state: WorldFuncEnvState, action: ActType
) -> Tuple[
    WorldFuncEnvState,
    ObsType,
    Union[SupportsFloat, BArrayType],
    Union[bool, BArrayType],
    Union[bool, BArrayType],
    Dict[str, Any],
]

Run one control step through the functional node/world composition.

close

close(state: WorldFuncEnvState) -> None

Close the node tree first, then the underlying world.

render_init

render_init(state, *, seed=None, render_mode=None, **kwargs)

Return a no-op render state for node-based functional environments.

render_image

render_image(state, render_state)

Render through the root node when rendering is enabled.

render_close

render_close(state, render_state)

Return the unchanged state because no extra render state is held.

update_observation_post_reset

update_observation_post_reset(
    old_obs: ObsType, newobs_masked: ObsType, mask: BArrayType
) -> ObsType

Merge masked reset observations back into a full batched observation.

update_context_post_reset

update_context_post_reset(
    old_context: ContextType, new_context: ContextType, mask: BArrayType
) -> ContextType

Merge masked reset contexts back into a full batched context.

has_wrapper_attr

has_wrapper_attr(name: str) -> bool

Checks if the attribute name exists in the environment.

get_wrapper_attr

get_wrapper_attr(name: str) -> Any

Gets the attribute name from the environment.

set_wrapper_attr

set_wrapper_attr(name: str, value: Any)

Sets the attribute name on the environment with value.