unilab.base.base.ABEnv

class unilab.base.base.ABEnv[source]

Bases: ABC

Methods

__init__()

capture_play_video_frame()

Capture one RGB frame through the env-facing video contract.

close()

Clean up environment resources

get_physics_state_snapshot()

Return a physics snapshot for offline playback/video export.

get_playback_model([env_index])

Return a model object suitable for backend-specific playback tooling.

init_play_renderer([render_spacing, ...])

Initialize env-facing playback rendering when supported.

init_state()

Initialize environment and return initial state

render([mode])

Render the current state; mode="rgb_array" returns an RGB frame.

render_play_frame()

Render one frame through the env-facing interactive playback contract.

resolve_play_render_plan(*, ...)

Resolve high-level playback mode through the backend contract.

run_playback(*, initialize, step, num_steps)

Execute playback through the backend contract.

run_playback_mode(*, play_render_mode, ...)

Resolve configured playback mode and execute it through the backend contract.

step(actions)

Step the environment with given actions, return new state

Attributes

action_space

Action space

cfg

The configuration of the environment

num_envs

return the size of the env if it is vectorized

obs_groups_spec

Map from observation group name to its dimension.

observation_space

Observation space

play_capabilities

Return env-facing play/render capabilities.

state

Current environment state (None before first reset)

property play_capabilities: EnvPlayCapabilities

Return env-facing play/render capabilities.

resolve_play_render_plan(*, play_render_mode, play_steps, output_video)[source]

Resolve high-level playback mode through the backend contract.

Parameters:
Return type:

BackendPlayRenderPlan

run_playback(*, initialize, step, num_steps, output_video=None, render_spacing=None, render_offset_mode=None, headless=None, record_video=None, frame_state_getter=None, camera_kwargs=None, debug_overlay_getter=None, on_frame=None)[source]

Execute playback through the backend contract.

debug_overlay_getter returns per-env sequences of unisim.backend.base.DebugPrimitive with env-local poses (None disables overlays for the frame). on_frame is an optional (frame_index, frame) -> frame | None callback applied to each recorded frame before it is written to the video.

Parameters:
Return type:

str | None

run_playback_mode(*, play_render_mode, play_steps, output_video, initialize, step, render_spacing=None, render_offset_mode=None, frame_state_getter=None, camera_kwargs=None, debug_overlay_getter=None, on_frame=None, on_plan=None)[source]

Resolve configured playback mode and execute it through the backend contract.

Overlay gating follows the resolved plan mode: record playback requires play_capabilities.supports_debug_overlay (backends fail closed otherwise); interactive playback requires supports_interactive_debug_overlay — when the backend lacks it the getter is dropped with a warning so interactive playback still runs without overlays.

Parameters:
Return type:

str | None

abstract property num_envs: int

return the size of the env if it is vectorized

abstract property cfg: EnvCfg

The configuration of the environment

abstract property observation_space: Space

Observation space

abstract property action_space: Space

Action space

abstract property obs_groups_spec: dict[str, int]

Map from observation group name to its dimension.

abstract property state: Any

Current environment state (None before first reset)

abstract init_state()[source]

Initialize environment and return initial state

Return type:

Any

abstract step(actions)[source]

Step the environment with given actions, return new state

Parameters:

actions (ndarray)

Return type:

Any

abstract close()[source]

Clean up environment resources

Return type:

None

init_play_renderer(render_spacing=None, render_offset_mode=None, *, headless=False, capture=False, width=1280, height=720, camera_kwargs=None)[source]

Initialize env-facing playback rendering when supported.

Parameters:
Return type:

None

render(mode='rgb_array')[source]

Render the current state; mode="rgb_array" returns an RGB frame.

Convenience wrapper over init_play_renderer() and capture_play_video_frame(), gated on play_capabilities.supports_native_video_capture.

Parameters:

mode (str)

Return type:

ndarray

render_play_frame()[source]

Render one frame through the env-facing interactive playback contract.

Return type:

None

capture_play_video_frame()[source]

Capture one RGB frame through the env-facing video contract.

Return type:

ndarray

get_physics_state_snapshot()[source]

Return a physics snapshot for offline playback/video export.

Return type:

ndarray

get_playback_model(env_index=None)[source]

Return a model object suitable for backend-specific playback tooling.

Parameters:

env_index (int | None) – Optional vectorized environment index whose playback model should be returned when backend model variants differ across envs.

Return type:

Any

Returns:

A backend-specific playback model object.