旧版本为cartographer_pbstream
源码是pbstream_main.cc
,又实际调用了pbstream_info.cc
和 pbstream_migrate.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23int main(int argc, char** argv)
{
google::InitGoogleLogging(argv[0]);
FLAGS_logtostderr = true;
const std::string usage_message =
"Swiss Army knife for pbstreams.\n\n"
"Currently supported subcommands are:\n"
"\tinfo - Prints summary of pbstream.\n"
"\tmigrate - Migrates old pbstream (w/o header) to new pbstream format.";
google::ParseCommandLineFlags(&argc, &argv, true);
if (argc < 2) {
google::SetUsageMessage(usage_message);
google::ShowUsageWithFlagsRestrict(argv[0], "pbstream_info_main");
return EXIT_FAILURE;
} else if (std::string(argv[1]) == "info") {
return ::cartographer::io::pbstream_info(argc, argv);
} else if (std::string(argv[1]) == "migrate") {
return ::cartographer::io::pbstream_migrate(argc, argv);
}
// 其他情况会报错
}
可执行文件在carto_ws/install_isolated/bin
pbstream_main info
终端执行pbstream_main info
,调用pbstream_info
:打印出pbstream
文件的概况,路径支持环境变量。1
./pbstream_main info $MAPS/file.pbstream
结果的中间一大部分是采用的lua参数,如果不想显示这些参数,注释掉源码里的LOG(INFO) << "Trajectory options: " << trajectory_options.DebugString();
结果如下:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26Reading pbstream file from '/home/xiaoqiang/carto_ws/maps/file.pbstream'...
Header: format_version: 2
Trajectory options: sensor_id {
id: "scan"
}
sensor_id {
type: IMU
id: "imu"
}
sensor_id {
type: ODOMETRY
id: "odom"
}
# ......省略lua参数
Trajectory id: 0 has #nodes 9778 has #submaps 161
SerializedData package contains #node: 9778
SerializedData package contains #odometry_data: 49697
SerializedData package contains #submap: 161
SerializedData package contains #submap_2d: 161
SerializedData package contains #submap_2d_grid: 161
SerializedData package contains #submap_3d: 0
SerializedData package contains #submap_3d_high_resolution_hybrid_grid: 0
SerializedData package contains #trajectory_data: 1
不要在最后加-all_debug_strings=true
,否则打印出无穷无尽的内容,包括了栅格值和子图转换表等等。
pbstream_main migrate
终端执行pbstream_main migrate
,调用pbstream_migrate
:把pbstream
文件移植到新的子图格式。把未使用histogram的子图文件移植为包含histogram的子图格式。如果想在输出文件中排除未完成的子图,设置--include_unfinished_submaps
为false