#include "recharge/recharge.hpp"
#include <rclcpp/executors/multi_threaded_executor.hpp>

// 如果使用可视化节点，需要包含其头文件
// #include "visualization_debug.hpp"  // 创建对应的头文件

int main(int argc, char** argv) {
    rclcpp::init(argc, argv);
    
    // 创建执行器
    auto executor = std::make_shared<rclcpp::executors::MultiThreadedExecutor>();
    
    // 创建各个节点
    auto default_node = std::make_shared<rclcpp::Node>("default_node");
    auto node_ctrl = std::make_shared<ScanFilterNode>();
    auto node_manager = std::make_shared<ChargingManager>();
    auto node_can = std::make_shared<RechargerRecv>();
    
    // 如果需要可视化，取消注释
    // auto visualizer = std::make_shared<RechargeVisualizer>();
    
    // 将节点添加到执行器
    executor->add_node(default_node);
    executor->add_node(node_ctrl);
    executor->add_node(node_manager);
    executor->add_node(node_can);
    
    // 如果需要可视化，取消注释
    // executor->add_node(visualizer);
    
    try {
        executor->spin();
    } catch (const std::exception& e) {
        std::cerr << "Exception: " << e.what() << std::endl;
    } catch (...) {
        std::cerr << "Unknown exception" << std::endl;
    }
    
    rclcpp::shutdown();
    return 0;
}