LeRobot documentation
Environments
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
< source >( 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
< source >( 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 local or served vector envs, as {suite: {task_id: env}}.
Return (preprocessor, postprocessor) for this env. Default: identity.
Return sim_settings() with the sim’s defaults, as local envs and the env server run it.
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
< source >( 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") whoseenv.pybuilds the envs. - n_envs (
int, optional, defaults to1) — Number of envs in each vector env. - use_async_envs (
bool, optional, defaults toFalse) — Run each env in its own worker process. - hub_cache_dir (
str, optional) — Folder to cache the downloadedenv.pyin. Only used with a repo ID. - trust_remote_code (
bool, optional, defaults toFalse) — 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— Ifn_envsis below 1.RuntimeError— If a Hub repo’s code would run withouttrust_remote_code.ModuleNotFoundError— If the simulator, or a package the repo’senv.pyneeds, is not installed.
Build the vector envs of a config, or of a Hub repo’s make_env.