mirror of
https://github.com/soconnor0919/robot-plugins.git
synced 2026-03-23 19:27:52 -04:00
Compare commits
5 Commits
31beaffc5b
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d772aecc54 | ||
|
|
14137ba631 | ||
|
|
9e0921c69c | ||
|
|
d3a9093d67 | ||
|
|
817ee69b87 |
@@ -243,10 +243,7 @@
|
||||
"description": "Angular velocity in rad/s"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"linear",
|
||||
"angular"
|
||||
]
|
||||
"required": ["linear", "angular"]
|
||||
},
|
||||
"ros2": {
|
||||
"messageType": "geometry_msgs/msg/Twist",
|
||||
@@ -289,9 +286,7 @@
|
||||
"description": "Duration to walk in seconds (0 = indefinite)"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"speed"
|
||||
]
|
||||
"required": ["speed"]
|
||||
},
|
||||
"ros2": {
|
||||
"messageType": "geometry_msgs/msg/Twist",
|
||||
@@ -356,9 +351,7 @@
|
||||
"description": "Duration to walk in seconds (0 = indefinite)"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"speed"
|
||||
]
|
||||
"required": ["speed"]
|
||||
},
|
||||
"ros2": {
|
||||
"messageType": "geometry_msgs/msg/Twist",
|
||||
@@ -423,9 +416,7 @@
|
||||
"description": "Duration to turn in seconds (0 = indefinite)"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"speed"
|
||||
]
|
||||
"required": ["speed"]
|
||||
},
|
||||
"ros2": {
|
||||
"messageType": "geometry_msgs/msg/Twist",
|
||||
@@ -490,9 +481,7 @@
|
||||
"description": "Duration to turn in seconds (0 = indefinite)"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"speed"
|
||||
]
|
||||
"required": ["speed"]
|
||||
},
|
||||
"ros2": {
|
||||
"messageType": "geometry_msgs/msg/Twist",
|
||||
@@ -587,9 +576,7 @@
|
||||
"description": "Text to speak"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"text"
|
||||
]
|
||||
"required": ["text"]
|
||||
},
|
||||
"ros2": {
|
||||
"messageType": "std_msgs/msg/String",
|
||||
@@ -615,10 +602,10 @@
|
||||
{
|
||||
"id": "say_with_emotion",
|
||||
"name": "Say Text with Emotion",
|
||||
"description": "Speak text with emotional expression using SSML-like markup",
|
||||
"description": "Speak text with emotional expression and animated gestures. Emotions: happy (excited gestures), sad (slower, lower pitch), neutral, excited (fast, animated), calm (slower, relaxed)",
|
||||
"category": "interaction",
|
||||
"icon": "heart",
|
||||
"timeout": 15000,
|
||||
"timeout": 20000,
|
||||
"retryable": true,
|
||||
"parameterSchema": {
|
||||
"type": "object",
|
||||
@@ -630,15 +617,9 @@
|
||||
},
|
||||
"emotion": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"neutral",
|
||||
"happy",
|
||||
"sad",
|
||||
"excited",
|
||||
"calm"
|
||||
],
|
||||
"enum": ["neutral", "happy", "sad", "excited", "calm"],
|
||||
"default": "neutral",
|
||||
"description": "Emotional tone for speech"
|
||||
"description": "Emotional tone: happy (animated), sad (slow/low pitch), excited (fast + gestures), calm (slower + relaxed)"
|
||||
},
|
||||
"speed": {
|
||||
"type": "number",
|
||||
@@ -648,18 +629,14 @@
|
||||
"description": "Speech speed multiplier"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"text"
|
||||
]
|
||||
"required": ["text"]
|
||||
},
|
||||
"ros2": {
|
||||
"messageType": "std_msgs/msg/String",
|
||||
"topic": "/speech",
|
||||
"payloadMapping": {
|
||||
"type": "static",
|
||||
"payload": {
|
||||
"data": "\\rspd={{speed}}\\\\rst={{emotion}}\\{{text}}"
|
||||
}
|
||||
"type": "transform",
|
||||
"transformFn": "transformToEmotionalSpeech"
|
||||
}
|
||||
},
|
||||
"implementation": {
|
||||
@@ -690,9 +667,7 @@
|
||||
"description": "Volume level (0.0 = silent, 1.0 = maximum)"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"volume"
|
||||
]
|
||||
"required": ["volume"]
|
||||
},
|
||||
"ros2": {
|
||||
"messageType": "std_msgs/msg/Float32",
|
||||
@@ -733,9 +708,7 @@
|
||||
"description": "Speech language"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"language"
|
||||
]
|
||||
"required": ["language"]
|
||||
},
|
||||
"ros2": {
|
||||
"messageType": "std_msgs/msg/String",
|
||||
@@ -781,10 +754,7 @@
|
||||
"description": "Movement speed (0.1 = slow, 1.0 = fast)"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"yaw",
|
||||
"pitch"
|
||||
]
|
||||
"required": ["yaw", "pitch"]
|
||||
},
|
||||
"ros2": {
|
||||
"messageType": "naoqi_bridge_msgs/msg/JointAnglesWithSpeed",
|
||||
@@ -792,14 +762,8 @@
|
||||
"payloadMapping": {
|
||||
"type": "static",
|
||||
"payload": {
|
||||
"joint_names": [
|
||||
"HeadYaw",
|
||||
"HeadPitch"
|
||||
],
|
||||
"joint_angles": [
|
||||
"{{yaw}}",
|
||||
"{{pitch}}"
|
||||
],
|
||||
"joint_names": ["HeadYaw", "HeadPitch"],
|
||||
"joint_angles": ["{{yaw}}", "{{pitch}}"],
|
||||
"speed": "{{speed}}"
|
||||
}
|
||||
}
|
||||
@@ -828,10 +792,7 @@
|
||||
"properties": {
|
||||
"arm": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"left",
|
||||
"right"
|
||||
],
|
||||
"enum": ["left", "right"],
|
||||
"default": "right",
|
||||
"description": "Which arm to control"
|
||||
},
|
||||
@@ -900,6 +861,26 @@
|
||||
"speed": "{{speed}}"
|
||||
}
|
||||
}
|
||||
},
|
||||
"implementation": {
|
||||
"type": "ros2_topic",
|
||||
"topic": "/joint_angles",
|
||||
"messageType": "naoqi_bridge_msgs/msg/JointAnglesWithSpeed",
|
||||
"messageTemplate": {
|
||||
"joint_names": [
|
||||
"{{arm === 'left' ? 'L' : 'R'}}ShoulderPitch",
|
||||
"{{arm === 'left' ? 'L' : 'R'}}ShoulderRoll",
|
||||
"{{arm === 'left' ? 'L' : 'R'}}ElbowYaw",
|
||||
"{{arm === 'left' ? 'L' : 'R'}}ElbowRoll"
|
||||
],
|
||||
"joint_angles": [
|
||||
"{{shoulder_pitch}}",
|
||||
"{{shoulder_roll}}",
|
||||
"{{elbow_yaw}}",
|
||||
"{{elbow_roll}}"
|
||||
],
|
||||
"speed": "{{speed}}"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -958,10 +939,7 @@
|
||||
"description": "Movement speed (fraction of max)"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"joint_name",
|
||||
"angle"
|
||||
]
|
||||
"required": ["joint_name", "angle"]
|
||||
},
|
||||
"ros2": {
|
||||
"messageType": "naoqi_bridge_msgs/msg/JointAnglesWithSpeed",
|
||||
@@ -1005,10 +983,7 @@
|
||||
"description": "Movement speed fraction"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"yaw",
|
||||
"pitch"
|
||||
]
|
||||
"required": ["yaw", "pitch"]
|
||||
},
|
||||
"ros2": {
|
||||
"messageType": "naoqi_bridge_msgs/msg/JointAnglesWithSpeed",
|
||||
@@ -1042,21 +1017,16 @@
|
||||
"properties": {
|
||||
"camera": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"front",
|
||||
"bottom"
|
||||
],
|
||||
"enum": ["front", "bottom"],
|
||||
"default": "front",
|
||||
"description": "Camera to use"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"camera"
|
||||
]
|
||||
"required": ["camera"]
|
||||
},
|
||||
"ros2": {
|
||||
"messageType": "sensor_msgs/msg/Image",
|
||||
"topic": "/naoqi_driver/camera/{camera}/image_raw",
|
||||
"topic": "/camera/{camera}/image_raw",
|
||||
"payloadMapping": {
|
||||
"type": "transform",
|
||||
"transformFn": "getCameraImage"
|
||||
@@ -1082,7 +1052,7 @@
|
||||
},
|
||||
"ros2": {
|
||||
"messageType": "sensor_msgs/msg/JointState",
|
||||
"topic": "/naoqi_driver/joint_states",
|
||||
"topic": "/joint_states",
|
||||
"payloadMapping": {
|
||||
"type": "transform",
|
||||
"transformFn": "getJointStates"
|
||||
@@ -1108,7 +1078,7 @@
|
||||
},
|
||||
"ros2": {
|
||||
"messageType": "sensor_msgs/msg/Imu",
|
||||
"topic": "/naoqi_driver/imu/torso",
|
||||
"topic": "/imu/torso",
|
||||
"payloadMapping": {
|
||||
"type": "transform",
|
||||
"transformFn": "getImuData"
|
||||
@@ -1134,7 +1104,7 @@
|
||||
},
|
||||
"ros2": {
|
||||
"messageType": "naoqi_bridge_msgs/msg/Bumper",
|
||||
"topic": "/naoqi_driver/bumper",
|
||||
"topic": "/bumper",
|
||||
"payloadMapping": {
|
||||
"type": "transform",
|
||||
"transformFn": "getBumperStatus"
|
||||
@@ -1154,21 +1124,16 @@
|
||||
"properties": {
|
||||
"sensor_type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"hand",
|
||||
"head"
|
||||
],
|
||||
"enum": ["hand", "head"],
|
||||
"default": "hand",
|
||||
"description": "Touch sensor type to read"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"sensor_type"
|
||||
]
|
||||
"required": ["sensor_type"]
|
||||
},
|
||||
"ros2": {
|
||||
"messageType": "naoqi_bridge_msgs/msg/HandTouch",
|
||||
"topic": "/naoqi_driver/{sensor_type}_touch",
|
||||
"topic": "/{sensor_type}_touch",
|
||||
"payloadMapping": {
|
||||
"type": "transform",
|
||||
"transformFn": "getTouchSensors"
|
||||
@@ -1188,22 +1153,16 @@
|
||||
"properties": {
|
||||
"sensor": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"left",
|
||||
"right",
|
||||
"both"
|
||||
],
|
||||
"enum": ["left", "right", "both"],
|
||||
"default": "both",
|
||||
"description": "Sonar sensor to read"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"sensor"
|
||||
]
|
||||
"required": ["sensor"]
|
||||
},
|
||||
"ros2": {
|
||||
"messageType": "sensor_msgs/msg/Range",
|
||||
"topic": "/naoqi_driver/sonar/{sensor}",
|
||||
"topic": "/sonar/{sensor}",
|
||||
"payloadMapping": {
|
||||
"type": "transform",
|
||||
"transformFn": "getSonarRange"
|
||||
@@ -1225,7 +1184,7 @@
|
||||
},
|
||||
"ros2": {
|
||||
"messageType": "naoqi_bridge_msgs/msg/RobotInfo",
|
||||
"topic": "/naoqi_driver/info",
|
||||
"topic": "/info",
|
||||
"payloadMapping": {
|
||||
"type": "transform",
|
||||
"transformFn": "getRobotInfo"
|
||||
@@ -1277,6 +1236,312 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "bow",
|
||||
"name": "Bow",
|
||||
"description": "Perform a polite bow gesture (head down + lean forward + return)",
|
||||
"category": "movement",
|
||||
"icon": "user-check",
|
||||
"timeout": 2000,
|
||||
"retryable": true,
|
||||
"parameterSchema": {
|
||||
"type": "object",
|
||||
"properties": {}
|
||||
},
|
||||
"ros2": {
|
||||
"topic": "/joint_angles",
|
||||
"messageType": "naoqi_bridge_msgs/msg/JointAnglesWithSpeed",
|
||||
"payloadMapping": {
|
||||
"type": "static",
|
||||
"payload": {
|
||||
"joint_names": ["HeadYaw", "HeadPitch"],
|
||||
"joint_angles": [0, 0.5],
|
||||
"speed": 0.3
|
||||
}
|
||||
}
|
||||
},
|
||||
"implementation": {
|
||||
"type": "ros2_topic",
|
||||
"topic": "/joint_angles",
|
||||
"messageType": "naoqi_bridge_msgs/msg/JointAnglesWithSpeed",
|
||||
"messageTemplate": {
|
||||
"joint_names": ["HeadYaw", "HeadPitch"],
|
||||
"joint_angles": [0, 0.5],
|
||||
"speed": 0.3
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "wave",
|
||||
"name": "Wave",
|
||||
"description": "Perform a friendly wave gesture with right arm",
|
||||
"category": "movement",
|
||||
"icon": "hand",
|
||||
"timeout": 2000,
|
||||
"retryable": true,
|
||||
"parameterSchema": {
|
||||
"type": "object",
|
||||
"properties": {}
|
||||
},
|
||||
"ros2": {
|
||||
"topic": "/joint_angles",
|
||||
"messageType": "naoqi_bridge_msgs/msg/JointAnglesWithSpeed",
|
||||
"payloadMapping": {
|
||||
"type": "static",
|
||||
"payload": {
|
||||
"joint_names": [
|
||||
"RShoulderPitch",
|
||||
"RShoulderRoll",
|
||||
"RElbowYaw",
|
||||
"RElbowRoll"
|
||||
],
|
||||
"joint_angles": [1.5, 0.2, -1.0, 0.5],
|
||||
"speed": 0.4
|
||||
}
|
||||
}
|
||||
},
|
||||
"implementation": {
|
||||
"type": "ros2_topic",
|
||||
"topic": "/joint_angles",
|
||||
"messageType": "naoqi_bridge_msgs/msg/JointAnglesWithSpeed",
|
||||
"messageTemplate": {
|
||||
"joint_names": [
|
||||
"RShoulderPitch",
|
||||
"RShoulderRoll",
|
||||
"RElbowYaw",
|
||||
"RElbowRoll"
|
||||
],
|
||||
"joint_angles": [1.5, 0.2, -1.0, 0.5],
|
||||
"speed": 0.4
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "nod",
|
||||
"name": "Nod",
|
||||
"description": "Perform a nodding gesture (head up and down)",
|
||||
"category": "movement",
|
||||
"icon": "chevrons-down",
|
||||
"timeout": 1500,
|
||||
"retryable": true,
|
||||
"parameterSchema": {
|
||||
"type": "object",
|
||||
"properties": {}
|
||||
},
|
||||
"ros2": {
|
||||
"topic": "/joint_angles",
|
||||
"messageType": "naoqi_bridge_msgs/msg/JointAnglesWithSpeed",
|
||||
"payloadMapping": {
|
||||
"type": "static",
|
||||
"payload": {
|
||||
"joint_names": ["HeadPitch"],
|
||||
"joint_angles": [0.3],
|
||||
"speed": 0.5
|
||||
}
|
||||
}
|
||||
},
|
||||
"implementation": {
|
||||
"type": "ros2_topic",
|
||||
"topic": "/joint_angles",
|
||||
"messageType": "naoqi_bridge_msgs/msg/JointAnglesWithSpeed",
|
||||
"messageTemplate": {
|
||||
"joint_names": ["HeadPitch"],
|
||||
"joint_angles": [0.3],
|
||||
"speed": 0.5
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "shake_head",
|
||||
"name": "Shake Head",
|
||||
"description": "Perform a head shaking gesture (no)",
|
||||
"category": "movement",
|
||||
"icon": "x-circle",
|
||||
"timeout": 1500,
|
||||
"retryable": true,
|
||||
"parameterSchema": {
|
||||
"type": "object",
|
||||
"properties": {}
|
||||
},
|
||||
"ros2": {
|
||||
"topic": "/joint_angles",
|
||||
"messageType": "naoqi_bridge_msgs/msg/JointAnglesWithSpeed",
|
||||
"payloadMapping": {
|
||||
"type": "static",
|
||||
"payload": {
|
||||
"joint_names": ["HeadYaw"],
|
||||
"joint_angles": [0.4],
|
||||
"speed": 0.5
|
||||
}
|
||||
}
|
||||
},
|
||||
"implementation": {
|
||||
"type": "ros2_topic",
|
||||
"topic": "/joint_angles",
|
||||
"messageType": "naoqi_bridge_msgs/msg/JointAnglesWithSpeed",
|
||||
"messageTemplate": {
|
||||
"joint_names": ["HeadYaw"],
|
||||
"joint_angles": [0.4],
|
||||
"speed": 0.5
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "point",
|
||||
"name": "Point",
|
||||
"description": "Point at something with left arm",
|
||||
"category": "movement",
|
||||
"icon": "finger-pointer",
|
||||
"timeout": 1500,
|
||||
"retryable": true,
|
||||
"parameterSchema": {
|
||||
"type": "object",
|
||||
"properties": {}
|
||||
},
|
||||
"ros2": {
|
||||
"topic": "/joint_angles",
|
||||
"messageType": "naoqi_bridge_msgs/msg/JointAnglesWithSpeed",
|
||||
"payloadMapping": {
|
||||
"type": "static",
|
||||
"payload": {
|
||||
"joint_names": [
|
||||
"LShoulderPitch",
|
||||
"LShoulderRoll",
|
||||
"LElbowYaw",
|
||||
"LElbowRoll",
|
||||
"LWristYaw"
|
||||
],
|
||||
"joint_angles": [0.8, 0.3, -1.0, 0.1, 0],
|
||||
"speed": 0.4
|
||||
}
|
||||
}
|
||||
},
|
||||
"implementation": {
|
||||
"type": "ros2_topic",
|
||||
"topic": "/joint_angles",
|
||||
"messageType": "naoqi_bridge_msgs/msg/JointAnglesWithSpeed",
|
||||
"messageTemplate": {
|
||||
"joint_names": [
|
||||
"LShoulderPitch",
|
||||
"LShoulderRoll",
|
||||
"LElbowYaw",
|
||||
"LElbowRoll",
|
||||
"LWristYaw"
|
||||
],
|
||||
"joint_angles": [0.8, 0.3, -1.0, 0.1, 0],
|
||||
"speed": 0.4
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "greet",
|
||||
"name": "Greet",
|
||||
"description": "Combined greeting gesture: bow + wave",
|
||||
"category": "movement",
|
||||
"icon": "sparkles",
|
||||
"timeout": 3000,
|
||||
"retryable": true,
|
||||
"parameterSchema": {
|
||||
"type": "object",
|
||||
"properties": {}
|
||||
},
|
||||
"ros2": {
|
||||
"topic": "/joint_angles",
|
||||
"messageType": "naoqi_bridge_msgs/msg/JointAnglesWithSpeed",
|
||||
"payloadMapping": {
|
||||
"type": "static",
|
||||
"payload": {
|
||||
"joint_names": ["HeadYaw", "HeadPitch"],
|
||||
"joint_angles": [0, 0.3],
|
||||
"speed": 0.4
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "wave_goodbye",
|
||||
"name": "Wave Goodbye",
|
||||
"description": "Animated wave goodbye gesture with speech",
|
||||
"category": "interaction",
|
||||
"icon": "hand",
|
||||
"timeout": 4000,
|
||||
"retryable": true,
|
||||
"parameterSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"text": {
|
||||
"type": "string",
|
||||
"default": "Goodbye!",
|
||||
"description": "Text to say while waving"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ros2": {
|
||||
"messageType": "std_msgs/msg/String",
|
||||
"topic": "/speech",
|
||||
"payloadMapping": {
|
||||
"type": "transform",
|
||||
"transformFn": "transformToWaveGoodbye"
|
||||
}
|
||||
},
|
||||
"implementation": {
|
||||
"type": "ros2_topic",
|
||||
"topic": "/speech",
|
||||
"messageType": "std_msgs/msg/String",
|
||||
"messageTemplate": {
|
||||
"data": "{{text}}"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "play_animation",
|
||||
"name": "Play Animation",
|
||||
"description": "Play a predefined NAO animation/gesture",
|
||||
"category": "movement",
|
||||
"icon": "play",
|
||||
"timeout": 5000,
|
||||
"retryable": true,
|
||||
"parameterSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"animation": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Hey_1",
|
||||
"Happy_1",
|
||||
"Happy_4",
|
||||
"Enthusiastic_1",
|
||||
"Yes_1",
|
||||
"Yes_2",
|
||||
"No_1",
|
||||
"Blow_1",
|
||||
"Gesture_Ok_1",
|
||||
"Gesture_Nice_1",
|
||||
"Gesture_You_1"
|
||||
],
|
||||
"default": "Hey_1",
|
||||
"description": "Animation to play"
|
||||
}
|
||||
},
|
||||
"required": ["animation"]
|
||||
},
|
||||
"ros2": {
|
||||
"messageType": "std_msgs/msg/String",
|
||||
"topic": "/speech",
|
||||
"payloadMapping": {
|
||||
"type": "transform",
|
||||
"transformFn": "transformToAnimation"
|
||||
}
|
||||
},
|
||||
"implementation": {
|
||||
"type": "ros2_topic",
|
||||
"topic": "/speech",
|
||||
"messageType": "std_msgs/msg/String",
|
||||
"messageTemplate": {
|
||||
"data": "^start(animations/Stand/Gestures/{{animation}})"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,35 +1,35 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
// Color output helpers
|
||||
const colors = {
|
||||
red: '\x1b[31m',
|
||||
green: '\x1b[32m',
|
||||
yellow: '\x1b[33m',
|
||||
blue: '\x1b[34m',
|
||||
reset: '\x1b[0m'
|
||||
red: "\x1b[31m",
|
||||
green: "\x1b[32m",
|
||||
yellow: "\x1b[33m",
|
||||
blue: "\x1b[34m",
|
||||
reset: "\x1b[0m",
|
||||
};
|
||||
|
||||
function log(message, color = 'reset') {
|
||||
function log(message, color = "reset") {
|
||||
console.log(`${colors[color]}${message}${colors.reset}`);
|
||||
}
|
||||
|
||||
function error(message) {
|
||||
log(`❌ ${message}`, 'red');
|
||||
log(`❌ ${message}`, "red");
|
||||
}
|
||||
|
||||
function success(message) {
|
||||
log(`✅ ${message}`, 'green');
|
||||
log(`✅ ${message}`, "green");
|
||||
}
|
||||
|
||||
function warn(message) {
|
||||
log(`⚠️ ${message}`, 'yellow');
|
||||
log(`⚠️ ${message}`, "yellow");
|
||||
}
|
||||
|
||||
function info(message) {
|
||||
log(`ℹ️ ${message}`, 'blue');
|
||||
log(`ℹ️ ${message}`, "blue");
|
||||
}
|
||||
|
||||
// Plugin schema validation
|
||||
@@ -40,7 +40,7 @@ function validatePlugin(pluginPath) {
|
||||
|
||||
let plugin;
|
||||
try {
|
||||
plugin = JSON.parse(fs.readFileSync(pluginPath, 'utf8'));
|
||||
plugin = JSON.parse(fs.readFileSync(pluginPath, "utf8"));
|
||||
} catch (e) {
|
||||
throw new Error(`Invalid JSON syntax: ${e.message}`);
|
||||
}
|
||||
@@ -50,17 +50,17 @@ function validatePlugin(pluginPath) {
|
||||
|
||||
// Required fields validation
|
||||
const requiredFields = [
|
||||
'robotId',
|
||||
'name',
|
||||
'platform',
|
||||
'version',
|
||||
'pluginApiVersion',
|
||||
'hriStudioVersion',
|
||||
'trustLevel',
|
||||
'category'
|
||||
"robotId",
|
||||
"name",
|
||||
"platform",
|
||||
"version",
|
||||
"pluginApiVersion",
|
||||
"hriStudioVersion",
|
||||
"trustLevel",
|
||||
"category",
|
||||
];
|
||||
|
||||
requiredFields.forEach(field => {
|
||||
requiredFields.forEach((field) => {
|
||||
if (!plugin[field]) {
|
||||
errors.push(`Missing required field: ${field}`);
|
||||
}
|
||||
@@ -68,36 +68,43 @@ function validatePlugin(pluginPath) {
|
||||
|
||||
// Field format validation
|
||||
if (plugin.robotId && !/^[a-z0-9-]+$/.test(plugin.robotId)) {
|
||||
errors.push('robotId must be lowercase with hyphens only');
|
||||
errors.push("robotId must be lowercase with hyphens only");
|
||||
}
|
||||
|
||||
if (plugin.version && !/^\d+\.\d+\.\d+/.test(plugin.version)) {
|
||||
errors.push('version must follow semantic versioning (e.g., 1.0.0)');
|
||||
errors.push("version must follow semantic versioning (e.g., 1.0.0)");
|
||||
}
|
||||
|
||||
if (plugin.trustLevel && !['official', 'verified', 'community'].includes(plugin.trustLevel)) {
|
||||
errors.push(`Invalid trustLevel: ${plugin.trustLevel}. Must be: official, verified, or community`);
|
||||
if (
|
||||
plugin.trustLevel &&
|
||||
!["official", "verified", "community"].includes(plugin.trustLevel)
|
||||
) {
|
||||
errors.push(
|
||||
`Invalid trustLevel: ${plugin.trustLevel}. Must be: official, verified, or community`,
|
||||
);
|
||||
}
|
||||
|
||||
// Category validation
|
||||
const validCategories = [
|
||||
'mobile-robot',
|
||||
'humanoid-robot',
|
||||
'manipulator',
|
||||
'drone',
|
||||
'sensor-platform',
|
||||
'simulation'
|
||||
"mobile-robot",
|
||||
"humanoid-robot",
|
||||
"manipulator",
|
||||
"drone",
|
||||
"sensor-platform",
|
||||
"simulation",
|
||||
];
|
||||
|
||||
if (plugin.category && !validCategories.includes(plugin.category)) {
|
||||
errors.push(`Invalid category: ${plugin.category}. Valid categories: ${validCategories.join(', ')}`);
|
||||
errors.push(
|
||||
`Invalid category: ${plugin.category}. Valid categories: ${validCategories.join(", ")}`,
|
||||
);
|
||||
}
|
||||
|
||||
// Actions validation
|
||||
if (!plugin.actions || !Array.isArray(plugin.actions)) {
|
||||
errors.push('Plugin must have an actions array');
|
||||
errors.push("Plugin must have an actions array");
|
||||
} else if (plugin.actions.length === 0) {
|
||||
warnings.push('Plugin has no actions defined');
|
||||
warnings.push("Plugin has no actions defined");
|
||||
} else {
|
||||
plugin.actions.forEach((action, index) => {
|
||||
const actionErrors = validateAction(action, index);
|
||||
@@ -108,37 +115,43 @@ function validatePlugin(pluginPath) {
|
||||
// Assets validation
|
||||
if (plugin.assets) {
|
||||
if (!plugin.assets.thumbnailUrl) {
|
||||
errors.push('assets.thumbnailUrl is required');
|
||||
errors.push("assets.thumbnailUrl is required");
|
||||
}
|
||||
|
||||
// Check if asset paths exist
|
||||
const assetChecks = [
|
||||
['thumbnailUrl', plugin.assets.thumbnailUrl],
|
||||
['main image', plugin.assets.images?.main],
|
||||
['logo', plugin.assets.images?.logo]
|
||||
["thumbnailUrl", plugin.assets.thumbnailUrl],
|
||||
["main image", plugin.assets.images?.main],
|
||||
["logo", plugin.assets.images?.logo],
|
||||
];
|
||||
|
||||
if (plugin.assets.images?.angles) {
|
||||
Object.entries(plugin.assets.images.angles).forEach(([angle, assetPath]) => {
|
||||
assetChecks.push([`${angle} angle`, assetPath]);
|
||||
});
|
||||
Object.entries(plugin.assets.images.angles).forEach(
|
||||
([angle, assetPath]) => {
|
||||
assetChecks.push([`${angle} angle`, assetPath]);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
assetChecks.forEach(([description, assetPath]) => {
|
||||
if (assetPath && assetPath.startsWith('assets/')) {
|
||||
const fullPath = path.resolve(path.dirname(pluginPath), '..', assetPath);
|
||||
if (assetPath && assetPath.startsWith("assets/")) {
|
||||
const fullPath = path.resolve(
|
||||
path.dirname(pluginPath),
|
||||
"..",
|
||||
assetPath,
|
||||
);
|
||||
if (!fs.existsSync(fullPath)) {
|
||||
warnings.push(`Asset not found: ${description} (${assetPath})`);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
errors.push('Plugin must have assets definition');
|
||||
errors.push("Plugin must have assets definition");
|
||||
}
|
||||
|
||||
// Manufacturer validation
|
||||
if (!plugin.manufacturer?.name) {
|
||||
warnings.push('manufacturer.name is recommended');
|
||||
warnings.push("manufacturer.name is recommended");
|
||||
}
|
||||
|
||||
return { errors, warnings, plugin };
|
||||
@@ -148,8 +161,8 @@ function validateAction(action, index) {
|
||||
const errors = [];
|
||||
|
||||
// Required action fields
|
||||
const requiredFields = ['id', 'name', 'category', 'parameterSchema'];
|
||||
requiredFields.forEach(field => {
|
||||
const requiredFields = ["id", "name", "category", "parameterSchema"];
|
||||
requiredFields.forEach((field) => {
|
||||
if (!action[field]) {
|
||||
errors.push(`Action ${index}: missing required field '${field}'`);
|
||||
}
|
||||
@@ -157,18 +170,22 @@ function validateAction(action, index) {
|
||||
|
||||
// Action ID format
|
||||
if (action.id && !/^[a-z_]+$/.test(action.id)) {
|
||||
errors.push(`Action ${index}: id must be snake_case (lowercase with underscores)`);
|
||||
errors.push(
|
||||
`Action ${index}: id must be snake_case (lowercase with underscores)`,
|
||||
);
|
||||
}
|
||||
|
||||
// Action category validation
|
||||
const validActionCategories = ['movement', 'interaction', 'sensors', 'logic'];
|
||||
const validActionCategories = ["movement", "interaction", "sensors", "logic"];
|
||||
if (action.category && !validActionCategories.includes(action.category)) {
|
||||
errors.push(`Action ${index}: invalid category '${action.category}'. Valid: ${validActionCategories.join(', ')}`);
|
||||
errors.push(
|
||||
`Action ${index}: invalid category '${action.category}'. Valid: ${validActionCategories.join(", ")}`,
|
||||
);
|
||||
}
|
||||
|
||||
// Parameter schema validation
|
||||
if (action.parameterSchema) {
|
||||
if (action.parameterSchema.type !== 'object') {
|
||||
if (action.parameterSchema.type !== "object") {
|
||||
errors.push(`Action ${index}: parameterSchema.type must be 'object'`);
|
||||
}
|
||||
|
||||
@@ -187,7 +204,9 @@ function validateAction(action, index) {
|
||||
const hasRestApi = action.restApi;
|
||||
|
||||
if (!hasRos2 && !hasNaoqi && !hasRestApi) {
|
||||
errors.push(`Action ${index}: must have at least one communication protocol (ros2, naoqi, or restApi)`);
|
||||
errors.push(
|
||||
`Action ${index}: must have at least one communication protocol (ros2, naoqi, or restApi)`,
|
||||
);
|
||||
}
|
||||
|
||||
return errors;
|
||||
@@ -195,15 +214,15 @@ function validateAction(action, index) {
|
||||
|
||||
// Repository validation
|
||||
function validateRepository() {
|
||||
const repoPath = path.resolve('repository.json');
|
||||
const repoPath = path.resolve("repository.json");
|
||||
|
||||
if (!fs.existsSync(repoPath)) {
|
||||
throw new Error('repository.json not found');
|
||||
throw new Error("repository.json not found");
|
||||
}
|
||||
|
||||
let repo;
|
||||
try {
|
||||
repo = JSON.parse(fs.readFileSync(repoPath, 'utf8'));
|
||||
repo = JSON.parse(fs.readFileSync(repoPath, "utf8"));
|
||||
} catch (e) {
|
||||
throw new Error(`Invalid repository.json: ${e.message}`);
|
||||
}
|
||||
@@ -212,22 +231,30 @@ function validateRepository() {
|
||||
const warnings = [];
|
||||
|
||||
// Required repository fields
|
||||
const requiredFields = ['id', 'name', 'apiVersion', 'pluginApiVersion', 'trust'];
|
||||
requiredFields.forEach(field => {
|
||||
const requiredFields = [
|
||||
"id",
|
||||
"name",
|
||||
"apiVersion",
|
||||
"pluginApiVersion",
|
||||
"trust",
|
||||
];
|
||||
requiredFields.forEach((field) => {
|
||||
if (!repo[field]) {
|
||||
errors.push(`Missing required repository field: ${field}`);
|
||||
}
|
||||
});
|
||||
|
||||
// Validate plugin count
|
||||
const indexPath = path.resolve('plugins/index.json');
|
||||
const indexPath = path.resolve("plugins/index.json");
|
||||
if (fs.existsSync(indexPath)) {
|
||||
const index = JSON.parse(fs.readFileSync(indexPath, 'utf8'));
|
||||
const index = JSON.parse(fs.readFileSync(indexPath, "utf8"));
|
||||
const actualCount = index.length;
|
||||
const reportedCount = repo.stats?.plugins || 0;
|
||||
|
||||
if (actualCount !== reportedCount) {
|
||||
errors.push(`Plugin count mismatch: reported ${reportedCount}, actual ${actualCount}`);
|
||||
errors.push(
|
||||
`Plugin count mismatch: reported ${reportedCount}, actual ${actualCount}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,24 +263,25 @@ function validateRepository() {
|
||||
|
||||
// Update plugin index
|
||||
function updateIndex() {
|
||||
const pluginsDir = path.resolve('plugins');
|
||||
const indexPath = path.join(pluginsDir, 'index.json');
|
||||
const pluginsDir = path.resolve("plugins");
|
||||
const indexPath = path.join(pluginsDir, "index.json");
|
||||
|
||||
if (!fs.existsSync(pluginsDir)) {
|
||||
throw new Error('plugins directory not found');
|
||||
throw new Error("plugins directory not found");
|
||||
}
|
||||
|
||||
const pluginFiles = fs.readdirSync(pluginsDir)
|
||||
.filter(file => file.endsWith('.json') && file !== 'index.json')
|
||||
const pluginFiles = fs
|
||||
.readdirSync(pluginsDir)
|
||||
.filter((file) => file.endsWith(".json") && file !== "index.json")
|
||||
.sort();
|
||||
|
||||
fs.writeFileSync(indexPath, JSON.stringify(pluginFiles, null, 2));
|
||||
success(`Updated index.json with ${pluginFiles.length} plugins`);
|
||||
|
||||
// Update repository stats
|
||||
const repoPath = path.resolve('repository.json');
|
||||
const repoPath = path.resolve("repository.json");
|
||||
if (fs.existsSync(repoPath)) {
|
||||
const repo = JSON.parse(fs.readFileSync(repoPath, 'utf8'));
|
||||
const repo = JSON.parse(fs.readFileSync(repoPath, "utf8"));
|
||||
repo.stats = repo.stats || {};
|
||||
repo.stats.plugins = pluginFiles.length;
|
||||
fs.writeFileSync(repoPath, JSON.stringify(repo, null, 2));
|
||||
@@ -268,10 +296,10 @@ function main() {
|
||||
|
||||
try {
|
||||
switch (command) {
|
||||
case 'validate':
|
||||
case "validate":
|
||||
const pluginPath = args[1];
|
||||
if (!pluginPath) {
|
||||
error('Usage: validate <plugin-file>');
|
||||
error("Usage: validate <plugin-file>");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
@@ -279,53 +307,53 @@ function main() {
|
||||
const { errors, warnings } = validatePlugin(pluginPath);
|
||||
|
||||
if (errors.length > 0) {
|
||||
error('Validation failed:');
|
||||
errors.forEach(err => console.log(` - ${err}`));
|
||||
error("Validation failed:");
|
||||
errors.forEach((err) => console.log(` - ${err}`));
|
||||
}
|
||||
|
||||
if (warnings.length > 0) {
|
||||
warn('Warnings:');
|
||||
warnings.forEach(warn => console.log(` - ${warn}`));
|
||||
warn("Warnings:");
|
||||
warnings.forEach((warn) => console.log(` - ${warn}`));
|
||||
}
|
||||
|
||||
if (errors.length === 0) {
|
||||
success('Plugin validation passed!');
|
||||
success("Plugin validation passed!");
|
||||
if (warnings.length === 0) {
|
||||
success('No warnings found');
|
||||
success("No warnings found");
|
||||
}
|
||||
} else {
|
||||
process.exit(1);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'validate-all':
|
||||
info('Validating all plugins...');
|
||||
case "validate-all":
|
||||
info("Validating all plugins...");
|
||||
|
||||
// Validate repository
|
||||
const repoResult = validateRepository();
|
||||
if (repoResult.errors.length > 0) {
|
||||
error('Repository validation failed:');
|
||||
repoResult.errors.forEach(err => console.log(` - ${err}`));
|
||||
error("Repository validation failed:");
|
||||
repoResult.errors.forEach((err) => console.log(` - ${err}`));
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Validate all plugins
|
||||
const indexPath = path.resolve('plugins/index.json');
|
||||
const indexPath = path.resolve("plugins/index.json");
|
||||
if (!fs.existsSync(indexPath)) {
|
||||
error('plugins/index.json not found');
|
||||
error("plugins/index.json not found");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const index = JSON.parse(fs.readFileSync(indexPath, 'utf8'));
|
||||
const index = JSON.parse(fs.readFileSync(indexPath, "utf8"));
|
||||
let allValid = true;
|
||||
|
||||
for (const pluginFile of index) {
|
||||
const pluginPath = path.resolve('plugins', pluginFile);
|
||||
const pluginPath = path.resolve("plugins", pluginFile);
|
||||
try {
|
||||
const { errors } = validatePlugin(pluginPath);
|
||||
if (errors.length > 0) {
|
||||
error(`${pluginFile}: ${errors.length} errors`);
|
||||
errors.forEach(err => console.log(` - ${err}`));
|
||||
errors.forEach((err) => console.log(` - ${err}`));
|
||||
allValid = false;
|
||||
} else {
|
||||
success(`${pluginFile}: valid`);
|
||||
@@ -337,18 +365,18 @@ function main() {
|
||||
}
|
||||
|
||||
if (allValid) {
|
||||
success('All plugins are valid!');
|
||||
success("All plugins are valid!");
|
||||
} else {
|
||||
process.exit(1);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'update-index':
|
||||
info('Updating plugin index...');
|
||||
case "update-index":
|
||||
info("Updating plugin index...");
|
||||
updateIndex();
|
||||
break;
|
||||
|
||||
case 'help':
|
||||
case "help":
|
||||
default:
|
||||
console.log(`
|
||||
HRIStudio Plugin Validator
|
||||
@@ -379,5 +407,5 @@ if (require.main === module) {
|
||||
module.exports = {
|
||||
validatePlugin,
|
||||
validateRepository,
|
||||
updateIndex
|
||||
updateIndex,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user