LeIsaac × LeRobot EnvHub

LeRobot EnvHub 现已通过 LeIsaac 支持simulation 中的模仿学习。 启动日常操作任务、遥操作机器人、采集 demonstration、推送到 Hub,并在 LeRobot 中训练 policy——全部在一个闭环中完成。

LeIsaac 与 IsaacLab 及 SO101 主/follower arm 设置集成,提供:

  • 🕹️ teleoperation 优先的工作流,用于数据采集
  • 📦 内置数据转换,可直接用于 LeRobot 训练
  • 🤖 日常技能,如拾取橙子、举起方块、清理桌面和折叠布料
  • ☁️ 来自 LightWheel持续升级:云 simulation、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
拾取三个橙子放入盘子,然后将机械臂复位到静止 state。单臂 SO101 follower arm
LeIsaac-SO101-LiftCube-v0

LeIsaac-SO101-LiftCube-Direct-v0
将红色方块举起。单臂 SO101 follower arm
LeIsaac-SO101-CleanToyTable-v0

LeIsaac-SO101-CleanToyTable-BiArm-v0

LeIsaac-SO101-CleanToyTable-BiArm-Direct-v0
将两个字母 e 物体拾入盒子,并将机械臂复位到静止 state。单臂 SO101 follower arm

双臂 SO101 follower arm
LeIsaac-SO101-FoldCloth-BiArm-v0

LeIsaac-SO101-FoldCloth-BiArm-Direct-v0
折叠布料,并将机械臂复位到静止 state。

注意:此任务中只有 DirectEnv 支持 check_success。
双臂 SO101 follower arm

在 LeRobot 中用一行代码直接加载 LeIsaac

EnvHub:通过 HuggingFace 共享 LeIsaac 环境

EnvHub 是我们的可复现环境中心,用一行代码启动打包好的 simulation,立即开始实验,并向社区发布你自己的任务。

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,并演示随机 action rollout 和交互式 teleoperation。

随机 action

点击展开代码示例
# envhub_random_action.py

import torch
from lerobot.envs 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 的 teleoperation 栈可以驱动 simulation 机械臂。

连接 SO101 leader arm 控制器,运行下面的 calibration 命令。

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

然后启动 teleoperation 脚本。

点击展开代码示例
# 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 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 arm 设备操作 simulation 机械臂。

☁️ 云 simulation(无需 GPU)

没有本地 GPU 或合适的驱动?没问题!你可以在云端零配置运行 LeIsaac。 LeIsaac 在 NVIDIA Brev 上开箱即用,直接在浏览器中为你提供完全配置好的环境。

👉 从这里开始:https://lightwheelai.github.io/leisaac/docs/cloud_simulation/nvidia_brev

实例部署完成后,只需打开 80 端口(HTTP)的链接即可启动 Visual Studio Code Server(默认密码:password)。你可以从那里运行 simulation、编辑代码并可视化 IsaacLab 环境——全部在 Web 浏览器中完成。

无需 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 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 上更新