Apollo 10.0
自动驾驶开放平台
records_to_offline_data.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2019 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 "cyber/common/file.h"
18
19#include "absl/strings/str_split.h"
24#include "modules/prediction/proto/prediction_conf.pb.h"
26
27namespace apollo {
28namespace prediction {
29
32 if (!FeatureOutput::Ready()) {
33 AERROR << "Feature output is not ready.";
34 return;
35 }
36 if (FLAGS_prediction_offline_bags.empty()) {
37 return;
38 }
39
40 PredictionConf prediction_conf;
41 if (!cyber::common::GetProtoFromFile(FLAGS_prediction_conf_file,
42 &prediction_conf)) {
43 AERROR << "Unable to load adapter conf file: "
44 << FLAGS_prediction_adapter_config_filename;
45 return;
46 }
47 ADEBUG << "Adapter config file is loaded into: "
48 << prediction_conf.ShortDebugString();
49
50 auto container_manager = std::make_shared<ContainerManager>();
51 EvaluatorManager evaluator_manager;
52 PredictorManager predictor_manager;
53 ScenarioManager scenario_manager;
54
55 if (!MessageProcess::Init(container_manager.get(), &evaluator_manager,
56 &predictor_manager, prediction_conf)) {
57 return;
58 }
59 const std::vector<std::string> inputs =
60 absl::StrSplit(FLAGS_prediction_offline_bags, ':');
61 for (const auto& input : inputs) {
62 std::vector<std::string> offline_bags;
63 GetRecordFileNames(boost::filesystem::path(input), &offline_bags);
64 std::sort(offline_bags.begin(), offline_bags.end());
65 AINFO << "For input " << input << ", found " << offline_bags.size()
66 << " rosbags to process";
67 for (std::size_t i = 0; i < offline_bags.size(); ++i) {
68 AINFO << "\tProcessing: [ " << i << " / " << offline_bags.size()
69 << " ]: " << offline_bags[i];
70 MessageProcess::ProcessOfflineData(prediction_conf, container_manager,
71 &evaluator_manager, &predictor_manager,
72 &scenario_manager, offline_bags[i]);
73 }
74 }
76}
77
78} // namespace prediction
79} // namespace apollo
80
81int main(int argc, char* argv[]) {
82 google::ParseCommandLineFlags(&argc, &argv, true);
84 return 0;
85}
static bool Ready()
Check if output is ready
static void Close()
Close the output stream
static void ProcessOfflineData(const PredictionConf &prediction_conf, const std::shared_ptr< ContainerManager > &container_manager, EvaluatorManager *evaluator_manager, PredictorManager *predictor_manager, ScenarioManager *scenario_manager, const std::string &record_filepath)
static bool Init(ContainerManager *container_manager, EvaluatorManager *evaluator_manager, PredictorManager *predictor_manager, const PredictionConf &prediction_conf)
#define ADEBUG
Definition log.h:41
#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 GetRecordFileNames(const boost::filesystem::path &p, std::vector< std::string > *record_files)
class register implement
Definition arena_queue.h:37
int main(int argc, char *argv[])