LeRobot documentation

Environments

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

Environments

Simulation environments are configured through EnvConfig and built by make_env. Each subclass declares its gym_kwargs and how to construct the vectorised environments.

See Environments from the Hub for using published environments and Adding a New Benchmark for contributing one.

EnvConfig

class 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 )

Create one local or served vector env for one task; no task_id means the suite’s first task.

create_envs

< >

( n_envs: intuse_async_envs: bool = False )

Create local or served vector envs, as {suite: {task_id: env}}.

get_env_processors

< >

( )

Return (preprocessor, postprocessor) for this env. Default: identity.

sim_config

< >

( )

Return sim_settings() with the sim’s defaults, as local envs and the env server run it.

sim_settings

< >

( )

Return the sim settings, as in a server YAML’s sim section; missing ones use sim defaults.

The default is the Gymnasium env gym_id with gym_kwargs and delta actions; override otherwise.

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]]

Parameters

  • cfg (EnvConfig | str) — The env config, or a Hugging Face Hub repo ID (e.g. "username/repo") whose env.py builds the envs.
  • n_envs (int, optional, defaults to 1) — Number of envs in each vector env.
  • use_async_envs (bool, optional, defaults to False) — Run each env in its own worker process.
  • hub_cache_dir (str, optional) — Folder to cache the downloaded env.py in. Only used with a repo ID.
  • trust_remote_code (bool, optional, defaults to False) — Consent to run a Hub repo’s code, needed for a repo ID or an EnvHub config.

Returns

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

The vector envs, as {suite: {task_id: env}}. A single-task env has one suite, with task ID 0.

Raises

ValueError or RuntimeError or ModuleNotFoundError

  • ValueError — If n_envs is below 1.
  • RuntimeError — If a Hub repo’s code would run without trust_remote_code.
  • ModuleNotFoundError — If the simulator, or a package the repo’s env.py needs, is not installed.

Build the vector envs of a config, or of a Hub repo’s make_env.

make_env_config

lerobot.envs.make_env_config

< >

( env_type: str**kwargs )

Update on GitHub