#include <rclcpp/rclcpp.hpp>
#include <rclcpp/logger.hpp>

#include "../include/brain/cerebellum_node.hpp"
#include "../include/brain/cerebrum_node.hpp"

/**
 * @file brain_node.cpp
 * @brief Entry point launching both Cerebrum and Cerebellum nodes in a single-threaded executor.
 */

/**
 * @brief Program entry: initialize ROS, create nodes, spin executor.
 *
 * Creates a SingleThreadedExecutor hosting both high-level (Cerebrum) and execution (Cerebellum)
 * components. Shutdown occurs when SIGINT or rclcpp shutdown is triggered.
 * @param argc Argument count.
 * @param argv Argument vector.
 * @return Zero on normal termination.
 */
int main(int argc, char ** argv)
{
  rclcpp::init(argc, argv);

  rclcpp::Logger logger = rclcpp::get_logger("brain_node");
  RCLCPP_INFO(logger, "Starting brain node...");

  auto executor = std::make_shared<rclcpp::executors::SingleThreadedExecutor>();
  rclcpp::NodeOptions options;

  auto cerebellum_node = std::make_shared<brain::CerebellumNode>(options);
  auto cerebrum_node = std::make_shared<brain::CerebrumNode>(options);

  executor->add_node(cerebellum_node);
  executor->add_node(cerebrum_node);

  executor->spin();

  rclcpp::shutdown();
  return 0;
}
