mirror of
https://github.com/soconnor0919/hristudio.git
synced 2026-05-15 08:29:52 -04:00
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:
@@ -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}` },
|
||||
|
||||
Reference in New Issue
Block a user