unienv_interface.world.env_composer¶
Classes:
| Name | Description |
|---|---|
WorldEnv |
Composes an |
WorldEnv
¶
WorldEnv(
world: World[BArrayType, BDeviceType, BDtypeType, BRNGType],
node_or_nodes: Union[
WorldNode[
ContextType, ObsType, ActType, BArrayType, BDeviceType, BDtypeType, BRNGType
],
Iterable[
WorldNode[Any, Any, Any, BArrayType, BDeviceType, BDtypeType, BRNGType]
],
],
*,
render_mode: Optional[str] = "auto",
)
Bases: Env[BArrayType, ContextType, ObsType, ActType, RenderFrame, BDeviceType, BDtypeType, BRNGType]
Composes an Env from a World and one or more WorldNode instances.
If multiple nodes are passed, they are automatically wrapped in a
CombinedWorldNode.
Bind a world and node tree into one stateful environment 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 |
get_nodes_by_type |
Collect nodes in the tree that are instances of |
reload |
Reload the environment - reload scene with entities from nodes. |
reset |
Reset the composed environment, optionally forcing a full reload. |
step |
Run one control step through the node/world composition. |
render |
Render via the root node when rendering is enabled. |
close |
Close the node tree and the underlying world. |
sample_space |
Sample from |
sample_action |
Sample one action from |
sample_observation |
Sample one observation from |
sample_context |
Sample one context value if |
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 |
get_wrapper_attr |
Gets the attribute |
set_wrapper_attr |
Sets the attribute |
Attributes:
| Name | Type | Description |
|---|---|---|
node |
|
|
world |
|
|
rng |
|
|
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 |
Env
|
|
prev_wrapper_layer |
Optional[Env]
|
|
control_timestep
property
¶
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).
get_node
¶
get_node(
nested_keys: Union[str, Sequence[str]],
) -> Optional[WorldNode[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[
[WorldNode[Any, Any, Any, BArrayType, BDeviceType, BDtypeType, BRNGType]], bool
],
) -> list[WorldNode[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[
WorldNode[Any, Any, Any, BArrayType, BDeviceType, BDtypeType, BRNGType]
],
) -> list[WorldNode[Any, Any, Any, BArrayType, BDeviceType, BDtypeType, BRNGType]]
Collect nodes in the tree that are instances of node_type.
reload
¶
reload(
*, mask: Optional[BArrayType] = None, seed: Optional[int] = None, **kwargs
) -> Tuple[ContextType, ObsType, Dict[str, Any]]
Reload the environment - reload scene with entities from nodes.
Flow
- world.reload() - World prepares (clear, load assets)
- node.reload() - Nodes add entities to scene
- world.after_reload() - World compiles scene with all entities
- node.after_reload() - Nodes cache entity references
reset
¶
reset(
*,
mask: Optional[BArrayType] = None,
seed: Optional[int] = None,
reload: bool = False,
**kwargs,
) -> Tuple[ContextType, ObsType, Dict[str, Any]]
Reset the composed environment, optionally forcing a full reload.
step
¶
step(
action: ActType,
) -> Tuple[
ObsType,
Union[SupportsFloat, BArrayType],
Union[bool, BArrayType],
Union[bool, BArrayType],
Dict[str, Any],
]
Run one control step through the node/world composition.
render
¶
render() -> RenderFrame | Sequence[RenderFrame] | None
Render via the root node when rendering is enabled.
sample_context
¶
sample_context() -> Optional[ContextType]
Sample one context value if context_space is defined.
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
¶
Checks if the attribute name exists in the environment.
set_wrapper_attr
¶
Sets the attribute name on the environment with value.