Apollo 11.0
自动驾驶开放平台
barrier_recognition_bank.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2024 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
20#include "modules/perception/barrier_recognition/detector/proto/barrier_bank_config.pb.h"
22
23namespace apollo {
24namespace perception {
25namespace lidar {
26
28 // get config
29 std::string config_file = GetConfigFile(options.config_path, options.config_file);
30 BarrierBankConfig config;
31 ACHECK(cyber::common::GetProtoFromFile(config_file, &config));
32 barrier_bank_map_.clear();
33 for (int i = 0; i < config.plugins_size(); ++i) {
34 const auto& plugin = config.plugins(i);
35 const auto& name = plugin.name();
36 std::shared_ptr<BaseBarrierRecognizer> recognizer =
40 if (!recognizer) {
41 AINFO << "Failed to find barrier recognizer: " << name << ", skipped";
42 continue;
43 }
45 option.config_path = plugin.config_path();
46 option.config_file = plugin.config_file();
47 if (!recognizer->Init(option)) {
48 AINFO << "Failed to init barrier recognizer: " << name << ", skipped";
49 continue;
50 }
51 barrier_bank_map_[name] = recognizer;
52 AINFO << "Recognizer bank add: " << name;
53 }
54 return true;
55}
56
57bool BarrierRecognizerBank::Recognize(const BarrierRecognizerOptions& options, LidarFrame *frame, float& open_percent) {
58 std::string barrier_type = options.name;
59 if (barrier_bank_map_.find(barrier_type) == barrier_bank_map_.end()) {
60 AERROR << "Failed to find barrier recognizer: " << barrier_type;
61 return false;
62 }
63 if (!barrier_bank_map_[barrier_type]->Recognize(options, frame, open_percent)) {
64 AINFO << "Failed to call barrier recognizer: " << barrier_type;
65 }
66 return true;
67}
68
69} // namespace lidar
70} // namespace perception
71} // namespace apollo
static PluginManager * Instance()
get singleton instance of PluginManager
std::shared_ptr< Base > CreateInstance(const std::string &derived_class)
create plugin instance of derived class based on Base
bool Init(const BarrierRecognizerInitOptions &options=BarrierRecognizerInitOptions())
Init of BarrierRecognizerBank object
bool Recognize(const BarrierRecognizerOptions &options, LidarFrame *frame, float &open_percent)
calculate the relative position of the vehicle based on the reflector
static std::string GetFullClassName(const std::string &class_name)
Given the class name of perception module, combine the namespace "apollo::perception::lidar::" with i...
#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
std::string GetConfigFile(const std::string &config_path, const std::string &config_file)
Definition util.cc:80
class register implement
Definition arena_queue.h:37