Spaces:
Running
Running
File size: 9,225 Bytes
c8b4583 ec936d5 c8b4583 ec936d5 c8b4583 ec936d5 c8b4583 ec936d5 c8b4583 ec936d5 c8b4583 ec936d5 c8b4583 ec936d5 c8b4583 ec936d5 c8b4583 ec936d5 c8b4583 ec936d5 c8b4583 ec936d5 c8b4583 ec936d5 c8b4583 ec936d5 c8b4583 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
# π€ lerobot.js
**State-of-the-art AI for real-world robotics in JavaScript/TypeScript**
A faithful TypeScript/JavaScript port of [Hugging Face's lerobot](https://github.com/huggingface/lerobot), bringing cutting-edge robotics AI to the JavaScript ecosystem with **zero Python dependencies**.
## π **[Complete SO-100 Setup Guide β](docs/getting_started_nodejs.md)**
**Get your SO-100 robot arms working in 10 minutes with lerobot.js!**
Step-by-step guide covering port detection, motor setup, calibration, and teleoperation.
## β¨ Features
- π **USB Port Detection**: Find robot arm serial ports in Node.js CLI and browser
- ποΈ **Robot Calibration**: Complete SO-100 follower/leader calibration system
- π **Universal**: Works in Node.js, browsers, and Edge devices
- π― **Python Faithful**: Identical UX and messaging to original lerobot
- π± **WebSerial**: Browser-native serial port access (Chrome/Edge 89+)
- π **Zero Dependencies**: No Python runtime required
- π¦ **Lightweight**: Pure TypeScript implementation
## π Quick Start
### Installation & Setup
```bash
# Option 1: Install globally (recommended)
npm install -g lerobot
# Option 2: Use directly with npx (no installation)
npx lerobot --help
# Verify installation
lerobot --help
```
### Essential Commands
```bash
# 1. Find USB ports for your robot arms
lerobot find-port
# 2. Calibrate follower robot
lerobot calibrate --robot.type=so100_follower --robot.port=COM4 --robot.id=my_follower_arm
# 3. Calibrate leader teleoperator
lerobot calibrate --teleop.type=so100_leader --teleop.port=COM3 --teleop.id=my_leader_arm
# Show command help
lerobot calibrate --help
```
### Alternative Usage Methods
```bash
# Method 1: Global CLI (after installation)
lerobot calibrate --robot.type=so100_follower --robot.port=COM4 --robot.id=my_robot
# Method 2: Direct with npx (no installation needed)
npx lerobot calibrate --robot.type=so100_follower --robot.port=COM4 --robot.id=my_robot
# Method 3: Development setup (if you cloned the repo)
git clone https://github.com/timpietrusky/lerobot.js
cd lerobot.js && pnpm install && pnpm run install-global
```
### Browser Usage
1. **Development**:
```bash
git clone https://github.com/timpietrusky/lerobot.js
cd lerobot.js
pnpm install
pnpm run dev
```
2. **Visit**: `http://localhost:5173`
3. **Use the interface**:
- Click "Show Available Ports" to see connected devices
- Click "Find MotorsBus Port" for guided port detection
## π Documentation
### Find USB Ports
Identify which USB ports your robot arms are connected to - essential for SO-100 setup.
#### CLI Example
```bash
$ lerobot find-port
Finding all available ports for the MotorsBus.
Ports before disconnecting: ['COM3', 'COM4']
Remove the USB cable from your MotorsBus and press Enter when done.
The port of this MotorsBus is 'COM3'
Reconnect the USB cable.
```
### Robot Calibration
Calibrate SO-100 robot arms for precise control and teleoperation.
#### Calibrate Follower Robot
```bash
$ lerobot calibrate --robot.type=so100_follower --robot.port=COM4 --robot.id=my_follower_arm
Calibrating device...
Device type: so100_follower
Port: COM4
ID: my_follower_arm
Connecting to so100_follower on port COM4...
Connected successfully.
Starting calibration procedure...
[... calibration steps ...]
Calibration completed successfully.
Configuration saved to: ~/.cache/huggingface/lerobot/calibration/robots/so100_follower/my_follower_arm.json
Disconnecting from robot...
```
#### Calibrate Leader Teleoperator
```bash
$ lerobot calibrate --teleop.type=so100_leader --teleop.port=COM3 --teleop.id=my_leader_arm
Calibrating teleoperator...
[... guided calibration process ...]
Configuration saved to: ~/.cache/huggingface/lerobot/calibration/teleoperators/so100_leader/my_leader_arm.json
```
### Browser Interface
1. **Visit**: Built-in web interface with calibration controls
2. **Port Selection**: Browser dialog for device selection
3. **Interactive Calibration**: Step-by-step guided process
4. **File Download**: Automatic calibration file download
### Platform Support
| Platform | Method | Requirements |
| ----------- | -------------------------------- | ----------------------------------- |
| **Node.js** | `lerobot find-port`, `calibrate` | Node.js 18+, Windows/macOS/Linux |
| **Browser** | Web interface + calibration | Chrome/Edge 89+, HTTPS or localhost |
| **Mobile** | Browser | Chrome Android 105+ |
### Browser Compatibility
The browser version uses the [WebSerial API](https://web.dev/serial/):
- β
**Chrome/Edge 89+** (Desktop)
- β
**Chrome Android 105+** (Mobile)
- β
**HTTPS** or localhost required
- β Firefox/Safari (WebSerial not supported)
## π οΈ Development
### Setup
```bash
git clone https://github.com/timpietrusky/lerobot.js
cd lerobot.js
pnpm install
```
### Scripts
```bash
# Development server (browser)
pnpm run dev
# Build CLI for Node.js
pnpm run build:cli
# Build web interface
pnpm run build:web
# Test CLI locally
pnpm run cli:find-port
# Build everything
pnpm run build
```
### Project Structure
```
src/
βββ lerobot/
β βββ node/
β β βββ find_port.ts # Node.js implementation
β βββ web/
β βββ find_port.ts # Browser implementation (WebSerial)
βββ cli/
β βββ index.ts # CLI interface
βββ main.ts # Web interface
βββ web_interface.css # UI styles
```
## π― Design Principles
### 1. Python lerobot Faithfulness
- **Identical commands**: `npx lerobot find-port` β `python -m lerobot.find_port`
- **Same terminology**: "MotorsBus", not "robot arms"
- **Matching output**: Error messages and workflows identical
- **Familiar UX**: Python lerobot users feel immediately at home
### 2. Platform Abstraction
- **Universal core**: Shared robotics logic
- **Adaptive UX**: CLI prompts vs. browser modals
- **Progressive enhancement**: Works everywhere, enhanced on capable platforms
### 3. Zero Dependencies
- **Node.js**: Only uses built-in modules + lightweight `serialport`
- **Browser**: Native WebSerial API, no external libraries
- **Deployment**: Single package, no Python runtime needed
## π§ Technical Details
### WebSerial API
The browser implementation leverages modern web APIs:
```typescript
// Request permission to access serial ports
await navigator.serial.requestPort();
// List granted ports
const ports = await navigator.serial.getPorts();
// Detect disconnected devices
const removedPorts = portsBefore.filter(/* ... */);
```
### CLI Implementation
Node.js version uses the `serialport` library for cross-platform compatibility:
```typescript
import { SerialPort } from "serialport";
// Cross-platform port detection
const ports = await SerialPort.list();
```
## πΊοΈ Roadmap
- [x] **Phase 1**: USB port detection (CLI + Browser)
- [ ] **Phase 2**: Motor communication and setup
- [x] **Phase 3**: Robot calibration tools β
**COMPLETE!**
- [ ] **Phase 4**: Dataset management and visualization
- [ ] **Phase 5**: Policy inference (ONNX.js)
- [ ] **Phase 6**: Training infrastructure
### β
Recently Completed
**Phase 3 - Robot Calibration (December 2024)**
- Complete SO-100 follower/leader calibration system
- CLI commands identical to Python lerobot
- Web browser calibration interface
- HF-compatible configuration storage
- Comprehensive error handling and validation
## π CLI Command Reference
### Available Commands
```bash
# Show all commands
lerobot --help
# Find USB ports
lerobot find-port
# Calibrate robot
lerobot calibrate --robot.type=so100_follower --robot.port=COM4 --robot.id=ROBOT_ID
# Calibrate teleoperator
lerobot calibrate --teleop.type=so100_leader --teleop.port=COM3 --teleop.id=TELEOP_ID
# Show calibration help
lerobot calibrate --help
```
### Configuration Files
Calibration data follows Hugging Face directory structure:
```
~/.cache/huggingface/lerobot/calibration/
βββ robots/
β βββ so100_follower/
β βββ ROBOT_ID.json
βββ teleoperators/
βββ so100_leader/
βββ TELEOP_ID.json
```
**Environment Variables:**
- `HF_HOME`: Override Hugging Face home directory
- `HF_LEROBOT_CALIBRATION`: Override calibration directory
## π€ Contributing
We welcome contributions! This project follows the principle of **Python lerobot faithfulness** - all features should maintain identical UX to the original.
### Guidelines
1. Check Python lerobot implementation first
2. Maintain identical command structure and messaging
3. Follow snake_case file naming convention
4. Test on both Node.js and browser platforms
## π License
Apache 2.0 - Same as original lerobot
## π Acknowledgments
- [Hugging Face lerobot team](https://github.com/huggingface/lerobot) for the original Python implementation
- [WebSerial API](https://web.dev/serial/) for browser-native hardware access
- [serialport](https://github.com/serialport/node-serialport) for Node.js cross-platform support
---
**Built with β€οΈ for the robotics community**
|