LeRobot 文件

LeIsaac × LeRobot EnvHub

Hugging Face's logo
加入 Hugging Face 社群

並獲得增強的文件體驗

開始使用

LeIsaac × LeRobot EnvHub

LeRobot EnvHub 現已支援使用 LeIsaac 進行模擬模仿學習 (imitation learning in simulation)。您可以啟動日常操作任務、遠端操作機器人、收集演示數據、將其推送到 Hub,並在 LeRobot 中訓練策略 —— 一切都在同一個工作流中完成。

LeIsaac 與 IsaacLab 及 SO101 Leader/Follower 設定進行整合,提供以下功能:

  • 🕹️ 以遠端操作 (Teleoperation) 為核心的工作流,用於數據收集
  • 📦 內建數據轉換,可直接用於 LeRobot 訓練
  • 🤖 日常生活技能,例如撿拾橘子、舉起方塊、清潔桌面以及摺疊衣物
  • ☁️ 持續升級,由 LightWheel 提供:雲端模擬、EnvHub 支援、Sim2Real 工具等

您可以在下方找到目前 LeRobot EnvHub 支援的 LeIsaac 任務。

可用環境

下表列出了 LeIsaac x LeRobot EnvHub 中所有可用的任務與環境。您也可以透過執行以下指令來獲取最新的環境列表:

python scripts/environments/list_envs.py
任務 環境 ID 任務描述 相關機器人
LeIsaac-SO101-PickOrange-v0

LeIsaac-SO101-PickOrange-Direct-v0
撿起三顆橘子並放入盤中,然後將機械手臂重置到休息狀態。 單臂 SO101 Follower
LeIsaac-SO101-LiftCube-v0

LeIsaac-SO101-LiftCube-Direct-v0
將紅色方塊舉起。 單臂 SO101 Follower
LeIsaac-SO101-CleanToyTable-v0

LeIsaac-SO101-CleanToyTable-BiArm-v0

LeIsaac-SO101-CleanToyTable-BiArm-Direct-v0
將兩個字母 e 物體撿入盒中,並將機械手臂重置到休息狀態。 單臂 SO101 Follower

雙臂 SO101 Follower
LeIsaac-SO101-FoldCloth-BiArm-v0

LeIsaac-SO101-FoldCloth-BiArm-Direct-v0
摺疊衣物,並將機械手臂重置到休息狀態。

注意:在此任務中,僅 DirectEnv 支援 check_success。
雙臂 SO101 Follower

用一行程式碼在 LeRobot 中直接載入 LeIsaac

EnvHub:透過 HuggingFace 分享 LeIsaac 環境

EnvHub 是我們可重現的環境中心,您可以透過一行指令啟動封裝好的模擬環境,立即進行實驗,並為社群發布您自己的任務。

LeIsaac 提供 EnvHub 支援,讓您只需幾個指令即可使用或分享任務。

如何開始:環境設定

執行以下指令來設定您的程式碼環境:

# Refer to Getting Started/Installation to install leisaac firstly
conda create -n leisaac_envhub python=3.11
conda activate leisaac_envhub

conda install -c "nvidia/label/cuda-12.8.1" cuda-toolkit
pip install -U torch==2.7.0 torchvision==0.22.0 --index-url https://download.pytorch.org/whl/cu128
pip install 'leisaac[isaaclab] @ git+https://github.com/LightwheelAI/leisaac.git#subdirectory=source/leisaac' --extra-index-url https://pypi.nvidia.com

# Install lerobot
pip install lerobot==0.4.1

# Fix numpy version
pip install numpy==1.26.0

使用範例

EnvHub 以統一的介面公開了每個 LeIsaac 支援的任務。下方的範例載入了 so101_pick_orange,並展示了隨機動作的演練以及互動式遠端操作。

隨機動作 (Random Action)

點擊以展開程式碼範例
# envhub_random_action.py

import torch
from lerobot.envs.factory import make_env

# Load from the hub
envs_dict = make_env("LightwheelAI/leisaac_env:envs/so101_pick_orange.py", n_envs=1, trust_remote_code=True)

# Access the environment
suite_name = next(iter(envs_dict))
sync_vector_env = envs_dict[suite_name][0]
# retrieve the isaac environment from the sync vector env
env = sync_vector_env.envs[0].unwrapped

# Use it like any gym environment
obs, info = env.reset()

while True:
    action = torch.tensor(env.action_space.sample())
    obs, reward, terminated, truncated, info = env.step(action)
    if terminated or truncated:
        obs, info = env.reset()

env.close()
python envhub_random_action.py

您應該會看到 SO101 機械手臂在純粹隨機的指令下擺動。

遠端操作 (Teleoperation)

LeRobot 的遠端操作堆疊可以驅動模擬中的機械手臂。

連接 SO101 Leader 控制器,並執行下方的校準指令。

lerobot-calibrate \
    --teleop.type=so101_leader \
    --teleop.port=/dev/ttyACM0 \
    --teleop.id=leader

然後啟動遠端操作腳本。

點擊以展開程式碼範例
# envhub_teleop_example.py

import logging
import time
import gymnasium as gym

from dataclasses import asdict, dataclass
from pprint import pformat

from lerobot.teleoperators import (  # noqa: F401
    Teleoperator,
    TeleoperatorConfig,
    make_teleoperator_from_config,
    so_leader,
    bi_so_leader,
)
from lerobot.utils.robot_utils import precise_sleep
from lerobot.utils.utils import init_logging
from lerobot.envs.factory import make_env


@dataclass
class TeleoperateConfig:
    teleop: TeleoperatorConfig
    env_name: str = "so101_pick_orange"
    fps: int = 60


@dataclass
class EnvWrap:
    env: gym.Env


def make_env_from_leisaac(env_name: str = "so101_pick_orange"):
    envs_dict = make_env(
        f'LightwheelAI/leisaac_env:envs/{env_name}.py',
        n_envs=1,
        trust_remote_code=True
    )
    suite_name = next(iter(envs_dict))
    sync_vector_env = envs_dict[suite_name][0]
    env = sync_vector_env.envs[0].unwrapped

    return env


def teleop_loop(teleop: Teleoperator, env: gym.Env, fps: int):
    from leisaac.devices.action_process import preprocess_device_action
    from leisaac.assets.robots.lerobot import SO101_FOLLOWER_MOTOR_LIMITS
    from leisaac.utils.env_utils import dynamic_reset_gripper_effort_limit_sim

    env_wrap = EnvWrap(env=env)

    obs, info = env.reset()
    while True:
        loop_start = time.perf_counter()
        if env.cfg.dynamic_reset_gripper_effort_limit:
            dynamic_reset_gripper_effort_limit_sim(env, 'so101leader')

        raw_action = teleop.get_action()
        processed_action = preprocess_device_action(
            dict(
                so101_leader=True,
                joint_state={
                    k.removesuffix(".pos"): v for k, v in raw_action.items()},
                motor_limits=SO101_FOLLOWER_MOTOR_LIMITS),
            env_wrap
        )
        obs, reward, terminated, truncated, info = env.step(processed_action)
        if terminated or truncated:
            obs, info = env.reset()

        dt_s = time.perf_counter() - loop_start
        precise_sleep(max(1 / fps - dt_s, 0.0))
        loop_s = time.perf_counter() - loop_start
        print(f"\ntime: {loop_s * 1e3:.2f}ms ({1 / loop_s:.0f} Hz)")


def teleoperate(cfg: TeleoperateConfig):
    init_logging()
    logging.info(pformat(asdict(cfg)))

    teleop = make_teleoperator_from_config(cfg.teleop)
    env = make_env_from_leisaac(cfg.env_name)

    teleop.connect()
    if hasattr(env, 'initialize'):
        env.initialize()
    try:
        teleop_loop(teleop=teleop, env=env, fps=cfg.fps)
    except KeyboardInterrupt:
        pass
    finally:
        teleop.disconnect()
        env.close()


def main():
    teleoperate(TeleoperateConfig(
        teleop=so_leader.SO101LeaderConfig(
            port="/dev/ttyACM0",
            id='leader',
            use_degrees=False,
        ),
        env_name="so101_pick_orange",
        fps=60,
    ))


if __name__ == "__main__":
    main()
python envhub_teleop_example.py

執行該腳本讓您能夠使用實體 Leader 設備來操作模擬中的機械手臂。

☁️ 雲端模擬 (無需 GPU)

沒有本地 GPU 或正確的驅動程式?沒問題!您可以完全在雲端執行 LeIsaac,無需任何安裝。LeIsaac 可在 NVIDIA Brev 上開箱即用,直接在您的瀏覽器中提供完整的配置環境。

👉 從這裡開始: https://lightwheelai.github.io/leisaac/docs/cloud_simulation/nvidia_brev

當您的實例部署完成後,只需開啟 port 80 (HTTP) 的連結,即可啟動 Visual Studio Code Server (預設密碼:password)。從那裡,您可以直接在瀏覽器中執行模擬、編輯程式碼並視覺化 IsaacLab 環境。

無需 GPU、無需驅動程式、無需本地安裝。點擊即可運行。

補充說明

我們保持 EnvHub 的涵蓋範圍與 LeIsaac 任務同步。目前支援:

  • so101_pick_orange
  • so101_lift_cube
  • so101_clean_toytable
  • bi_so101_fold_cloth

在呼叫 make_env 時,透過指定不同的腳本來切換任務,例如:

envs_dict_pick_orange = make_env("LightwheelAI/leisaac_env:envs/so101_pick_orange.py", n_envs=1, trust_remote_code=True)
envs_dict_lift_cube = make_env("LightwheelAI/leisaac_env:envs/so101_lift_cube.py", n_envs=1, trust_remote_code=True)
envs_dict_clean_toytable = make_env("LightwheelAI/leisaac_env:envs/so101_clean_toytable.py", n_envs=1, trust_remote_code=True)
envs_dict_fold_cloth = make_env("LightwheelAI/leisaac_env:envs/bi_so101_fold_cloth.py", n_envs=1, trust_remote_code=True)

注意:當使用 bi_so101_fold_cloth 時,在執行任何其他操作之前,請在獲取環境後立即呼叫 initialize()

點擊以展開程式碼範例
import torch
from lerobot.envs.factory import make_env

# Load from the hub
envs_dict = make_env("LightwheelAI/leisaac_env:envs/bi_so101_fold_cloth.py", n_envs=1, trust_remote_code=True)

# Access the environment
suite_name = next(iter(envs_dict))
sync_vector_env = envs_dict[suite_name][0]
# retrieve the isaac environment from the sync vector env
env = sync_vector_env.envs[0].unwrapped

# NOTE: initialize() first
env.initialize()

# other operation with env...
在 GitHub 上更新

© . This site is unofficial and not affiliated with Hugging Face, Inc.