Apollo 11.0
自动驾驶开放平台
cyber_record_parser.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
17#include <boost/filesystem.hpp>
18#include <boost/program_options.hpp>
19
20#include "cyber/cyber.h"
24
28
29int main(int argc, char **argv) {
30 boost::program_options::options_description boost_desc("Allowed options");
31 boost_desc.add_options()("help", "produce help message")(
32 "bag_files", boost::program_options::value<std::vector<std::string>>(),
33 "provide the bag file")("out_folder",
34 boost::program_options::value<std::string>(),
35 "provide the output folder")(
36 "cloud_topic",
37 boost::program_options::value<std::string>()->default_value(
38 "/apollo/sensor/velodyne64/compensator/PointCloud2"),
39 "provide point cloud2 topic")(
40 "gnss_loc_topic",
41 boost::program_options::value<std::string>()->default_value(
42 "/apollo/localization/measure_gnss"),
43 "provide gnss localization topic")(
44 "lidar_loc_topic",
45 boost::program_options::value<std::string>()->default_value(
46 "/apollo/localization/measure_lidar"),
47 "provide lidar localization topic")(
48 "fusion_loc_topic",
49 boost::program_options::value<std::string>()->default_value(
50 "/apollo/localization/pose"),
51 "provide fusion localization topic")(
52 "odometry_loc_topic",
53 boost::program_options::value<std::string>()->default_value(
54 "/apollo/sensor/gnss/odometry"),
55 "provide odometry localization topic");
56
57 boost::program_options::variables_map boost_args;
58 boost::program_options::store(
59 boost::program_options::parse_command_line(argc, argv, boost_desc),
60 boost_args);
61 boost::program_options::notify(boost_args);
62
63 if (boost_args.count("help") || !boost_args.count("bag_files") ||
64 !boost_args.count("out_folder")) {
65 AERROR << boost_desc;
66 return 0;
67 }
68
69 const std::vector<std::string> bag_files =
70 boost_args["bag_files"].as<std::vector<std::string>>();
71 const std::string pcd_folder =
72 boost_args["out_folder"].as<std::string>() + "/pcd";
73 if (!boost::filesystem::exists(pcd_folder)) {
74 boost::filesystem::create_directory(pcd_folder);
75 }
76
77 const std::string cloud_topic = boost_args["cloud_topic"].as<std::string>();
78 const std::string gnss_loc_topic =
79 boost_args["gnss_loc_topic"].as<std::string>();
80 const std::string lidar_loc_topic =
81 boost_args["lidar_loc_topic"].as<std::string>();
82 const std::string fusion_loc_topic =
83 boost_args["fusion_loc_topic"].as<std::string>();
84 const std::string odometry_loc_topic =
85 boost_args["odometry_loc_topic"].as<std::string>();
86
87 std::unique_ptr<PCDExporter> pcd_exporter(new PCDExporter(pcd_folder));
88 std::unique_ptr<LocationExporter> loc_exporter(
89 new LocationExporter(pcd_folder));
90
91 CyberRecordReader reader;
92 reader.Subscribe(cloud_topic, [&](const std::string &msg) {
93 pcd_exporter->CompensatedPcdCallback(msg);
94 });
95
96 reader.Subscribe(gnss_loc_topic, [&](const std::string &msg) {
97 loc_exporter->GnssLocCallback(msg);
98 });
99
100 reader.Subscribe(lidar_loc_topic, [&](const std::string &msg) {
101 loc_exporter->LidarLocCallback(msg);
102 });
103
104 reader.Subscribe(fusion_loc_topic, [&](const std::string &msg) {
105 loc_exporter->FusionLocCallback(msg);
106 });
107
108 reader.Subscribe(odometry_loc_topic, [&](const std::string &msg) {
109 loc_exporter->OdometryLocCallback(msg);
110 });
111
112 reader.Read(bag_files);
113
114 return 0;
115}
void Subscribe(const std::string &topic, const std::function< void(const std::string &)> call_back)
void Read(const std::string &file_name)
Export info about localziation in rosbag.
int main(int argc, char **argv)
#define AERROR
Definition log.h:44