LeRobot

0.5.1 · active · verified Thu Apr 16

LeRobot is a state-of-the-art open-source Python library for real-world robotics using PyTorch, developed by Hugging Face. It provides tools for creating robot environments, loading pre-trained policies, and managing robotics datasets. It is currently at version 0.5.1 and is under active development, with new releases often including significant updates and breaking changes.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to load a pre-trained robotics policy from the Hugging Face Hub and use it to sample actions in a dummy environment. It showcases the core `load_policy` and `RobotEnvFactory` components.

from lerobot.common.policies.hf_hub.load import load_policy
from lerobot.common.robot_env_factory import RobotEnvFactory
import torch

# Load a pre-trained policy from the Hugging Face Hub
# This example uses a public model, so no explicit token is needed unless fine-tuning.
policy = load_policy("lerobot/diffusion_policy_v2_pen_push_multi_view_taco_play_sok_fixed_camera_v0")

# Create a dummy robot environment for demonstration
# Real environments require specific configurations like 'robomimic', 'taco_play', etc.
# e.g., env = RobotEnvFactory("taco_play", record_dir="./recordings")()
env = RobotEnvFactory("dummy")()

# Reset the environment to get initial observation
obs = env.reset()

# Sample actions from the policy
with torch.no_grad():
    action = policy.sample_actions(obs)

print(f"Initial observation keys: {obs.keys()}")
print(f"Sampled action shape: {action.shape}")
env.close()

view raw JSON →