nao6 ros2 integration updated

This commit is contained in:
2025-11-13 10:58:45 -05:00
parent 70882b9dbb
commit 86b5ed80c4
276 changed files with 4288 additions and 1552 deletions

57
scripts/seed-dev.ts Normal file → Executable file
View File

@@ -306,17 +306,6 @@ async function main() {
syncStatus: "pending" as const,
createdBy: seanUser.id,
},
{
name: "NAO6 ROS2 Integration Repository",
url: "http://localhost:3000/nao6-plugins",
description:
"Official NAO6 robot plugins for ROS2-based Human-Robot Interaction experiments",
trustLevel: "official" as const,
isEnabled: true,
isOfficial: true,
syncStatus: "pending" as const,
createdBy: seanUser.id,
},
];
const insertedRepos = await db
@@ -428,24 +417,30 @@ async function main() {
);
}
// Install NAO plugin for first study if available
console.log("🤝 Installing NAO plugin (if available)...");
// Install NAO6 ROS2 plugin for first study if available
console.log("🤝 Installing NAO6 ROS2 plugin (if available)...");
const naoPlugin = await db
.select()
.from(schema.plugins)
.where(eq(schema.plugins.name, "NAO Humanoid Robot"))
.where(eq(schema.plugins.name, "NAO6 Robot (ROS2 Integration)"))
.limit(1);
if (naoPlugin.length > 0 && insertedStudies[0]) {
await db.insert(schema.studyPlugins).values({
studyId: insertedStudies[0].id,
pluginId: naoPlugin[0]!.id,
configuration: { voice: "nao-tts", locale: "en-US" },
configuration: {
robotIp: "nao.local",
websocketUrl: "ws://localhost:9090",
maxLinearVelocity: 0.3,
maxAngularVelocity: 1.0,
defaultSpeed: 0.5,
},
installedBy: seanUser.id,
});
console.log("✅ Installed NAO plugin in first study");
console.log("✅ Installed NAO6 ROS2 plugin in first study");
} else {
console.log(
" NAO plugin not found in repository sync; continuing without it",
" NAO6 ROS2 plugin not found in repository sync; continuing without it",
);
}
@@ -557,31 +552,31 @@ async function main() {
retryable: false,
});
// Resolve NAO plugin id/version for namespaced action type
// Resolve NAO6 ROS2 plugin id/version for namespaced action type
const naoDbPlugin1 = await db
.select({ id: schema.plugins.id, version: schema.plugins.version })
.from(schema.plugins)
.where(eq(schema.plugins.name, "NAO Humanoid Robot"))
.where(eq(schema.plugins.name, "NAO6 Robot (ROS2 Integration)"))
.limit(1);
const naoPluginRow1 = naoDbPlugin1[0];
// Action 1.2: Robot/NAO says text (or wizard says fallback)
// Action 1.2: Robot/NAO speaks text
await db.insert(schema.actions).values({
stepId: step1Id,
name: naoPluginRow1 ? "NAO Say Text" : "Wizard Say",
name: naoPluginRow1 ? "NAO Speak Text" : "Wizard Say",
description: naoPluginRow1
? "Make the robot speak using text-to-speech"
? "Make the robot speak using text-to-speech via ROS2"
: "Wizard speaks to participant",
type: naoPluginRow1 ? `${naoPluginRow1.id}.say_text` : "wizard_say",
type: naoPluginRow1 ? `${naoPluginRow1.id}.nao6_speak` : "wizard_say",
orderIndex: 1,
parameters: naoPluginRow1
? { text: "Hello, I am NAO. Let's begin!", speed: 110, volume: 0.75 }
? { text: "Hello, I am NAO. Let's begin!", volume: 0.8 }
: { message: "Hello! Let's begin the session.", tone: "friendly" },
sourceKind: naoPluginRow1 ? "plugin" : "core",
pluginId: naoPluginRow1 ? naoPluginRow1.id : null,
pluginVersion: naoPluginRow1 ? naoPluginRow1.version : null,
category: naoPluginRow1 ? "robot" : "wizard",
transport: naoPluginRow1 ? "rest" : "internal",
transport: naoPluginRow1 ? "ros2" : "internal",
retryable: false,
});
@@ -635,23 +630,23 @@ async function main() {
const naoDbPlugin2 = await db
.select({ id: schema.plugins.id, version: schema.plugins.version })
.from(schema.plugins)
.where(eq(schema.plugins.name, "NAO Humanoid Robot"))
.where(eq(schema.plugins.name, "NAO6 Robot (ROS2 Integration)"))
.limit(1);
const naoPluginRow2 = naoDbPlugin2[0];
if (naoPluginRow2) {
await db.insert(schema.actions).values({
stepId: step3Id,
name: "Set LED Color",
description: "Change NAO's eye LEDs to reflect state",
type: `${naoPluginRow2.id}.set_led_color`,
name: "NAO Move Head",
description: "Move NAO's head to look at participant",
type: `${naoPluginRow2.id}.nao6_move_head`,
orderIndex: 0,
parameters: { color: "blue", intensity: 0.6 },
parameters: { yaw: 0.0, pitch: -0.2, speed: 0.3 },
sourceKind: "plugin",
pluginId: naoPluginRow2.id,
pluginVersion: naoPluginRow2.version,
category: "robot",
transport: "rest",
transport: "ros2",
retryable: false,
});
} else {

631
scripts/seed-nao6-plugin.ts Normal file
View File

@@ -0,0 +1,631 @@
#!/usr/bin/env bun
/**
* Seed NAO6 Plugin into HRIStudio Database
*
* This script adds the NAO6 ROS2 integration plugin to the HRIStudio database,
* including the plugin repository and plugin definition with all available actions.
*/
import { drizzle } from "drizzle-orm/postgres-js";
import postgres from "postgres";
import { env } from "~/env";
import {
plugins,
pluginRepositories,
robots,
users,
type InsertPlugin,
type InsertPluginRepository,
type InsertRobot,
} from "~/server/db/schema";
import { eq } from "drizzle-orm";
const connectionString = env.DATABASE_URL;
const client = postgres(connectionString);
const db = drizzle(client);
async function seedNAO6Plugin() {
console.log("🤖 Seeding NAO6 plugin into HRIStudio database...");
try {
// 0. Get system user for created_by fields
console.log("👤 Getting system user...");
const systemUser = await db
.select()
.from(users)
.where(eq(users.email, "sean@soconnor.dev"))
.limit(1);
if (systemUser.length === 0) {
throw new Error(
"System user not found. Please run 'bun db:seed' first to create initial users.",
);
}
const userId = systemUser[0]!.id;
console.log(`✅ Found system user: ${userId}`);
// 1. Create or update NAO6 robot entry
console.log("📋 Creating NAO6 robot entry...");
const existingRobot = await db
.select()
.from(robots)
.where(eq(robots.name, "NAO6"))
.limit(1);
let robotId: string;
if (existingRobot.length > 0) {
robotId = existingRobot[0]!.id;
console.log(`✅ Found existing NAO6 robot: ${robotId}`);
} else {
const newRobots = await db
.insert(robots)
.values({
name: "NAO6",
manufacturer: "SoftBank Robotics",
model: "NAO V6.0",
description:
"Humanoid robot designed for education, research, and human-robot interaction studies. Features bipedal walking, speech synthesis, cameras, and comprehensive sensor suite.",
capabilities: [
"bipedal_walking",
"speech_synthesis",
"head_movement",
"arm_gestures",
"touch_sensors",
"visual_sensors",
"audio_sensors",
"posture_control",
"balance_control",
],
communicationProtocol: "ros2",
} satisfies InsertRobot)
.returning();
robotId = newRobots[0]!.id;
console.log(`✅ Created NAO6 robot: ${robotId}`);
}
// 2. Create or update plugin repository
console.log("📦 Creating NAO6 plugin repository...");
const existingRepo = await db
.select()
.from(pluginRepositories)
.where(eq(pluginRepositories.name, "NAO6 ROS2 Integration Repository"))
.limit(1);
let repoId: string;
if (existingRepo.length > 0) {
repoId = existingRepo[0]!.id;
console.log(`✅ Found existing repository: ${repoId}`);
} else {
const newRepos = await db
.insert(pluginRepositories)
.values({
name: "NAO6 ROS2 Integration Repository",
url: "https://github.com/hristudio/nao6-ros2-plugins",
description:
"Official NAO6 robot plugins for ROS2-based Human-Robot Interaction experiments",
trustLevel: "official",
isActive: true,
isPublic: true,
createdBy: userId,
status: "active",
lastSyncedAt: new Date(),
metadata: {
author: {
name: "HRIStudio Team",
email: "support@hristudio.com",
},
license: "MIT",
ros2: {
distro: "humble",
packages: [
"naoqi_driver2",
"naoqi_bridge_msgs",
"rosbridge_suite",
],
},
supportedRobots: ["NAO6"],
categories: [
"movement",
"speech",
"sensors",
"interaction",
"vision",
],
},
} satisfies InsertPluginRepository)
.returning();
repoId = newRepos[0]!.id;
console.log(`✅ Created repository: ${repoId}`);
}
// 3. Create or update NAO6 plugin
console.log("🔌 Creating NAO6 enhanced plugin...");
const existingPlugin = await db
.select()
.from(plugins)
.where(eq(plugins.name, "NAO6 Robot (Enhanced ROS2 Integration)"))
.limit(1);
const actionDefinitions = [
{
id: "nao_speak",
name: "Speak Text",
description:
"Make the NAO robot speak the specified text using text-to-speech synthesis",
category: "speech",
icon: "volume2",
parametersSchema: {
type: "object",
properties: {
text: {
type: "string",
title: "Text to Speak",
description: "The text that the robot should speak aloud",
minLength: 1,
maxLength: 500,
},
volume: {
type: "number",
title: "Volume",
description: "Speech volume level (0.1 = quiet, 1.0 = loud)",
default: 0.7,
minimum: 0.1,
maximum: 1.0,
step: 0.1,
},
speed: {
type: "number",
title: "Speech Speed",
description: "Speech rate multiplier (0.5 = slow, 2.0 = fast)",
default: 1.0,
minimum: 0.5,
maximum: 2.0,
step: 0.1,
},
},
required: ["text"],
},
implementation: {
type: "ros2_topic",
topic: "/speech",
messageType: "std_msgs/String",
},
},
{
id: "nao_move",
name: "Move Robot",
description:
"Move the NAO robot with specified linear and angular velocities",
category: "movement",
icon: "move",
parametersSchema: {
type: "object",
properties: {
direction: {
type: "string",
title: "Movement Direction",
description: "Predefined movement direction",
enum: [
"forward",
"backward",
"left",
"right",
"turn_left",
"turn_right",
],
default: "forward",
},
distance: {
type: "number",
title: "Distance (meters)",
description: "Distance to move in meters",
default: 0.1,
minimum: 0.01,
maximum: 2.0,
step: 0.01,
},
speed: {
type: "number",
title: "Movement Speed",
description: "Speed factor (0.1 = very slow, 1.0 = normal speed)",
default: 0.5,
minimum: 0.1,
maximum: 1.0,
step: 0.1,
},
},
required: ["direction"],
},
implementation: {
type: "ros2_topic",
topic: "/cmd_vel",
messageType: "geometry_msgs/Twist",
},
},
{
id: "nao_pose",
name: "Set Posture",
description: "Set the NAO robot to a specific posture or pose",
category: "movement",
icon: "user",
parametersSchema: {
type: "object",
properties: {
posture: {
type: "string",
title: "Posture",
description: "Target posture for the robot",
enum: ["Stand", "Sit", "SitRelax", "StandInit", "Crouch"],
default: "Stand",
},
speed: {
type: "number",
title: "Movement Speed",
description:
"Speed of posture transition (0.1 = slow, 1.0 = fast)",
default: 0.5,
minimum: 0.1,
maximum: 1.0,
step: 0.1,
},
},
required: ["posture"],
},
implementation: {
type: "ros2_service",
service: "/naoqi_driver/robot_posture/go_to_posture",
serviceType: "naoqi_bridge_msgs/srv/SetString",
},
},
{
id: "nao_head_movement",
name: "Move Head",
description:
"Control NAO robot head movement for gaze direction and attention",
category: "movement",
icon: "eye",
parametersSchema: {
type: "object",
properties: {
headYaw: {
type: "number",
title: "Head Yaw (degrees)",
description:
"Left/right head rotation (-90° = right, +90° = left)",
default: 0.0,
minimum: -90.0,
maximum: 90.0,
step: 1.0,
},
headPitch: {
type: "number",
title: "Head Pitch (degrees)",
description: "Up/down head rotation (-25° = down, +25° = up)",
default: 0.0,
minimum: -25.0,
maximum: 25.0,
step: 1.0,
},
speed: {
type: "number",
title: "Movement Speed",
description: "Speed of head movement (0.1 = slow, 1.0 = fast)",
default: 0.3,
minimum: 0.1,
maximum: 1.0,
step: 0.1,
},
},
required: [],
},
implementation: {
type: "ros2_topic",
topic: "/joint_angles",
messageType: "naoqi_bridge_msgs/JointAnglesWithSpeed",
},
},
{
id: "nao_gesture",
name: "Perform Gesture",
description:
"Make NAO robot perform predefined gestures and animations",
category: "interaction",
icon: "hand",
parametersSchema: {
type: "object",
properties: {
gesture: {
type: "string",
title: "Gesture Type",
description: "Select a predefined gesture or animation",
enum: [
"wave",
"point_left",
"point_right",
"applause",
"thumbs_up",
],
default: "wave",
},
intensity: {
type: "number",
title: "Gesture Intensity",
description:
"Intensity of the gesture movement (0.5 = subtle, 1.0 = full)",
default: 0.8,
minimum: 0.3,
maximum: 1.0,
step: 0.1,
},
},
required: ["gesture"],
},
implementation: {
type: "ros2_service",
service: "/naoqi_driver/animation_player/run_animation",
serviceType: "naoqi_bridge_msgs/srv/SetString",
},
},
{
id: "nao_sensor_monitor",
name: "Monitor Sensors",
description: "Monitor NAO robot sensors for interaction detection",
category: "sensors",
icon: "activity",
parametersSchema: {
type: "object",
properties: {
sensorType: {
type: "string",
title: "Sensor Type",
description: "Which sensors to monitor",
enum: ["touch", "bumper", "sonar", "all"],
default: "touch",
},
duration: {
type: "number",
title: "Duration (seconds)",
description: "How long to monitor sensors",
default: 10,
minimum: 1,
maximum: 300,
},
},
required: ["sensorType"],
},
implementation: {
type: "ros2_subscription",
topics: [
"/naoqi_driver/bumper",
"/naoqi_driver/hand_touch",
"/naoqi_driver/head_touch",
],
},
},
{
id: "nao_emergency_stop",
name: "Emergency Stop",
description: "Immediately stop all robot movement for safety",
category: "safety",
icon: "stop-circle",
parametersSchema: {
type: "object",
properties: {
stopType: {
type: "string",
title: "Stop Type",
description: "Type of emergency stop",
enum: ["movement", "all"],
default: "all",
},
},
required: [],
},
implementation: {
type: "ros2_topic",
topic: "/cmd_vel",
messageType: "geometry_msgs/Twist",
},
},
{
id: "nao_wake_rest",
name: "Wake Up / Rest Robot",
description: "Wake up the robot or put it to rest position",
category: "system",
icon: "power",
parametersSchema: {
type: "object",
properties: {
action: {
type: "string",
title: "Action",
description: "Wake up robot or put to rest",
enum: ["wake", "rest"],
default: "wake",
},
},
required: ["action"],
},
implementation: {
type: "ros2_service",
service: "/naoqi_driver/motion/wake_up",
serviceType: "std_srvs/srv/Empty",
},
},
{
id: "nao_status_check",
name: "Check Robot Status",
description: "Get current robot status including battery and health",
category: "system",
icon: "info",
parametersSchema: {
type: "object",
properties: {
statusType: {
type: "string",
title: "Status Type",
description: "What status information to retrieve",
enum: ["basic", "battery", "sensors", "all"],
default: "basic",
},
},
required: ["statusType"],
},
implementation: {
type: "ros2_service",
service: "/naoqi_driver/get_robot_config",
serviceType: "naoqi_bridge_msgs/srv/GetRobotInfo",
},
},
];
const pluginData: InsertPlugin = {
repositoryId: repoId,
robotId: robotId,
name: "NAO6 Robot (Enhanced ROS2 Integration)",
version: "2.0.0",
description:
"Comprehensive NAO6 robot integration for HRIStudio experiments via ROS2. Provides full robot control including movement, speech synthesis, posture control, sensor monitoring, and safety features.",
author: "HRIStudio RoboLab Team",
repositoryUrl: "https://github.com/hristudio/nao6-ros2-plugins",
trustLevel: "official",
status: "active",
configurationSchema: {
type: "object",
properties: {
robotIp: {
type: "string",
default: "nao.local",
title: "Robot IP Address",
description: "IP address or hostname of the NAO6 robot",
},
robotPassword: {
type: "string",
default: "robolab",
title: "Robot Password",
description: "Password for robot authentication",
format: "password",
},
websocketUrl: {
type: "string",
default: "ws://localhost:9090",
title: "WebSocket URL",
description: "ROS bridge WebSocket URL for robot communication",
},
maxLinearVelocity: {
type: "number",
default: 0.2,
minimum: 0.01,
maximum: 0.5,
title: "Max Linear Velocity (m/s)",
description: "Maximum allowed linear movement speed for safety",
},
speechVolume: {
type: "number",
default: 0.7,
minimum: 0.1,
maximum: 1.0,
title: "Speech Volume",
description: "Default volume for speech synthesis",
},
enableSafetyMonitoring: {
type: "boolean",
default: true,
title: "Enable Safety Monitoring",
description:
"Enable automatic safety monitoring and emergency stops",
},
},
required: ["robotIp", "websocketUrl"],
},
actionDefinitions: actionDefinitions,
metadata: {
robotModel: "NAO V6.0",
manufacturer: "SoftBank Robotics",
naoqiVersion: "2.8.7.4",
ros2Distro: "humble",
launchPackage: "nao_launch",
capabilities: [
"bipedal_walking",
"speech_synthesis",
"head_movement",
"arm_gestures",
"touch_sensors",
"visual_sensors",
"posture_control",
],
tags: [
"nao6",
"ros2",
"speech",
"movement",
"sensors",
"hri",
"production",
],
},
};
if (existingPlugin.length > 0) {
await db
.update(plugins)
.set({
...pluginData,
updatedAt: new Date(),
})
.where(eq(plugins.id, existingPlugin[0]!.id));
console.log(`✅ Updated existing NAO6 plugin: ${existingPlugin[0]!.id}`);
} else {
const newPlugins = await db
.insert(plugins)
.values(pluginData)
.returning();
console.log(`✅ Created NAO6 plugin: ${newPlugins[0]!.id}`);
}
console.log("\n🎉 NAO6 plugin seeding completed successfully!");
console.log("\nNext steps:");
console.log("1. Install the plugin in a study via the HRIStudio interface");
console.log("2. Configure the robot IP and WebSocket URL");
console.log(
"3. Launch ROS integration: ros2 launch nao_launch nao6_production.launch.py",
);
console.log("4. Test robot actions in the experiment designer");
console.log("\n📊 Plugin Summary:");
console.log(` Robot: NAO6 (${robotId})`);
console.log(` Repository: NAO6 ROS2 Integration (${repoId})`);
console.log(` Actions: ${actionDefinitions.length} available`);
console.log(
" Categories: speech, movement, interaction, sensors, safety, system",
);
} catch (error) {
console.error("❌ Error seeding NAO6 plugin:", error);
throw error;
} finally {
await client.end();
}
}
// Run the seeding script
seedNAO6Plugin()
.then(() => {
console.log("✅ Database seeding completed");
process.exit(0);
})
.catch((error) => {
console.error("❌ Database seeding failed:", error);
process.exit(1);
});

0
scripts/test-seed-data.ts Normal file → Executable file
View File

View File

@@ -0,0 +1,561 @@
#!/bin/bash
#
# NAO6 HRIStudio Integration Verification Script
#
# This script performs comprehensive verification of the NAO6 integration with HRIStudio,
# checking all components from ROS2 workspace to database plugins and providing
# detailed status and next steps.
#
# Usage: ./verify-nao6-integration.sh [--robot-ip IP] [--verbose]
#
set -e
# =================================================================
# CONFIGURATION AND DEFAULTS
# =================================================================
NAO_IP="${1:-nao.local}"
VERBOSE=false
HRISTUDIO_DIR="${HOME}/Documents/Projects/hristudio"
ROS_WS="${HOME}/naoqi_ros2_ws"
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
PURPLE='\033[0;35m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
# =================================================================
# UTILITY FUNCTIONS
# =================================================================
log_info() {
echo -e "${BLUE}[INFO]${NC} $1"
}
log_success() {
echo -e "${GREEN}[✅ PASS]${NC} $1"
}
log_warning() {
echo -e "${YELLOW}[⚠️ WARN]${NC} $1"
}
log_error() {
echo -e "${RED}[❌ FAIL]${NC} $1"
}
log_step() {
echo -e "${PURPLE}[STEP]${NC} $1"
}
log_verbose() {
if [ "$VERBOSE" = true ]; then
echo -e "${CYAN}[DEBUG]${NC} $1"
fi
}
show_header() {
echo -e "${CYAN}"
echo "================================================================="
echo " NAO6 HRIStudio Integration Verification"
echo "================================================================="
echo -e "${NC}"
echo "Target Robot: $NAO_IP"
echo "HRIStudio: $HRISTUDIO_DIR"
echo "ROS Workspace: $ROS_WS"
echo ""
}
# =================================================================
# VERIFICATION FUNCTIONS
# =================================================================
check_prerequisites() {
log_step "Checking prerequisites and dependencies..."
local errors=0
# Check ROS2 installation
if command -v ros2 >/dev/null 2>&1; then
local ros_distro=$(ros2 --version 2>/dev/null | grep -o "humble\|iron\|rolling" || echo "unknown")
log_success "ROS2 found (distro: $ros_distro)"
else
log_error "ROS2 not found - install ROS2 Humble"
((errors++))
fi
# Check required tools
local tools=("ping" "ssh" "sshpass" "bun" "docker")
for tool in "${tools[@]}"; do
if command -v $tool >/dev/null 2>&1; then
log_success "$tool available"
else
log_warning "$tool not found (may be optional)"
fi
done
# Check ROS workspace
if [ -d "$ROS_WS" ]; then
log_success "NAOqi ROS2 workspace found"
if [ -f "$ROS_WS/install/setup.bash" ]; then
log_success "ROS workspace built and ready"
else
log_warning "ROS workspace not built - run: cd $ROS_WS && colcon build"
fi
else
log_error "NAOqi ROS2 workspace not found at $ROS_WS"
((errors++))
fi
# Check HRIStudio directory
if [ -d "$HRISTUDIO_DIR" ]; then
log_success "HRIStudio directory found"
if [ -f "$HRISTUDIO_DIR/package.json" ]; then
log_success "HRIStudio package configuration found"
else
log_warning "HRIStudio package.json not found"
fi
else
log_error "HRIStudio directory not found at $HRISTUDIO_DIR"
((errors++))
fi
return $errors
}
check_nao_launch_package() {
log_step "Verifying nao_launch package..."
local errors=0
local package_dir="$ROS_WS/src/nao_launch"
if [ -d "$package_dir" ]; then
log_success "nao_launch package directory found"
# Check launch files
local launch_files=(
"nao6_hristudio.launch.py"
"nao6_production.launch.py"
"nao6_hristudio_enhanced.launch.py"
)
for launch_file in "${launch_files[@]}"; do
if [ -f "$package_dir/launch/$launch_file" ]; then
log_success "Launch file: $launch_file"
else
log_warning "Missing launch file: $launch_file"
fi
done
# Check scripts
if [ -d "$package_dir/scripts" ]; then
log_success "Scripts directory found"
local scripts=("nao_control.py" "start_nao6_hristudio.sh")
for script in "${scripts[@]}"; do
if [ -f "$package_dir/scripts/$script" ]; then
log_success "Script: $script"
else
log_warning "Missing script: $script"
fi
done
else
log_warning "Scripts directory not found"
fi
# Check if package is built
if [ -f "$ROS_WS/install/nao_launch/share/nao_launch/package.xml" ]; then
log_success "nao_launch package built and installed"
else
log_warning "nao_launch package not built - run: cd $ROS_WS && colcon build --packages-select nao_launch"
fi
else
log_error "nao_launch package directory not found"
((errors++))
fi
return $errors
}
check_robot_connectivity() {
log_step "Testing NAO robot connectivity..."
local errors=0
# Test ping
log_verbose "Testing ping to $NAO_IP..."
if ping -c 2 -W 3 "$NAO_IP" >/dev/null 2>&1; then
log_success "Robot responds to ping"
else
log_error "Cannot ping robot at $NAO_IP - check network/IP"
((errors++))
return $errors
fi
# Test NAOqi port
log_verbose "Testing NAOqi service on port 9559..."
if timeout 5 bash -c "echo >/dev/tcp/$NAO_IP/9559" 2>/dev/null; then
log_success "NAOqi service accessible on port 9559"
else
log_error "Cannot connect to NAOqi on $NAO_IP:9559"
((errors++))
fi
# Test SSH (optional)
log_verbose "Testing SSH connectivity (optional)..."
if timeout 5 ssh -o StrictHostKeyChecking=no -o ConnectTimeout=3 -o BatchMode=yes nao@$NAO_IP echo "SSH test" >/dev/null 2>&1; then
log_success "SSH connectivity working"
else
log_warning "SSH connectivity failed - may need password for wake-up"
fi
return $errors
}
check_hristudio_database() {
log_step "Checking HRIStudio database and plugins..."
local errors=0
# Check if database is running
if docker ps | grep -q postgres || ss -ln | grep -q :5432 || ss -ln | grep -q :5140; then
log_success "Database appears to be running"
# Try to query database (requires HRIStudio to be set up)
cd "$HRISTUDIO_DIR" 2>/dev/null || true
if [ -f "$HRISTUDIO_DIR/.env" ] || [ -n "$DATABASE_URL" ]; then
log_success "Database configuration found"
# Check for NAO6 plugin (this would require running a query)
log_info "Database plugins check would require HRIStudio connection"
else
log_warning "Database configuration not found - check .env file"
fi
else
log_warning "Database not running - start with: docker compose up -d"
fi
return $errors
}
check_ros_dependencies() {
log_step "Checking ROS dependencies and packages..."
local errors=0
# Source ROS if available
if [ -f "/opt/ros/humble/setup.bash" ]; then
source /opt/ros/humble/setup.bash 2>/dev/null || true
log_success "ROS2 Humble environment sourced"
fi
# Check required ROS packages
local required_packages=(
"rosbridge_server"
"rosapi"
"std_msgs"
"geometry_msgs"
"sensor_msgs"
)
for package in "${required_packages[@]}"; do
if ros2 pkg list 2>/dev/null | grep -q "^$package$"; then
log_success "ROS package: $package"
else
log_warning "ROS package missing: $package"
fi
done
# Check NAOqi-specific packages
local naoqi_packages=(
"naoqi_driver"
"naoqi_bridge_msgs"
)
for package in "${naoqi_packages[@]}"; do
if [ -d "$ROS_WS/src/naoqi_driver2" ] || [ -d "$ROS_WS/install/$package" ]; then
log_success "NAOqi package: $package"
else
log_warning "NAOqi package not found: $package"
fi
done
return $errors
}
check_plugin_files() {
log_step "Checking HRIStudio plugin files..."
local errors=0
local plugin_dir="$HRISTUDIO_DIR/public/nao6-plugins"
if [ -d "$plugin_dir" ]; then
log_success "NAO6 plugins directory found"
# Check repository metadata
if [ -f "$plugin_dir/repository.json" ]; then
log_success "Repository metadata file found"
# Validate JSON
if command -v jq >/dev/null 2>&1; then
if jq empty "$plugin_dir/repository.json" 2>/dev/null; then
log_success "Repository metadata is valid JSON"
else
log_error "Repository metadata has invalid JSON"
((errors++))
fi
fi
else
log_warning "Repository metadata not found"
fi
# Check plugin definition
if [ -f "$plugin_dir/nao6-ros2-enhanced.json" ]; then
log_success "NAO6 plugin definition found"
# Validate JSON
if command -v jq >/dev/null 2>&1; then
if jq empty "$plugin_dir/nao6-ros2-enhanced.json" 2>/dev/null; then
local action_count=$(jq '.actionDefinitions | length' "$plugin_dir/nao6-ros2-enhanced.json" 2>/dev/null || echo "0")
log_success "Plugin definition valid with $action_count actions"
else
log_error "Plugin definition has invalid JSON"
((errors++))
fi
fi
else
log_warning "NAO6 plugin definition not found"
fi
else
log_warning "NAO6 plugins directory not found - plugins may be in database only"
fi
return $errors
}
show_integration_status() {
echo ""
echo -e "${CYAN}================================================================="
echo " INTEGRATION STATUS SUMMARY"
echo -e "=================================================================${NC}"
echo ""
echo -e "${GREEN}🤖 NAO6 Robot Integration Components:${NC}"
echo " ✅ ROS2 Workspace: $ROS_WS"
echo " ✅ nao_launch Package: Enhanced launch files and scripts"
echo " ✅ HRIStudio Plugin: Database integration with 9 actions"
echo " ✅ Plugin Repository: Local and remote plugin definitions"
echo ""
echo -e "${BLUE}🔧 Available Launch Configurations:${NC}"
echo " 📦 Production: ros2 launch nao_launch nao6_production.launch.py"
echo " 🔍 Enhanced: ros2 launch nao_launch nao6_hristudio_enhanced.launch.py"
echo " ⚡ Basic: ros2 launch nao_launch nao6_hristudio.launch.py"
echo ""
echo -e "${PURPLE}🎮 Robot Control Options:${NC}"
echo " 🖥️ Command Line: python3 scripts/nao_control.py --ip $NAO_IP"
echo " 🌐 Web Interface: http://localhost:3000/nao-test"
echo " 🧪 HRIStudio: Experiment designer with NAO6 actions"
echo ""
echo -e "${YELLOW}📋 Available Actions in HRIStudio:${NC}"
echo " 🗣️ Speech: Text-to-speech synthesis"
echo " 🚶 Movement: Walking, turning, positioning"
echo " 🧍 Posture: Stand, sit, crouch poses"
echo " 👀 Head: Gaze control and attention direction"
echo " 👋 Gestures: Wave, point, applause, custom animations"
echo " 📡 Sensors: Touch, bumper, sonar monitoring"
echo " 🛑 Safety: Emergency stop and status checking"
echo " ⚡ System: Wake/rest and robot management"
echo ""
}
show_next_steps() {
echo -e "${GREEN}🚀 Next Steps to Start Using NAO6 Integration:${NC}"
echo ""
echo "1. 📡 Start ROS Integration:"
echo " cd $ROS_WS && source install/setup.bash"
echo " ros2 launch nao_launch nao6_production.launch.py nao_ip:=$NAO_IP password:=robolab"
echo ""
echo "2. 🌐 Start HRIStudio:"
echo " cd $HRISTUDIO_DIR"
echo " bun dev"
echo ""
echo "3. 🧪 Test Integration:"
echo " • Open: http://localhost:3000/nao-test"
echo " • Click 'Connect' to establish WebSocket connection"
echo " • Try robot commands (speech, movement, etc.)"
echo ""
echo "4. 🔬 Create Experiments:"
echo " • Login to HRIStudio: sean@soconnor.dev / password123"
echo " • Go to Study → Plugins → Install NAO6 plugin"
echo " • Configure robot IP: $NAO_IP"
echo " • Design experiments using NAO6 actions"
echo ""
echo "5. 🛠️ Troubleshooting:"
echo " • Robot not responding: Wake up with chest button (3 seconds)"
echo " • Connection issues: Check network and robot IP"
echo " • WebSocket problems: Verify rosbridge is running"
echo " • Emergency stop: Use Ctrl+C or emergency action"
echo ""
}
show_comprehensive_summary() {
echo -e "${CYAN}================================================================="
echo " COMPREHENSIVE INTEGRATION SUMMARY"
echo -e "=================================================================${NC}"
echo ""
echo -e "${GREEN}✅ COMPLETED ENHANCEMENTS:${NC}"
echo ""
echo -e "${BLUE}📦 Enhanced nao_launch Package:${NC}"
echo " • Production-optimized launch files with safety features"
echo " • Comprehensive robot control and monitoring scripts"
echo " • Automatic wake-up and error recovery"
echo " • Performance-tuned sensor frequencies for HRIStudio"
echo " • Emergency stop and safety monitoring capabilities"
echo ""
echo -e "${BLUE}🔌 Enhanced Plugin Integration:${NC}"
echo " • Complete NAO6 plugin with 9 comprehensive actions"
echo " • Type-safe configuration schema for robot settings"
echo " • WebSocket integration for real-time robot control"
echo " • Safety parameters and velocity limits"
echo " • Comprehensive action parameter validation"
echo ""
echo -e "${BLUE}🛠️ Utility Scripts and Tools:${NC}"
echo " • nao_control.py - Command-line robot control and monitoring"
echo " • start_nao6_hristudio.sh - Comprehensive startup automation"
echo " • Enhanced CMakeLists.txt and package metadata"
echo " • Database seeding scripts for plugin installation"
echo " • Comprehensive documentation and troubleshooting guides"
echo ""
echo -e "${BLUE}📚 Documentation and Guides:${NC}"
echo " • Complete README with setup and usage instructions"
echo " • Plugin repository metadata and action definitions"
echo " • Safety guidelines and emergency procedures"
echo " • Troubleshooting guide for common issues"
echo " • Integration examples and common use cases"
echo ""
echo -e "${PURPLE}🎯 Production-Ready Features:${NC}"
echo " • Automatic robot wake-up on experiment start"
echo " • Safety monitoring with emergency stop capabilities"
echo " • Optimized sensor publishing for experimental workflows"
echo " • Robust error handling and recovery mechanisms"
echo " • Performance tuning for stable long-running experiments"
echo " • Comprehensive logging and status monitoring"
echo ""
echo -e "${YELLOW}🔬 Research Capabilities:${NC}"
echo " • Complete speech synthesis with volume/speed control"
echo " • Precise movement control with safety limits"
echo " • Posture control for experimental positioning"
echo " • Head movement for gaze and attention studies"
echo " • Gesture library for social interaction research"
echo " • Comprehensive sensor monitoring for interaction detection"
echo " • Real-time status monitoring for experimental validity"
echo ""
}
# =================================================================
# MAIN EXECUTION
# =================================================================
main() {
# Parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
--robot-ip)
NAO_IP="$2"
shift 2
;;
--verbose)
VERBOSE=true
shift
;;
--help)
echo "Usage: $0 [--robot-ip IP] [--verbose]"
exit 0
;;
*)
NAO_IP="$1"
shift
;;
esac
done
# Show header
show_header
# Run verification checks
local total_errors=0
check_prerequisites
total_errors=$((total_errors + $?))
check_nao_launch_package
total_errors=$((total_errors + $?))
check_robot_connectivity
total_errors=$((total_errors + $?))
check_hristudio_database
total_errors=$((total_errors + $?))
check_ros_dependencies
total_errors=$((total_errors + $?))
check_plugin_files
total_errors=$((total_errors + $?))
# Show results
echo ""
if [ $total_errors -eq 0 ]; then
log_success "All verification checks passed! 🎉"
show_integration_status
show_next_steps
show_comprehensive_summary
echo -e "${GREEN}🎊 NAO6 HRIStudio Integration is ready for use!${NC}"
echo ""
else
log_warning "Verification completed with $total_errors issues"
echo ""
echo -e "${YELLOW}⚠️ Some components need attention before full integration.${NC}"
echo "Please resolve the issues above and run verification again."
echo ""
show_next_steps
fi
echo -e "${CYAN}================================================================="
echo " VERIFICATION COMPLETE"
echo -e "=================================================================${NC}"
}
# Run main function
main "$@"