Formula Student Autonomous Systems
The code for the main driverless system
Loading...
Searching...
No Matches
main.cpp
Go to the documentation of this file.
2#include "rclcpp/rclcpp.hpp"
4
12int main(int argc, char **argv) {
13 (void)argc;
14 (void)argv;
15 rclcpp::init(argc, argv);
16
17 SLAMParameters params;
18 std::string adapter_type = params.load_config();
19 std::shared_ptr<SLAMNode> slam_node = adapter_map.at(adapter_type)(params);
20 slam_node->init();
21
22 // If asynchronous optimization or synch parallel with graph slam, use a multi-threaded executor
23 if (params.slam_optimization_mode_ == "async" ||
24 (params.slam_solver_name_ == "graph_slam" &&
25 params.slam_optimization_mode_ == "sync-parallel")) {
26 rclcpp::executors::MultiThreadedExecutor executor;
27 executor.add_node(slam_node);
28 executor.spin();
29 } else {
30 rclcpp::spin(slam_node);
31 }
32 rclcpp::shutdown();
33
34 return 0;
35}
const std::map< std::string, std::function< std::shared_ptr< ControlNode >(const ControlParameters &)>, std::less<> > adapter_map
Definition map.hpp:18
Definition main.py:1
std::shared_ptr< rclcpp::executors::SingleThreadedExecutor > executor
Parameters for the SLAM node.
std::string slam_optimization_mode_
std::string slam_solver_name_
std::string load_config()
Load the configuration for the SLAM node from YAML file.