//! Driver component definitions
//!
//! Catalog of available hardware driver components.

use super::{CargoDependency, Component, ComponentCatalog, ComponentType, DriverConfig, Mecha10Config};

/// Add all driver components to the catalog
pub fn add_drivers(catalog: &mut ComponentCatalog) {
    // RealSense Camera Driver
    catalog.insert(Component {
        id: "realsense-camera".to_string(),
        name: "Intel RealSense Camera".to_string(),
        description: "Driver for Intel RealSense depth cameras (D435, D455, etc.)".to_string(),
        component_type: ComponentType::Driver,
        version: "0.1.0".to_string(),
        category: "vision".to_string(),
        tags: vec!["camera".to_string(), "depth".to_string(), "rgb".to_string()],
        cargo_dependencies: vec![
            CargoDependency {
                name: "mecha10-core".to_string(),
                version: None,
                path: Some("../../packages/core".to_string()),
                features: vec![],
                optional: false,
            },
            CargoDependency {
                name: "realsense-rust".to_string(),
                version: Some("0.6".to_string()),
                path: None,
                features: vec![],
                optional: false,
            },
        ],
        files: vec![],
        mecha10_config: Mecha10Config {
            driver: Some(DriverConfig {
                name: "realsense_camera".to_string(),
                path: "./drivers/realsense_camera".to_string(),
                description: "Intel RealSense depth camera driver".to_string(),
                run_target: "robot".to_string(),
                enabled: true,
            }),
            custom_node: None,
            behavior: None,
        },
    });

    // RPLidar Driver
    catalog.insert(Component {
        id: "rplidar".to_string(),
        name: "Slamtec RPLidar".to_string(),
        description: "Driver for Slamtec RPLidar 2D laser scanners (A1, A2, A3)".to_string(),
        component_type: ComponentType::Driver,
        version: "0.1.0".to_string(),
        category: "sensors".to_string(),
        tags: vec!["lidar".to_string(), "laser".to_string(), "2d".to_string()],
        cargo_dependencies: vec![
            CargoDependency {
                name: "mecha10-core".to_string(),
                version: None,
                path: Some("../../packages/core".to_string()),
                features: vec![],
                optional: false,
            },
            CargoDependency {
                name: "serialport".to_string(),
                version: Some("4.2".to_string()),
                path: None,
                features: vec![],
                optional: false,
            },
        ],
        files: vec![],
        mecha10_config: Mecha10Config {
            driver: Some(DriverConfig {
                name: "rplidar".to_string(),
                path: "./drivers/rplidar".to_string(),
                description: "Slamtec RPLidar 2D laser scanner driver".to_string(),
                run_target: "robot".to_string(),
                enabled: true,
            }),
            custom_node: None,
            behavior: None,
        },
    });

    // Velodyne Lidar Driver
    catalog.insert(Component {
        id: "velodyne-lidar".to_string(),
        name: "Velodyne 3D Lidar".to_string(),
        description: "Driver for Velodyne 3D LiDAR sensors (VLP-16, VLP-32, etc.)".to_string(),
        component_type: ComponentType::Driver,
        version: "0.1.0".to_string(),
        category: "sensors".to_string(),
        tags: vec!["lidar".to_string(), "3d".to_string(), "pointcloud".to_string()],
        cargo_dependencies: vec![CargoDependency {
            name: "mecha10-core".to_string(),
            version: None,
            path: Some("../../packages/core".to_string()),
            features: vec![],
            optional: false,
        }],
        files: vec![],
        mecha10_config: Mecha10Config {
            driver: Some(DriverConfig {
                name: "velodyne_lidar".to_string(),
                path: "./drivers/velodyne_lidar".to_string(),
                description: "Velodyne 3D LiDAR driver".to_string(),
                run_target: "robot".to_string(),
                enabled: true,
            }),
            custom_node: None,
            behavior: None,
        },
    });

    // IMU Driver (MPU9250/BMI088)
    catalog.insert(Component {
        id: "imu-mpu9250".to_string(),
        name: "MPU9250 IMU".to_string(),
        description: "Driver for MPU9250/MPU6050 IMU sensors via I2C".to_string(),
        component_type: ComponentType::Driver,
        version: "0.1.0".to_string(),
        category: "sensors".to_string(),
        tags: vec!["imu".to_string(), "accelerometer".to_string(), "gyroscope".to_string()],
        cargo_dependencies: vec![
            CargoDependency {
                name: "mecha10-core".to_string(),
                version: None,
                path: Some("../../packages/core".to_string()),
                features: vec![],
                optional: false,
            },
            CargoDependency {
                name: "linux-embedded-hal".to_string(),
                version: Some("0.4".to_string()),
                path: None,
                features: vec![],
                optional: false,
            },
        ],
        files: vec![],
        mecha10_config: Mecha10Config {
            driver: Some(DriverConfig {
                name: "imu_mpu9250".to_string(),
                path: "./drivers/imu_mpu9250".to_string(),
                description: "MPU9250 IMU driver via I2C".to_string(),
                run_target: "robot".to_string(),
                enabled: true,
            }),
            custom_node: None,
            behavior: None,
        },
    });

    // Motor Controller (Roboclaw)
    catalog.insert(Component {
        id: "roboclaw-motor".to_string(),
        name: "Roboclaw Motor Controller".to_string(),
        description: "Driver for Roboclaw motor controllers via serial".to_string(),
        component_type: ComponentType::Driver,
        version: "0.1.0".to_string(),
        category: "actuators".to_string(),
        tags: vec![
            "motor".to_string(),
            "controller".to_string(),
            "differential-drive".to_string(),
        ],
        cargo_dependencies: vec![
            CargoDependency {
                name: "mecha10-core".to_string(),
                version: None,
                path: Some("../../packages/core".to_string()),
                features: vec![],
                optional: false,
            },
            CargoDependency {
                name: "serialport".to_string(),
                version: Some("4.2".to_string()),
                path: None,
                features: vec![],
                optional: false,
            },
        ],
        files: vec![],
        mecha10_config: Mecha10Config {
            driver: Some(DriverConfig {
                name: "roboclaw_motor".to_string(),
                path: "./drivers/roboclaw_motor".to_string(),
                description: "Roboclaw motor controller driver".to_string(),
                run_target: "robot".to_string(),
                enabled: true,
            }),
            custom_node: None,
            behavior: None,
        },
    });

    // GPS Driver (U-blox)
    catalog.insert(Component {
        id: "ublox-gps".to_string(),
        name: "U-blox GPS".to_string(),
        description: "Driver for U-blox GPS modules (NEO-M8, ZED-F9P, etc.)".to_string(),
        component_type: ComponentType::Driver,
        version: "0.1.0".to_string(),
        category: "sensors".to_string(),
        tags: vec!["gps".to_string(), "navigation".to_string(), "positioning".to_string()],
        cargo_dependencies: vec![
            CargoDependency {
                name: "mecha10-core".to_string(),
                version: None,
                path: Some("../../packages/core".to_string()),
                features: vec![],
                optional: false,
            },
            CargoDependency {
                name: "serialport".to_string(),
                version: Some("4.2".to_string()),
                path: None,
                features: vec![],
                optional: false,
            },
        ],
        files: vec![],
        mecha10_config: Mecha10Config {
            driver: Some(DriverConfig {
                name: "ublox_gps".to_string(),
                path: "./drivers/ublox_gps".to_string(),
                description: "U-blox GPS driver".to_string(),
                run_target: "robot".to_string(),
                enabled: true,
            }),
            custom_node: None,
            behavior: None,
        },
    });

    // Servo Controller (PCA9685)
    catalog.insert(Component {
        id: "pca9685-servo".to_string(),
        name: "PCA9685 Servo Controller".to_string(),
        description: "Driver for PCA9685 16-channel PWM servo controller via I2C".to_string(),
        component_type: ComponentType::Driver,
        version: "0.1.0".to_string(),
        category: "actuators".to_string(),
        tags: vec!["servo".to_string(), "pwm".to_string(), "i2c".to_string()],
        cargo_dependencies: vec![
            CargoDependency {
                name: "mecha10-core".to_string(),
                version: None,
                path: Some("../../packages/core".to_string()),
                features: vec![],
                optional: false,
            },
            CargoDependency {
                name: "linux-embedded-hal".to_string(),
                version: Some("0.4".to_string()),
                path: None,
                features: vec![],
                optional: false,
            },
        ],
        files: vec![],
        mecha10_config: Mecha10Config {
            driver: Some(DriverConfig {
                name: "pca9685_servo".to_string(),
                path: "./drivers/pca9685_servo".to_string(),
                description: "PCA9685 servo controller driver".to_string(),
                run_target: "robot".to_string(),
                enabled: true,
            }),
            custom_node: None,
            behavior: None,
        },
    });

    // ZED Camera Driver
    catalog.insert(Component {
        id: "zed-camera".to_string(),
        name: "Stereolabs ZED Camera".to_string(),
        description: "Driver for Stereolabs ZED stereo cameras (ZED, ZED 2, ZED X)".to_string(),
        component_type: ComponentType::Driver,
        version: "0.1.0".to_string(),
        category: "vision".to_string(),
        tags: vec!["camera".to_string(), "stereo".to_string(), "depth".to_string()],
        cargo_dependencies: vec![CargoDependency {
            name: "mecha10-core".to_string(),
            version: None,
            path: Some("../../packages/core".to_string()),
            features: vec![],
            optional: false,
        }],
        files: vec![],
        mecha10_config: Mecha10Config {
            driver: Some(DriverConfig {
                name: "zed_camera".to_string(),
                path: "./drivers/zed_camera".to_string(),
                description: "Stereolabs ZED camera driver".to_string(),
                run_target: "robot".to_string(),
                enabled: true,
            }),
            custom_node: None,
            behavior: None,
        },
    });
}
