Apollo 11.0
自动驾驶开放平台
evaluator_submodule.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
18
19#include "cyber/time/clock.h"
21#include "modules/common/adapters/proto/adapter_config.pb.h"
24
25namespace apollo {
26namespace prediction {
27
29
30std::string EvaluatorSubmodule::Name() const {
31 return FLAGS_evaluator_submodule_name;
32}
33
35 evaluator_manager_.reset(new EvaluatorManager());
36 PredictionConf prediction_conf;
37 if (!ComponentBase::GetProtoConfig(&prediction_conf)) {
38 AERROR << "Unable to load prediction conf file: "
39 << ComponentBase::ConfigFilePath();
40 return false;
41 }
42 ADEBUG << "Prediction config file is loaded into: "
43 << prediction_conf.ShortDebugString();
44 if (!MessageProcess::InitEvaluators(evaluator_manager_.get(),
45 prediction_conf)) {
46 return false;
47 }
48 // TODO(kechxu) change topic name when finalized
49 evaluator_writer_ = node_->CreateWriter<SubmoduleOutput>(
50 prediction_conf.topic_conf().evaluator_topic_name());
51 return true;
52}
53
55 const std::shared_ptr<ADCTrajectoryContainer>& adc_trajectory_container,
56 const std::shared_ptr<SubmoduleOutput>& container_output) {
57 constexpr static size_t kHistorySize = 1;
58 const auto frame_start_time = container_output->frame_start_time();
59 ObstaclesContainer obstacles_container(*container_output);
60 evaluator_manager_->Run(adc_trajectory_container.get(),
61 &obstacles_container);
62 SubmoduleOutput submodule_output =
63 obstacles_container.GetSubmoduleOutput(kHistorySize, frame_start_time);
64 evaluator_writer_->Write(submodule_output);
65 return true;
66}
67
68} // namespace prediction
69} // namespace apollo
std::shared_ptr< Node > node_
std::string Name() const
Get name of the node
bool Proc(const std::shared_ptr< ADCTrajectoryContainer > &adc_trajectory_container, const std::shared_ptr< SubmoduleOutput > &) override
Data callback upon receiving a prediction container output.
bool Init() override
Initialize the node
static bool InitEvaluators(EvaluatorManager *evaluator_manager, const PredictionConf &prediction_conf)
SubmoduleOutput GetSubmoduleOutput(const size_t history_size, const apollo::cyber::Time &frame_start_time)
const apollo::cyber::Time & frame_start_time() const
Use evaluator submodule to manage all evaluators
#define ADEBUG
Definition log.h:41
#define AERROR
Definition log.h:44
class register implement
Definition arena_queue.h:37