| 89 | } // namespace |
| 90 | |
| 91 | int main(int argc, char** argv) { |
| 92 | ros::init(argc, argv, "static_mapping_node"); |
| 93 | ros::NodeHandle n; |
| 94 | |
| 95 | SIMPLE_PROF_USE_MS; |
| 96 | SIMPLE_PROF_MERGE_OUTPUT; |
| 97 | |
| 98 | google::InitGoogleLogging(argv[0]); |
| 99 | FLAGS_alsologtostderr = true; |
| 100 | FLAGS_colorlogtostderr = true; |
| 101 | google::InstallFailureSignalHandler(); |
| 102 | |
| 103 | // parse auguements |
| 104 | // point cloud |
| 105 | std::string point_cloud_topic = ""; |
| 106 | pcl::console::parse_argument(argc, argv, "-pc", point_cloud_topic); |
| 107 | if (point_cloud_topic.empty()) { |
| 108 | PRINT_ERROR("point cloud topic is empty!"); |
| 109 | return -1; |
| 110 | } else { |
| 111 | PRINT_INFO_FMT("Get point cloud from ROS topic: %s", |
| 112 | point_cloud_topic.c_str()); |
| 113 | } |
| 114 | ros::Subscriber sub_pointcloud = |
| 115 | n.subscribe(point_cloud_topic, 10, pointcloud_callback); |
| 116 | std::string cloud_frame_id = "base_link"; |
| 117 | pcl::console::parse_argument(argc, argv, "-pc_frame_id", cloud_frame_id); |
| 118 | |
| 119 | // imu |
| 120 | std::string imu_topic = ""; |
| 121 | bool use_imu = false; |
| 122 | ros::Subscriber sub_imu; |
| 123 | std::string imu_frame_id = "/novatel_imu"; |
| 124 | pcl::console::parse_argument(argc, argv, "-imu", imu_topic); |
| 125 | if (imu_topic.empty()) { |
| 126 | PRINT_WARNING("No imu topic, expect no imu messages."); |
| 127 | } else { |
| 128 | PRINT_INFO_FMT("Get imu data from ROS topic: %s", imu_topic.c_str()); |
| 129 | sub_imu = n.subscribe(imu_topic, 100, imu_callback); |
| 130 | pcl::console::parse_argument(argc, argv, "-imu_frame_id", imu_frame_id); |
| 131 | use_imu = true; |
| 132 | } |
| 133 | |
| 134 | // odom |
| 135 | bool use_odom = false; |
| 136 | std::string odom_topic = ""; |
| 137 | std::string odom_frame_id = ""; |
| 138 | pcl::console::parse_argument(argc, argv, "-odom", odom_topic); |
| 139 | pcl::console::parse_argument(argc, argv, "-odom_frame_id", odom_frame_id); |
| 140 | ros::Subscriber sub_odom; |
| 141 | if (!odom_topic.empty() && !odom_frame_id.empty()) { |
| 142 | sub_odom = n.subscribe(odom_topic, 100, odom_callback); |
| 143 | use_odom = true; |
| 144 | PRINT_INFO_FMT("Get odom data from ROS topic: %s", odom_topic.c_str()); |
| 145 | } else { |
| 146 | PRINT_WARNING("No odom data accessed!"); |
| 147 | } |
| 148 |
nothing calls this directly
no test coverage detected