import { useState } from "react"; import { Button } from "../components/ui/button"; import { Alert, AlertDescription } from "../components/ui/alert"; import { PortManager } from "../components/PortManager"; import { CalibrationPanel } from "../components/CalibrationPanel"; import { TeleoperationPanel } from "../components/TeleoperationPanel"; import { isWebSerialSupported } from "@lerobot/web"; import type { RobotConnection } from "@lerobot/web"; interface HomeProps { connectedRobots: RobotConnection[]; onConnectedRobotsChange: (robots: RobotConnection[]) => void; } export function Home({ connectedRobots, onConnectedRobotsChange }: HomeProps) { const [calibratingRobot, setCalibratingRobot] = useState(null); const [teleoperatingRobot, setTeleoperatingRobot] = useState(null); const isSupported = isWebSerialSupported(); const handleCalibrate = (port: SerialPort) => { // Find the robot from connectedRobots const robot = connectedRobots.find((r) => r.port === port); if (robot) { setCalibratingRobot(robot); } }; const handleTeleoperate = (robot: RobotConnection) => { setTeleoperatingRobot(robot); }; const handleFinishCalibration = () => { setCalibratingRobot(null); }; const handleFinishTeleoperation = () => { setTeleoperatingRobot(null); }; return (
{/* Header */}

🤖 LeRobot.js

Robotics for the web and node

{!isSupported && ( Web Serial API is not supported in this browser. Please use Chrome, Edge, or another Chromium-based browser to use this demo. )}
{/* Main Content */} {calibratingRobot ? (
) : teleoperatingRobot ? ( ) : (
)}
); }