"use client"; import type React from "react"; import { Book, Code2, Terminal, Copy, Check } from "lucide-react"; import { Button } from "@/components/ui/button"; import { useState } from "react"; import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; import { oneDark } from "react-syntax-highlighter/dist/esm/styles/prism"; const CodeBlock = ({ children, language = "typescript", }: { children: React.ReactNode; language?: string; }) => { const [copied, setCopied] = useState(false); const copyToClipboard = async (text: string) => { try { await navigator.clipboard.writeText(text); setCopied(true); setTimeout(() => setCopied(false), 2000); } catch (err) { console.error("Failed to copy:", err); } }; const codeText = typeof children === "string" ? children : children?.toString() || ""; return (
Complete API reference for @lerobot/web
Complete workflow from discovery to teleoperation.
Discovers and connects to robotics hardware using WebSerial API.
robotConfigs?: RobotConfig[]
- Auto-connect
to these known robots
onMessage?: (message: string) => void
-
Progress messages callback
FindPortProcess
result: Promise<RobotConnection[]>
-
Array of robot connections
stop(): void
- Cancel discovery process
Calibrates motor homing offsets and records range of motion.
robot: RobotConnection
- Connected robot from
findPort()
onProgress?: (message: string) => void
-
Progress messages callback
onLiveUpdate?: (data: LiveCalibrationData) => void
{" "}
- Real-time position updates
CalibrationProcess
result: Promise<WebCalibrationResults>
{" "}
- Python-compatible format
stop(): void
- Stop calibration process
Enables real-time robot control with extensible input devices.
robot: RobotConnection
- Connected robot from
findPort()
teleop: TeleoperatorConfig
- Teleoperator
configuration:
{`{ type: "keyboard" }`}
- Keyboard
control
{`{ type: "direct" }`}
- Direct
programmatic control
calibrationData?: {`{ [motorName: string]: any }`}
{" "}
- Calibration data from calibrate()
onStateUpdate?: (state: TeleoperationState) => void
{" "}
- State change callback
TeleoperationProcess
start(): void
- Begin teleoperation
stop(): void
- Stop teleoperation and clear
states
getState(): TeleoperationState
- Current
state and motor positions
teleoperator: BaseWebTeleoperator
- Access
teleoperator-specific methods
disconnect(): Promise<void>
- Stop and
disconnect
Releases motor torque so robot can be moved freely by hand.
robot: RobotConnection
- Connected robot
motorIds?: number[]
- Specific motor IDs
(default: all motors for robot type)