From c959e61f95f63a2ed09f841d637c4f686818692a Mon Sep 17 00:00:00 2001 From: Sean O'Connor Date: Wed, 1 Apr 2026 18:58:26 -0400 Subject: [PATCH] fix(wizard): use API route for animations instead of ROS topic - Add executeAnimationSSH that calls /api/robots/command - Remove ROS topic publishing for animations - Fix play_animation_show_sole -> play_animation_friendly --- src/lib/ros/wizard-ros-service.ts | 78 ++++++++++++---------- src/server/services/robot-communication.ts | 2 +- 2 files changed, 44 insertions(+), 36 deletions(-) diff --git a/src/lib/ros/wizard-ros-service.ts b/src/lib/ros/wizard-ros-service.ts index ede487e..511cd92 100644 --- a/src/lib/ros/wizard-ros-service.ts +++ b/src/lib/ros/wizard-ros-service.ts @@ -926,48 +926,15 @@ export class WizardRosService extends EventEmitter { break; case "play_animation_bow": - this.publish("/animation", "std_msgs/String", { data: "animations/Stand/Gestures/BowShort_1" }); - await new Promise((resolve) => setTimeout(resolve, 2000)); - break; - case "play_animation_hey": - this.publish("/animation", "std_msgs/String", { data: "animations/Stand/Gestures/Hey_1" }); - await new Promise((resolve) => setTimeout(resolve, 2000)); - break; - case "play_animation_show_floor": - this.publish("/animation", "std_msgs/String", { data: "animations/Stand/Gestures/ShowFloor_1" }); - await new Promise((resolve) => setTimeout(resolve, 2000)); - break; - - case "play_animation_show_sole": - this.publish("/animation", "std_msgs/String", { data: "animations/Stand/Gestures/ShowSole_1" }); - await new Promise((resolve) => setTimeout(resolve, 2000)); - break; - + case "play_animation_friendly": case "play_animation_enthusiastic": - this.publish("/animation", "std_msgs/String", { data: "animations/Stand/Gestures/Enthusiastic_4" }); - await new Promise((resolve) => setTimeout(resolve, 2000)); - break; - case "play_animation_think": - this.publish("/animation", "std_msgs/String", { data: "animations/Stand/Gestures/Think_1" }); - await new Promise((resolve) => setTimeout(resolve, 2000)); - break; - case "play_animation_yes": - this.publish("/animation", "std_msgs/String", { data: "animations/Stand/Gestures/Yes_1" }); - await new Promise((resolve) => setTimeout(resolve, 2000)); - break; - case "play_animation_no": - this.publish("/animation", "std_msgs/String", { data: "animations/Stand/Gestures/No_3" }); - await new Promise((resolve) => setTimeout(resolve, 2000)); - break; - case "play_animation_idontknow": - this.publish("/animation", "std_msgs/String", { data: "animations/Stand/Gestures/IDontKnow_1" }); - await new Promise((resolve) => setTimeout(resolve, 2000)); + await this.executeAnimationSSH(actionId); break; default: @@ -1057,6 +1024,47 @@ export class WizardRosService extends EventEmitter { }); } + /** + * Execute animation via API route (SSH to robot) + */ + private async executeAnimationSSH(actionId: string): Promise { + const animationMap: Record = { + "play_animation_bow": "animations/Stand/Gestures/BowShort_1", + "play_animation_hey": "animations/Stand/Gestures/Hey_1", + "play_animation_show_floor": "animations/Stand/Gestures/ShowFloor_1", + "play_animation_friendly": "animations/Stand/Gestures/Friendly_1", + "play_animation_enthusiastic": "animations/Stand/Gestures/Enthusiastic_4", + "play_animation_think": "animations/Stand/Gestures/Think_1", + "play_animation_yes": "animations/Stand/Gestures/Yes_1", + "play_animation_no": "animations/Stand/Gestures/No_3", + "play_animation_idontknow": "animations/Stand/Gestures/IDontKnow_1", + }; + + const animation = animationMap[actionId]; + if (!animation) { + throw new Error(`Unknown animation: ${actionId}`); + } + + console.log(`[WizardROS] Executing animation via API: ${animation}`); + + // Use the robots command API to execute via SSH + const response = await fetch("/api/robots/command", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ + action: "executeSystemAction", + parameters: { id: actionId }, + }), + }); + + if (!response.ok) { + const error = await response.text(); + throw new Error(`Animation failed: ${error}`); + } + + console.log(`[WizardROS] Animation completed: ${animation}`); + } + /** * Set Autonomous Life state with fallbacks */ diff --git a/src/server/services/robot-communication.ts b/src/server/services/robot-communication.ts index 69fed09..1684692 100755 --- a/src/server/services/robot-communication.ts +++ b/src/server/services/robot-communication.ts @@ -269,7 +269,7 @@ export class RobotCommunicationService extends EventEmitter { "play_animation_bow": "animations/Stand/Gestures/BowShort_1", "play_animation_hey": "animations/Stand/Gestures/Hey_1", "play_animation_show_floor": "animations/Stand/Gestures/ShowFloor_1", - "play_animation_show_sole": "animations/Stand/Gestures/ShowSole_1", + "play_animation_friendly": "animations/Stand/Gestures/Friendly_1", "play_animation_enthusiastic": "animations/Stand/Gestures/Enthusiastic_4", "play_animation_think": "animations/Stand/Gestures/Think_1", "play_animation_yes": "animations/Stand/Gestures/Yes_1",