| 344 | } |
| 345 | |
| 346 | int main(int argc, char** argv) { |
| 347 | cout << colouredString("Initializing ROS node:", RED, BOLD) << endl; |
| 348 | |
| 349 | ros::init(argc, argv, "dataset_converter"); |
| 350 | |
| 351 | ros::NodeHandle nh; |
| 352 | |
| 353 | cout << colouredString("DONE!", GREEN, BOLD) << endl; |
| 354 | |
| 355 | cout << colouredString("Initializing sensor information:", RED, BOLD) << endl; |
| 356 | |
| 357 | map<string, map<string, string>> topic2info_map = sensorInfo(nh); |
| 358 | |
| 359 | cout << colouredString("DONE!", GREEN, BOLD) << endl; |
| 360 | |
| 361 | cout << colouredString("Creating folders:", RED, BOLD) << endl; |
| 362 | |
| 363 | string path(argv[1]); |
| 364 | size_t pos = path.find_last_of("/"); |
| 365 | size_t pos_dot = path.find_last_of("."); |
| 366 | |
| 367 | string bagname; |
| 368 | string bagpath; |
| 369 | if (pos == string::npos) { |
| 370 | cout << colouredString( |
| 371 | "Relative path are not supported. Use an absolute path instead." |
| 372 | "For example: roslaunch okvis_ros convert_datasert.launch bag:= /absolute/path/here", |
| 373 | RED, |
| 374 | BOLD) |
| 375 | << endl; |
| 376 | exit(EXIT_FAILURE); |
| 377 | } else { |
| 378 | bagname = path.substr(pos + 1, pos_dot - pos - 1); |
| 379 | bagpath = path.substr(0, pos + 1); |
| 380 | } |
| 381 | |
| 382 | if (!createDirs(bagpath + bagname, topic2info_map)) { |
| 383 | cout << colouredString("FAILED!", RED, BACKGROUND); |
| 384 | exit(EXIT_FAILURE); |
| 385 | } else { |
| 386 | cout << colouredString("DONE!", GREEN, BOLD) << endl; |
| 387 | } |
| 388 | cout << colouredString("Reading bag:", RED, BOLD) << endl; |
| 389 | |
| 390 | rosbag::Bag bag; |
| 391 | cout << colouredString("\tOpening bag...", RED, REGULAR); |
| 392 | bag.open(argv[1], rosbag::bagmode::Read); |
| 393 | cout << colouredString("\t[DONE!]", GREEN, REGULAR) << endl; |
| 394 | |
| 395 | cout << colouredString("\tQuering topics bag...", RED, REGULAR); |
| 396 | |
| 397 | vector<string> topic_list; |
| 398 | |
| 399 | rosbag::View view(bag); |
| 400 | |
| 401 | vector<const rosbag::ConnectionInfo*> bag_info = view.getConnections(); |
| 402 | std::set<string> bag_topics; |
| 403 |
nothing calls this directly
no test coverage detected