Spaces:
Running
Running
docs: improve entry into the project
Browse files- packages/web/README.md +14 -36
packages/web/README.md
CHANGED
|
@@ -1,20 +1,13 @@
|
|
| 1 |
# @lerobot/web
|
| 2 |
|
| 3 |
-
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
- **Direct Hardware Control**: STS3215 motor communication via WebSerial API
|
| 8 |
-
- **Device Persistence**: WebUSB API for automatic robot reconnection
|
| 9 |
-
- **Extensible Teleoperation**: Multiple input devices (keyboard, direct control, future: leader arms, joysticks)
|
| 10 |
-
- **Motor Calibration**: Automated homing offset and range recording
|
| 11 |
-
- **Cross-browser Support**: Chrome/Edge 89+ with HTTPS or localhost
|
| 12 |
-
- **TypeScript Native**: Full type safety and IntelliSense support
|
| 13 |
|
| 14 |
## Installation
|
| 15 |
|
| 16 |
```bash
|
| 17 |
-
# pnpm
|
| 18 |
pnpm add @lerobot/web
|
| 19 |
|
| 20 |
# npm
|
|
@@ -27,41 +20,29 @@ yarn add @lerobot/web
|
|
| 27 |
## Quick Start
|
| 28 |
|
| 29 |
```typescript
|
| 30 |
-
import {
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
calibrate,
|
| 34 |
-
teleoperate,
|
| 35 |
-
KeyboardTeleoperator,
|
| 36 |
-
DirectTeleoperator,
|
| 37 |
-
} from "@lerobot/web";
|
| 38 |
-
|
| 39 |
-
// 1. Find and connect to hardware
|
| 40 |
const findProcess = await findPort();
|
| 41 |
const robots = await findProcess.result;
|
| 42 |
const robot = robots[0];
|
| 43 |
|
| 44 |
-
// 2.
|
| 45 |
await releaseMotors(robot);
|
| 46 |
-
console.log("🔓 Motors released - you can move the robot by hand");
|
| 47 |
|
| 48 |
-
// 3.
|
| 49 |
const calibrationProcess = await calibrate({
|
| 50 |
robot,
|
| 51 |
onProgress: (message) => console.log(message),
|
| 52 |
onLiveUpdate: (data) => console.log("Live positions:", data),
|
| 53 |
});
|
| 54 |
|
| 55 |
-
//
|
| 56 |
-
//
|
| 57 |
-
|
| 58 |
-
console.log("⏱️ Stopping calibration...");
|
| 59 |
-
calibrationProcess.stop();
|
| 60 |
-
}, 10000); // Stop after 10 seconds, or call stop() when user is ready
|
| 61 |
-
|
| 62 |
const calibrationData = await calibrationProcess.result;
|
| 63 |
|
| 64 |
-
// 4.
|
| 65 |
const teleop = await teleoperate({
|
| 66 |
robot,
|
| 67 |
calibrationData,
|
|
@@ -69,11 +50,8 @@ const teleop = await teleoperate({
|
|
| 69 |
});
|
| 70 |
teleop.start();
|
| 71 |
|
| 72 |
-
//
|
| 73 |
-
|
| 74 |
-
console.log("⏹️ Stopping teleoperation...");
|
| 75 |
-
teleop.stop();
|
| 76 |
-
}, 30000); // Stop after 30 seconds, or call stop() when needed
|
| 77 |
```
|
| 78 |
|
| 79 |
## Core API
|
|
|
|
| 1 |
# @lerobot/web
|
| 2 |
|
| 3 |
+
interact with your robot in JS (WebSerial + WebUSB), inspired by [LeRobot](https://github.com/huggingface/lerobot)
|
| 4 |
|
| 5 |
+
🚀 **[Try the live demo →](https://huggingface.co/spaces/NERDDISCO/LeRobot.js)**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
## Installation
|
| 8 |
|
| 9 |
```bash
|
| 10 |
+
# pnpm
|
| 11 |
pnpm add @lerobot/web
|
| 12 |
|
| 13 |
# npm
|
|
|
|
| 20 |
## Quick Start
|
| 21 |
|
| 22 |
```typescript
|
| 23 |
+
import { findPort, releaseMotors, calibrate, teleoperate } from "@lerobot/web";
|
| 24 |
+
|
| 25 |
+
// 1. find and connect to hardware like a robot arm
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
const findProcess = await findPort();
|
| 27 |
const robots = await findProcess.result;
|
| 28 |
const robot = robots[0];
|
| 29 |
|
| 30 |
+
// 2. release the motors and put them into the homing position
|
| 31 |
await releaseMotors(robot);
|
|
|
|
| 32 |
|
| 33 |
+
// 3. calibrate the motors by moving each motor through its full range of motion
|
| 34 |
const calibrationProcess = await calibrate({
|
| 35 |
robot,
|
| 36 |
onProgress: (message) => console.log(message),
|
| 37 |
onLiveUpdate: (data) => console.log("Live positions:", data),
|
| 38 |
});
|
| 39 |
|
| 40 |
+
// when done, stop calibration and get the min/max ranges for each motor
|
| 41 |
+
// which we need to control the robot in its defined ranges
|
| 42 |
+
calibrationProcess.stop();
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
const calibrationData = await calibrationProcess.result;
|
| 44 |
|
| 45 |
+
// 4. start controlling the robot arm with your keyboard
|
| 46 |
const teleop = await teleoperate({
|
| 47 |
robot,
|
| 48 |
calibrationData,
|
|
|
|
| 50 |
});
|
| 51 |
teleop.start();
|
| 52 |
|
| 53 |
+
// stop any control
|
| 54 |
+
teleop.stop();
|
|
|
|
|
|
|
|
|
|
| 55 |
```
|
| 56 |
|
| 57 |
## Core API
|