File size: 4,873 Bytes
bdc1ac8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1552af3
 
bdc1ac8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1552af3
 
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
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
# lerobot

Python lerobot compatible CLI for Node.js. Provides the same command-line interface as Python lerobot with identical behavior and syntax.

## Installation

```bash
# Use directly with npx (recommended)
npx lerobot find-port

# Or install globally
npm install -g lerobot
lerobot find-port
```

## Commands

### Find Port

Discover robot port with interactive cable detection. Matches Python lerobot's `find_port.py` exactly.

```bash
# Interactive cable detection (always enabled, like Python lerobot)
lerobot find-port
```

This command follows Python lerobot's behavior exactly:

1. Lists initial ports
2. Prompts to unplug USB cable
3. Detects which port disappeared
4. Prompts to reconnect cable
5. Verifies port is restored

### Calibrate

Calibrate robot motors and save calibration data to Hugging Face cache.

```bash
lerobot calibrate \
  --robot.type=so100_follower \
  --robot.port=/dev/ttyUSB0 \
  --robot.id=my_follower_arm
```

**Options:**

- `--robot.type` - Robot type (e.g., `so100_follower`)
- `--robot.port` - Serial port (e.g., `/dev/ttyUSB0`, `COM4`)
- `--robot.id` - Robot identifier (default: `default`)
- `--output` - Custom output path for calibration file

**Compatible with:** `python -m lerobot calibrate`

### Teleoperate

Control robot through keyboard teleoperation.

```bash
lerobot teleoperate \
  --robot.type=so100_follower \
  --robot.port=/dev/ttyUSB0 \
  --robot.id=my_follower_arm
```

**Options:**

- `--robot.type` - Robot type (e.g., `so100_follower`)
- `--robot.port` - Serial port (e.g., `/dev/ttyUSB0`, `COM4`)
- `--robot.id` - Robot identifier (default: `default`)
- `--teleop.type` - Teleoperator type (default: `keyboard`)
- `--teleop.stepSize` - Step size for keyboard control (default: `25`)
- `--duration` - Duration in seconds, 0 = unlimited (default: `0`)

**Controls:**

- `w/s` - Motor 1 up/down
- `a/d` - Motor 2 left/right
- `q/e` - Motor 3 up/down
- `r/f` - Motor 4 forward/back
- `t/g` - Motor 5 up/down
- `y/h` - Motor 6 open/close
- `Ctrl+C` - Stop and exit

**Compatible with:** `python -m lerobot teleoperate`

### Release Motors

Release robot motors for manual movement.

```bash
lerobot release-motors \
  --robot.type=so100_follower \
  --robot.port=/dev/ttyUSB0 \
  --robot.id=my_follower_arm
```

**Options:**

- `--robot.type` - Robot type (e.g., `so100_follower`)
- `--robot.port` - Serial port (e.g., `/dev/ttyUSB0`, `COM4`)
- `--robot.id` - Robot identifier (default: `default`)
- `--motors` - Specific motor IDs to release (comma-separated)

**Compatible with:** `python -m lerobot release-motors`

## Python lerobot Compatibility

This CLI provides 100% compatible commands with Python lerobot:

| Python lerobot                     | Node.js lerobot              | Status        |
| ---------------------------------- | ---------------------------- | ------------- |
| `python -m lerobot find_port`      | `npx lerobot find-port`      | βœ… Compatible |
| `python -m lerobot calibrate`      | `npx lerobot calibrate`      | βœ… Compatible |
| `python -m lerobot teleoperate`    | `npx lerobot teleoperate`    | βœ… Compatible |
| `python -m lerobot release-motors` | `npx lerobot release-motors` | βœ… Compatible |

### Calibration Data Compatibility

Calibration files are saved to the same location as Python lerobot:

```
~/.cache/huggingface/lerobot/calibration/robots/{robot_type}/{robot_id}.json
```

This ensures calibration data is shared between Python and Node.js implementations.

## Examples

### Complete Workflow

```bash
# 1. Find your robot (interactive mode)
npx lerobot find-port --interactive
# Output: Detected port: /dev/ttyUSB0

# 2. Calibrate the robot
npx lerobot calibrate \
  --robot.type=so100_follower \
  --robot.port=/dev/ttyUSB0 \
  --robot.id=my_arm

# 3. Control the robot
npx lerobot teleoperate \
  --robot.type=so100_follower \
  --robot.port=/dev/ttyUSB0 \
  --robot.id=my_arm

# 4. Release motors when done
npx lerobot release-motors \
  --robot.type=so100_follower \
  --robot.port=/dev/ttyUSB0 \
  --robot.id=my_arm
```

### Automation Scripts

```bash
#!/bin/bash
# Automated calibration script

ROBOT_TYPE="so100_follower"
ROBOT_PORT="/dev/ttyUSB0"
ROBOT_ID="production_arm_1"

echo "Starting automated calibration..."
npx lerobot calibrate \
  --robot.type=$ROBOT_TYPE \
  --robot.port=$ROBOT_PORT \
  --robot.id=$ROBOT_ID

echo "Calibration complete. Starting teleoperation..."
npx lerobot teleoperate \
  --robot.type=$ROBOT_TYPE \
  --robot.port=$ROBOT_PORT \
  --robot.id=$ROBOT_ID \
  --duration=60  # Run for 60 seconds
```

## Requirements

- Node.js 18+
- Compatible with Windows, macOS, and Linux
- Same hardware requirements as Python lerobot

## Related Packages

- **[@lerobot/node](../node/)** - Node.js library for programmatic control
- **[@lerobot/web](../web/)** - Browser library for web applications

## License

Apache-2.0