LeRobot documentation

环境

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

环境

模拟环境通过 EnvConfig 进行配置,并由 make_env 构建。每个子类都声明其 gym_kwargs 以及如何构建向量化环境。

请参阅 来自 Hub 的环境 以了解如何使用已发布的环境,并参阅 添加新基准 以了解如何贡献一个。

EnvConfig

类 lerobot.envs.EnvConfig

< >

( task: str | None = Nonefps: int = 30features: dict[str, PolicyFeature] = <factory>features_map: dict[str, str] = <factory>max_parallel_tasks: int = 1disable_env_checker: bool = Trueserver: EnvClientConfig | None = None )

create_env

< >

( task_group: str | None = Nonetask_id: int | None = Nonen_envs: int = 1use_async_envs: bool = False )

为每个任务创建一个本地或托管的向量环境;未指定 task_id 时,默认使用套件中的第一个任务。

create_envs

< >

( n_envs: intuse_async_envs: bool = False )

创建本地或已部署的向量环境,格式为 {suite: {task_id: env}}。

get_env_processors

< >

( )

返回此环境的 (preprocessor, postprocessor)。默认值:identity。

sim_config

< >

( )

返回 sim_settings(),其中包含模拟的默认值,与本地环境和环境服务器运行时的设置一致。

sim_settings

< >

( )

返回模拟设置,类似于服务器 YAML 中的 sim 部分;缺失的设置将使用模拟默认值。

默认使用带有 gym_kwargs 和增量动作的 Gymnasium 环境 gym_id;否则请覆盖此设置。

make_env

lerobot.envs.make_env

< >

( cfg: EnvConfig | strn_envs: int = 1use_async_envs: bool = Falsehub_cache_dir: str | None = Nonetrust_remote_code: bool = False ) → dict[str, dict[int, gym.vector.VectorEnv]]

参数

  • cfg (EnvConfig | str) — 环境配置,或 Hugging Face Hub 仓库 ID(例如 "username/repo"),其 env.py 用于构建环境。
  • n_envs (int,可选,默认为 1) — 每个向量环境中的环境数量。
  • use_async_envs (bool,可选,默认为 False) — 在各自独立的工作进程中运行每个环境。
  • hub_cache_dir (str, 可选) — 用于缓存下载的 env.py 的文件夹。仅在提供仓库 ID 时使用。
  • trust_remote_code (bool,可选,默认为 False) — 同意运行 Hub 仓库的代码,使用仓库 ID 或 EnvHub 配置时需要此设置。

返回值

dict[str, dict[int, gym.vector.VectorEnv]]

向量环境,格式为 {suite: {task_id: env}}。单任务环境只有一个 suite,其任务 ID 为 0。

引发

ValueError 或 RuntimeError 或 ModuleNotFoundError

  • ValueError — 如果 n_envs 小于 1。
  • RuntimeError — 如果 Hub 仓库的代码可以在不使用 trust_remote_code 的情况下运行。
  • ModuleNotFoundError — 如果模拟器未安装,或者仓库的 env.py 所需的某个包未安装。

构建配置或 Hub 仓库的 make_env 的向量环境。

make_env_config

lerobot.envs.make_env_config

< >

( env_type: str**kwargs )

Update on GitHub