unilab.base.np_env¶
Classes
统一的 numpy 环境基类(backend-agnostic) |
|
NpEnvState(obs: 'dict[str, np.ndarray]', reward: 'np.ndarray', terminated: 'np.ndarray', truncated: 'np.ndarray', info: 'dict[str, Any]', final_observation: 'dict[str, np.ndarray] | None' = None) |
- class unilab.base.np_env.NpEnvState[source]¶
Bases:
objectNpEnvState(obs: ‘dict[str, np.ndarray]’, reward: ‘np.ndarray’, terminated: ‘np.ndarray’, truncated: ‘np.ndarray’, info: ‘dict[str, Any]’, final_observation: ‘dict[str, np.ndarray] | None’ = None)
- Parameters:
- class unilab.base.np_env.NpEnv[source]¶
Bases:
ABEnv统一的 numpy 环境基类(backend-agnostic)
- Parameters:
cfg (
EnvCfg)backend (
SimBackend)num_envs (
int)
- __init__(cfg, backend, num_envs)[source]¶
- Parameters:
cfg (
EnvCfg)backend (
SimBackend)num_envs (
int)
- property state: NpEnvState | None¶
Current environment state (None before first reset)
- property obs_groups_spec: dict[str, int]¶
101}.
Subclasses MUST override this property.
- Type:
Return observation group dimensions, e.g. {“obs”
- Type:
98, “critic”
- build_symmetry_augmentation(*, device)[source]¶
Return an env-owned runtime symmetry adapter when the task/backend supports it.
- Parameters:
device (
str)- Return type:
- step(actions)[source]¶
Step the environment with given actions, return new state
- Parameters:
actions (
ndarray)- Return type:
- init_play_renderer(render_spacing=None, render_offset_mode=None, *, headless=False, capture=False, width=1280, height=720, camera_kwargs=None)[source]¶
Initialize backend-native playback rendering when available.
- resolve_play_render_plan(*, play_render_mode, play_steps, output_video)[source]¶
Resolve high-level playback mode through the concrete backend.
- 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, extra_data_getter=None)[source]¶
Execute playback through the concrete backend.
- Parameters:
- Return type:
- render_play_frame()[source]¶
Render one interactive playback frame through the env contract.
- Return type:
- capture_play_video_frame()[source]¶
Capture one detached RGB video frame through the env contract.
- Return type:
- get_physics_state_snapshot()[source]¶
Return a detached physics snapshot for offline playback/video export.
- Return type:
- abstract apply_action(actions, state)[source]¶
子类实现:action → ctrl
- Parameters:
actions (
ndarray)state (
NpEnvState)
- Return type:
- abstract update_state(state)[source]¶
子类实现:计算 obs/reward/terminated
- Parameters:
state (
NpEnvState)- Return type:
- property play_capabilities: EnvPlayCapabilities¶
Return env-facing play/render capabilities.
- get_playback_model(env_index=None)[source]¶
Return the backend playback model for one env in a vectorized batch.