Skip to content

Conversation

@whats2000
Copy link

What this does

This PR adds a new script, lerobot_infer.py, providing a fast, pure inference mode for running robot policies without video encoding or dataset recording overhead.

Key features:

  • New CLI entry point: lerobot-infer
  • Real-time policy inference loop
  • Teleoperation support (optional)
  • Required camera streaming for policies that depend on vision
  • Keyboard controls (p/Space, t, r, Esc)
  • Automatic temporary metadata directory creation/cleanup
  • Optional visualization via --display_data=true

This improves the workflow for quickly testing robot policies on hardware.


How it was tested

The script was validated using a generic configuration with robot, teleop, and at least one camera stream, which is required for most vision-based policies.

Testers must use their own robot IDs, teleop IDs, ports, and camera setup.

Example test command (replace with your own devices):

uv run lerobot-infer \
    --robot.type=<ROBOT_TYPE> \
    --robot.port=<ROBOT_PORT> \
    --robot.id=<ROBOT_ID> \
    --robot.cameras="<YOUR_CAMERA_CONFIG>" \
    --policy.path=<POLICY_PATH> \
    --task=<TASK_NAME> \
    --teleop.type=<TELEOP_TYPE> \
    --teleop.port=<TELEOP_PORT> \
    --teleop.id=<TELEOP_ID>

Observed results:

  • Start and stop inference works correctly
  • Episode reset works correctly
  • Manual teleop control works successfully
  • Mode switching (policy ↔ teleop) works as intended

How to checkout & try? (for the reviewer)

Minimal example:

uv run lerobot-infer \
    --robot.type=<ROBOT_TYPE> \
    --robot.port=<ROBOT_PORT> \
    --robot.id=<ROBOT_ID> \
    --robot.cameras="<YOUR_CAMERA_CONFIG>" \
    --policy.path=<POLICY_PATH>

With teleop:

uv run lerobot-infer \
    --robot.type=<ROBOT_TYPE> \
    --robot.port=<ROBOT_PORT> \
    --robot.id=<ROBOT_ID> \
    --robot.cameras="<YOUR_CAMERA_CONFIG>" \
    --teleop.type=<TELEOP_TYPE> \
    --teleop.port=<TELEOP_PORT> \
    --teleop.id=<TELEOP_ID> \
    --policy.path=<POLICY_PATH>

Optional visualization:

--display_data=true

Keyboard controls:

  • p / Space → start/stop inference
  • t → toggle teleoperation
  • r → reset episode
  • Esc → exit

Copilot AI review requested due to automatic review settings November 20, 2025 02:35
Copilot finished reviewing on behalf of whats2000 November 20, 2025 02:41
@whats2000
Copy link
Author

Additional Notes

Current inference is using the record script, but this introduces several issues:

  • Slow episode transitions — each episode waits for video construction, which adds unnecessary delay during testing.
  • No immediate interruption — policies cannot be paused quickly in urgent situations (e.g., to prevent unsafe actions or hardware risks).
  • No convenient recovery path — switching to manual control is not supported, making it harder to recover or reset the robot during experiments.

This PR addresses all of the above by introducing a lightweight inference-only script with instant start/stop control, keyboard-based safety interruption, and optional teleoperation for recovery.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new fast inference script (lerobot_infer.py) designed for testing robot policies on hardware without the overhead of video encoding or dataset recording. The script provides a streamlined workflow with real-time keyboard controls for policy execution, teleoperation switching, and episode management.

Key Changes

  • Adds lerobot-infer CLI command for pure inference mode without recording
  • Implements keyboard-driven control flow (play/pause policy, toggle teleoperation, reset episodes, exit)
  • Supports optional real-time visualization via rerun when --display_data=true

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
src/lerobot/scripts/lerobot_infer.py New inference script with policy execution loop, keyboard listener, temporary dataset handling for policy metadata, and support for single/multi-teleop configurations
pyproject.toml Adds CLI entry point lerobot-infer to project scripts

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant