Apollo 11.0
自动驾驶开放平台
record_to_learning_data.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2020 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
19#include "absl/strings/str_split.h"
20
21#include "modules/planning/planning_base/proto/planning_config.pb.h"
22
23#include "cyber/common/file.h"
30
31namespace apollo {
32namespace planning {
33
35 AINFO << "map_dir: " << FLAGS_map_dir;
36 if (FLAGS_planning_offline_bags.empty()) {
37 return;
38 }
39
40 if (!FeatureOutput::Ready()) {
41 AERROR << "Feature output is not ready.";
42 return;
43 }
44
45 const std::string planning_config_file =
46 "/apollo/modules/planning/planning_component/conf/planning_config.pb.txt";
47 PlanningConfig planning_config;
48 ACHECK(
49 cyber::common::GetProtoFromFile(planning_config_file, &planning_config))
50 << "failed to load planning config file " << planning_config_file;
51
52 MessageProcess message_process;
53 if (!message_process.Init(planning_config)) {
54 return;
55 }
56
57 const std::vector<std::string> inputs =
58 absl::StrSplit(FLAGS_planning_offline_bags, ':');
59 for (const auto& input : inputs) {
60 std::vector<std::string> offline_bags;
61 util::GetFilesByPath(boost::filesystem::path(input), &offline_bags);
62 std::sort(offline_bags.begin(), offline_bags.end());
63 AINFO << "For input " << input << ", found " << offline_bags.size()
64 << " rosbags to process";
65 for (std::size_t i = 0; i < offline_bags.size(); ++i) {
66 AINFO << "\tProcessing: [ " << i + 1 << " / " << offline_bags.size()
67 << " ]: " << offline_bags[i];
68 message_process.ProcessOfflineData(offline_bags[i]);
70 }
71 }
72 message_process.Close();
73}
74
75} // namespace planning
76} // namespace apollo
77
78int main(int argc, char* argv[]) {
79 google::ParseCommandLineFlags(&argc, &argv, true);
81 return 0;
82}
static void WriteRemainderiLearningData(const std::string &record_file)
static bool Ready()
Check if output is ready
bool Init(const PlanningConfig &planning_config)
void ProcessOfflineData(const std::string &record_file)
Planning module main class.
#define ACHECK(cond)
Definition log.h:80
#define AERROR
Definition log.h:44
#define AINFO
Definition log.h:42
bool GetProtoFromFile(const std::string &file_name, google::protobuf::Message *message)
Parses the content of the file specified by the file_name as a representation of protobufs,...
Definition file.cc:132
void GetFilesByPath(const boost::filesystem::path &path, std::vector< std::string > *files)
Definition util.cc:138
class register implement
Definition arena_queue.h:37
int main(int argc, char *argv[])