feat(nao6): add SSH-based posture actions (wake_up, rest, stand, sit, crouch)

- Update plugin with sshCommand payloadMapping type
- Add server-side SSH command execution in robot-communication.ts
- Add client-side SSH command execution in wizard-ros-service.ts
- Update API route to handle executeSSH action
This commit is contained in:
2026-04-01 19:37:28 -04:00
parent 6243b62d3b
commit 27f633fb4b
3 changed files with 151 additions and 5 deletions
+29
View File
@@ -128,6 +128,35 @@ export async function POST(request: NextRequest) {
return NextResponse.json({ success: true });
}
case "executeSSH": {
const { command } = parameters ?? {};
if (!command) {
return NextResponse.json(
{ error: "Missing command parameter" },
{ status: 400 },
);
}
console.log(`[Robots API] Executing SSH command: ${command}`);
const sshCmd = `sshpass -p "${password}" ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 "nao@${robotIp}" "${command}"`;
try {
const { stdout, stderr } = await execAsync(sshCmd);
if (stderr && !stderr.includes("null") && stderr.trim()) {
console.warn(`[Robots API] SSH stderr: ${stderr}`);
}
console.log(`[Robots API] SSH result: ${stdout}`);
return NextResponse.json({ success: true, stdout, stderr });
} catch (error) {
console.error(`[Robots API] SSH command failed:`, error);
return NextResponse.json(
{ error: error instanceof Error ? error.message : "SSH command failed" },
{ status: 500 },
);
}
}
default:
return NextResponse.json(
{ error: `Unknown action: ${action}` },