Spaces:
Running
Running
File size: 2,142 Bytes
540cfa6 c8b4583 ec936d5 ca45f6b 540cfa6 ec936d5 ca45f6b 540cfa6 ec936d5 ca45f6b 540cfa6 ec936d5 ca45f6b 540cfa6 |
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 |
#!/usr/bin/env node
/**
* lerobot.js CLI
*
* Provides command-line interface for lerobot functionality
* Maintains compatibility with Python lerobot command structure
*/
import { findPort } from "../lerobot/node/find_port.js";
import { main as calibrateMain } from "../lerobot/node/calibrate.js";
import { main as teleoperateMain } from "../lerobot/node/teleoperate.js";
/**
* Show usage information
*/
function showUsage() {
console.log("Usage: lerobot <command>");
console.log("");
console.log("Commands:");
console.log(
" find-port Find the USB port associated with your MotorsBus"
);
console.log(" calibrate Recalibrate your device (robot or teleoperator)");
console.log(" teleoperate Control a robot using keyboard input");
console.log("");
console.log("Examples:");
console.log(" lerobot find-port");
console.log(
" lerobot calibrate --robot.type=so100_follower --robot.port=COM4 --robot.id=my_follower_arm"
);
console.log(
" lerobot teleoperate --robot.type=so100_follower --robot.port=COM4 --teleop.type=keyboard"
);
console.log("");
}
/**
* Main CLI function
*/
async function main() {
const args = process.argv.slice(2);
if (args.length === 0) {
showUsage();
process.exit(1);
}
const command = args[0];
try {
switch (command) {
case "find-port":
await findPort();
break;
case "calibrate":
// Pass remaining arguments to calibrate command
const calibrateArgs = args.slice(1);
await calibrateMain(calibrateArgs);
break;
case "teleoperate":
// Pass remaining arguments to teleoperate command
const teleoperateArgs = args.slice(1);
await teleoperateMain(teleoperateArgs);
break;
case "help":
case "--help":
case "-h":
showUsage();
break;
default:
console.error(`Unknown command: ${command}`);
showUsage();
process.exit(1);
}
} catch (error) {
console.error("Error:", error instanceof Error ? error.message : error);
process.exit(1);
}
}
// Run the CLI
main();
|