# 環境

シミュレーション環境は`EnvConfig`によって設定され、`make_env`によって構築されます。各サブクラスは、その`gym_kwargs`とベクトル化環境の構築方法を宣言します。

公開されている環境の使用については[ハブからの環境](../envhub)を、ベンチマークの貢献については[新しいベンチマークの追加](../adding_benchmarks)を参照してください。

## EnvConfig[[lerobot.envs.EnvConfig]]

#### lerobot.envs.EnvConfig[[lerobot.envs.EnvConfig]]

```python
lerobot.envs.EnvConfig(task: str | None = None, fps: int = 30, features: dict[str, PolicyFeature] = <factory>, features_map: dict[str, str] = <factory>, max_parallel_tasks: int = 1, disable_env_checker: bool = True, server: EnvClientConfig | None = None)
```

[ソース](https://github.com/huggingface/lerobot/blob/v0.7.0/src/lerobot/envs/configs.py#L71)

#### create_env[[lerobot.envs.EnvConfig.create_env]]

```python
create_env(task_group: str | None = None, task_id: int | None = None, n_envs: int = 1, use_async_envs: bool = False)
```

[ソース](https://github.com/huggingface/lerobot/blob/v0.7.0/src/lerobot/envs/configs.py#L127)

1つのタスクに対して、ローカルまたはサーブされたベクトル環境を1つ作成します。`task_id`を指定しない場合、スイートの最初のタスクが対象となります。

#### create_envs[[lerobot.envs.EnvConfig.create_envs]]

```python
create_envs(n_envs: int, use_async_envs: bool = False)
```

[ソース](https://github.com/huggingface/lerobot/blob/v0.7.0/src/lerobot/envs/configs.py#L112)

`&amp;lcub;suite: &amp;lcub;task_id: env}}` の形式で、ローカルまたはサーブされたベクトル環境を作成します。

#### get_env_processors[[lerobot.envs.EnvConfig.get_env_processors]]

```python
get_env_processors()
```

[ソース](https://github.com/huggingface/lerobot/blob/v0.7.0/src/lerobot/envs/configs.py#L215)

Return この環境用の(preprocessor, postprocessor)です。デフォルト: identity。

#### sim_config[[lerobot.envs.EnvConfig.sim_config]]

```python
sim_config()
```

[ソース](https://github.com/huggingface/lerobot/blob/v0.7.0/src/lerobot/envs/configs.py#L108)

`sim_settings()`を、シミュレーションのデフォルト値として返します。ローカル環境および環境サーバーが実行するのと同じです。

#### sim_settings[[lerobot.envs.EnvConfig.sim_settings]]

```python
sim_settings()
```

[ソース](https://github.com/huggingface/lerobot/blob/v0.7.0/src/lerobot/envs/configs.py#L101)

`sim` セクションのサーバー YAML と同様に、シミュレーション設定を返します。欠落している項目にはシミュレーションのデフォルト値が使用されます。

デフォルトでは、`gym_kwargs` とデルタアクションを備えた Gymnasium 環境 `gym_id` が使用されます。それ以外の場合は、上書きしてください。

## make_env[[lerobot.envs.make_env]]

#### lerobot.envs.make_env[[lerobot.envs.make_env]]

```python
lerobot.envs.make_env(cfg: EnvConfig | str, n_envs: int = 1, use_async_envs: bool = False, hub_cache_dir: str | None = None, trust_remote_code: bool = False)
```

[ソース](https://github.com/huggingface/lerobot/blob/v0.7.0/src/lerobot/envs/factory.py#L65)

**パラメータ:**

cfg (`EnvConfig | str`) : 環境設定、または `env.py` が環境を構築する Hugging Face Hub リポジトリ ID（例: `"username/repo"`）。

n_envs (`int`、*任意*、デフォルトは`1`) : 各ベクトル環境内の環境数。

use_async_envs (`bool`, *任意*, デフォルトは `False`) : 各 env を独自のワーカープロセスで実行します。

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}}` の形式です。単一タスクの環境は1つのスイートを持ち、タスク 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]]

#### lerobot.envs.make_env_config[[lerobot.envs.make_env_config]]

```python
lerobot.envs.make_env_config(env_type: str, **kwargs)
```

[ソース](https://github.com/huggingface/lerobot/blob/v0.7.0/src/lerobot/envs/factory.py#L27)

