File size: 3,219 Bytes
bdc1ac8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Node.js Quick Start Example (Vite)

This example demonstrates the complete workflow of using `@lerobot/node` to control robotics hardware from Node.js applications, using Vite for fast development and building. Follows the same pattern as the web Quick Start guide.

## What This Example Does

1. **Find Port**: Discovers and connects to your robot hardware
2. **Release Motors**: Puts motors in free-movement mode for setup
3. **Calibrate**: Records motor ranges and sets homing positions
4. **Teleoperate**: Enables keyboard control of the robot

## Hardware Requirements

- SO-100 robotic arm with STS3215 servos
- USB connection to your computer
- Compatible with Windows (COM ports), macOS, and Linux (/dev/tty\* ports)

## Installation

```bash
# Install dependencies (from project root)
pnpm install
```

## Running the Examples

### Full Workflow Demo

```bash
# Complete robot setup workflow (interactive)
pnpm demo:full-workflow
```

### Individual Component Demos

```bash
# Test port discovery
pnpm demo:find-port

# Test calibration (requires connected robot)
pnpm demo:calibrate

# Test keyboard control (requires calibrated robot)
pnpm demo:teleoperate
```

## Example Usage

The main demo (`src/main.ts`) shows the complete workflow:

```typescript
import { findPort, connectPort, releaseMotors, calibrate, teleoperate } from "@lerobot/node";

// 1. Find available robots
const findProcess = await findPort();
const robots = await findProcess.result;

// 2. Connect to first robot found
const robot = await connectPort(robots[0].path, "so100_follower", "my_robot_arm");

// 3. Release motors for manual positioning
await releaseMotors(robot);

// 4. Calibrate motor ranges
const calibrationProcess = await calibrate({
  robot,
  onProgress: (message) => console.log(message),
});

// 5. Control robot with keyboard
const teleop = await teleoperate({
  robot,
  teleop: { type: "keyboard" },
});
```

## CLI Commands

You can also use the CLI directly:

```bash
# Find available ports
npx lerobot find-port

# Calibrate robot
npx lerobot calibrate --robot.type so100_follower --robot.port /dev/ttyUSB0 --robot.id my_robot

# Control robot
npx lerobot teleoperate --robot.type so100_follower --robot.port /dev/ttyUSB0 --robot.id my_robot
```

## Development

```bash
# Run with Vite Node (faster development with hot reload)
pnpm dev

# Build with Vite and run compiled version
pnpm build && pnpm start
```

## Safety Notes

⚠️ **Important Safety Guidelines:**

- Always ensure robot is in a safe position before running examples
- Keep emergency stop accessible (ESC key during teleoperation)
- Start with small movements to test calibration
- Ensure robot has adequate workspace clearance

## Troubleshooting

**Port Not Found:**

- Check USB connection
- Verify robot is powered on
- Try different USB ports/cables
- On Linux: Check user permissions for serial ports

**Calibration Issues:**

- Ensure motors are released and can move freely
- Move each joint through its full range slowly
- Avoid forcing motors past mechanical limits

**Control Problems:**

- Verify calibration completed successfully
- Check that calibration file was saved
- Restart the teleoperation if motors don't respond