161 lines
5.7 KiB
JavaScript
161 lines
5.7 KiB
JavaScript
/**
|
|
* Robotics Navigation: Adaptive Real-Time Path Planning
|
|
*
|
|
* Use Case: Autonomous robots need real-time similarity search
|
|
* for environment matching and obstacle avoidance.
|
|
*
|
|
* Optimization Priority: BALANCED (latency + accuracy)
|
|
*/
|
|
export const ROBOTICS_ATTENTION_CONFIG = {
|
|
heads: 8, // Optimal balance (validated)
|
|
forwardPassTargetMs: 10, // 10ms for 100Hz control loop
|
|
batchSize: 4, // Small batches for real-time
|
|
precision: 'float16', // Reduced precision for edge devices
|
|
edgeOptimized: true, // NVIDIA Jetson, Intel NCS optimization
|
|
// Dynamic attention based on environment complexity
|
|
dynamicHeads: {
|
|
enabled: true,
|
|
simple: 4, // 4 heads for simple environments
|
|
complex: 12, // 12 heads for complex scenes
|
|
adaptationStrategy: 'scene-complexity'
|
|
},
|
|
// Dynamic-k based on navigation context
|
|
dynamicK: {
|
|
min: 5,
|
|
max: 20,
|
|
adaptationStrategy: 'obstacle-density' // More obstacles = more candidates
|
|
},
|
|
// Self-healing for continuous operation
|
|
selfHealing: {
|
|
enabled: true,
|
|
adaptationIntervalMs: 100,
|
|
degradationThreshold: 0.05,
|
|
hardwareMonitoring: true // Battery, temperature, GPU
|
|
}
|
|
};
|
|
// Example: Environment matching for navigation
|
|
export async function matchEnvironment(currentSensorData, // LIDAR, camera, IMU
|
|
knownEnvironments, // HNSWGraph type
|
|
robotContext, applyAttention, analyzeSceneComplexity, calculateObstacleDensity, computePath) {
|
|
const startTime = Date.now();
|
|
const config = ROBOTICS_ATTENTION_CONFIG;
|
|
// Adaptive attention based on scene complexity
|
|
const sceneComplexity = analyzeSceneComplexity(currentSensorData);
|
|
const adaptiveHeads = sceneComplexity > 0.7 ? 12 : 4;
|
|
// Apply attention with adaptive heads
|
|
const enhanced = await applyAttention(currentSensorData, {
|
|
...config,
|
|
heads: adaptiveHeads
|
|
});
|
|
// Dynamic-k based on obstacle density
|
|
const obstacleDensity = calculateObstacleDensity(currentSensorData);
|
|
const k = Math.round(5 + obstacleDensity * 15); // 5-20 range
|
|
// Search for similar environments
|
|
const matches = await knownEnvironments.search(enhanced, k);
|
|
return {
|
|
bestMatch: matches[0],
|
|
suggestedPath: computePath(matches),
|
|
confidence: matches[0].score,
|
|
latencyMs: Date.now() - startTime // Track real-time performance
|
|
};
|
|
}
|
|
// Performance targets for robotics
|
|
export const ROBOTICS_PERFORMANCE_TARGETS = {
|
|
controlLoopLatencyMs: 10, // 10ms for 100Hz control
|
|
navigationAccuracy: 0.95, // 95% path planning accuracy
|
|
p99LatencyMs: 15, // 15ms p99 (real-time critical)
|
|
powerConsumptionW: 20, // 20W max (battery life)
|
|
uptimePercent: 99.0 // 99% uptime (2 nines, field operation)
|
|
};
|
|
// Robot platform-specific configurations
|
|
export const ROBOTICS_CONFIG_VARIATIONS = {
|
|
// High-performance robots (Boston Dynamics Spot, ANYmal)
|
|
highPerformance: {
|
|
...ROBOTICS_ATTENTION_CONFIG,
|
|
heads: 12,
|
|
forwardPassTargetMs: 5, // 5ms for 200Hz control
|
|
precision: 'float32', // Full precision available
|
|
powerConsumptionW: 100 // Higher power budget
|
|
},
|
|
// Consumer drones (DJI, Parrot)
|
|
consumerDrone: {
|
|
...ROBOTICS_ATTENTION_CONFIG,
|
|
heads: 6,
|
|
forwardPassTargetMs: 20, // 50Hz control acceptable
|
|
precision: 'float16',
|
|
powerConsumptionW: 15 // Battery constrained
|
|
},
|
|
// Industrial AGVs (warehouse robots)
|
|
industrialAGV: {
|
|
...ROBOTICS_ATTENTION_CONFIG,
|
|
heads: 8,
|
|
forwardPassTargetMs: 15,
|
|
precision: 'float32',
|
|
dynamicK: { min: 10, max: 30, adaptationStrategy: 'warehouse-density' }
|
|
},
|
|
// Embedded robots (Raspberry Pi, Arduino)
|
|
embedded: {
|
|
...ROBOTICS_ATTENTION_CONFIG,
|
|
heads: 4,
|
|
forwardPassTargetMs: 50, // Slower acceptable
|
|
precision: 'int8', // Quantized for embedded
|
|
powerConsumptionW: 5 // Very power constrained
|
|
}
|
|
};
|
|
// Environment adaptation
|
|
export function adaptConfigToEnvironment(baseConfig, environment) {
|
|
switch (environment) {
|
|
case 'indoor':
|
|
return {
|
|
...baseConfig,
|
|
heads: 8,
|
|
dynamicK: { ...baseConfig.dynamicK, min: 5, max: 15 }
|
|
};
|
|
case 'outdoor':
|
|
return {
|
|
...baseConfig,
|
|
heads: 10, // More complexity
|
|
dynamicK: { ...baseConfig.dynamicK, min: 10, max: 25 },
|
|
selfHealing: { ...baseConfig.selfHealing, adaptationIntervalMs: 50 }
|
|
};
|
|
case 'underground':
|
|
return {
|
|
...baseConfig,
|
|
heads: 6, // Limited sensors
|
|
forwardPassTargetMs: 15
|
|
// Note: Network resilience handled at transport layer
|
|
};
|
|
case 'aerial':
|
|
return {
|
|
...baseConfig,
|
|
heads: 12, // Complex 3D navigation
|
|
forwardPassTargetMs: 8,
|
|
dynamicK: { ...baseConfig.dynamicK, min: 8, max: 20 }
|
|
};
|
|
}
|
|
}
|
|
// Power-aware configuration adjustment
|
|
export function adaptConfigToPower(baseConfig, batteryPercent) {
|
|
if (batteryPercent < 20) {
|
|
// Critical battery - minimize computation
|
|
return {
|
|
...baseConfig,
|
|
heads: 4,
|
|
batchSize: 1
|
|
// Note: Precision optimization coming in future release
|
|
};
|
|
}
|
|
else if (batteryPercent < 50) {
|
|
// Low battery - reduce quality slightly
|
|
return {
|
|
...baseConfig,
|
|
heads: 6,
|
|
precision: 'float16'
|
|
};
|
|
}
|
|
else {
|
|
// Normal operation
|
|
return baseConfig;
|
|
}
|
|
}
|
|
//# sourceMappingURL=robotics-navigation.js.map
|