Apollo 11.0
自动驾驶开放平台
pointcloud_map_based_roi_component.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2023 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
21
22namespace apollo {
23namespace perception {
24namespace lidar {
25
28 if (!GetProtoConfig(&comp_config)) {
29 AERROR << "Get PointCloudMapROIComponentConfig file failed";
30 return false;
31 }
32 AINFO << "PointCloud map based roi Component Configs: "
33 << comp_config.DebugString();
34 // writer
35 output_channel_name_ = comp_config.output_channel_name();
36 writer_ = node_->CreateWriter<LidarFrameMessage>(output_channel_name_);
37
38 // Scene manager
40
41 // map manager init
42 use_map_manager_ =
43 comp_config.use_map_manager() && comp_config.enable_hdmap();
44 if (use_map_manager_) {
45 MapManagerInitOptions map_manager_init_options;
46 map_manager_init_options.config_path =
47 comp_config.map_manager_config_path();
48 map_manager_init_options.config_file =
49 comp_config.map_manager_config_file();
50 if (!map_manager_.Init(map_manager_init_options)) {
51 AINFO << "Failed to init map manager.";
52 use_map_manager_ = false;
53 }
54 }
55
56 // init roi filter
57 auto& plugin = comp_config.plugin_param();
60 ConfigUtil::GetFullClassName(plugin.name()));
61
62 CHECK_NOTNULL(roi_filter_);
63 ROIFilterInitOptions roi_filter_init_options;
64 roi_filter_init_options.config_path = plugin.config_path();
65 roi_filter_init_options.config_file = plugin.config_file();
66 ACHECK(roi_filter_->Init(roi_filter_init_options))
67 << "Failed to init roi filter.";
68
69 return true;
70}
71
73 const std::shared_ptr<LidarFrameMessage>& message) {
75 // internal proc
76 bool status = InternalProc(message);
77 if (status) {
78 writer_->Write(message);
79 AINFO << "Send pointcloud map based roi output message.";
80 }
81 return status;
82}
83
84bool PointCloudMapROIComponent::InternalProc(
85 const std::shared_ptr<LidarFrameMessage>& message) {
86 // map update
87 PERF_BLOCK("map_manager")
88 if (use_map_manager_) {
89 MapManagerOptions map_manager_options;
90 if (!map_manager_.Update(map_manager_options,
91 message->lidar_frame_.get())) {
92 AINFO << "Failed to update map structure.";
93 return false;
94 }
95 }
97
98 ROIFilterOptions roi_filter_options;
99 auto lidar_frame_ref = message->lidar_frame_.get();
100 auto original_cloud = lidar_frame_ref->cloud;
101 PERF_BLOCK("roi_filter")
102 if (lidar_frame_ref->hdmap_struct != nullptr &&
103 roi_filter_->Filter(roi_filter_options, lidar_frame_ref)) {
104 // do nothing
105 } else {
106 AINFO << "Fail to call roi filter, use origin cloud.";
107 lidar_frame_ref->roi_indices.indices.resize(original_cloud->size());
108 // we manually fill roi indices with all cloud point indices
109 std::iota(lidar_frame_ref->roi_indices.indices.begin(),
110 lidar_frame_ref->roi_indices.indices.end(), 0);
111 }
113
114 return true;
115}
116
117} // namespace lidar
118} // namespace perception
119} // namespace apollo
bool GetProtoConfig(T *config) const
std::shared_ptr< Node > node_
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
static std::string GetFullClassName(const std::string &class_name)
Given the class name of perception module, combine the namespace "apollo::perception::lidar::" with i...
bool Init(const MapManagerInitOptions &options=MapManagerInitOptions())
Init of Map Manager
bool Update(const MapManagerOptions &options, LidarFrame *frame)
update map structure and lidar2world pose
bool Proc(const std::shared_ptr< LidarFrameMessage > &message) override
Process of Point Cloud Map ROI Component object
bool Init() override
Init of Point Cloud Map ROI Component object
#define ACHECK(cond)
Definition log.h:80
#define AERROR
Definition log.h:44
#define AINFO
Definition log.h:42
class register implement
Definition arena_queue.h:37
#define PERF_FUNCTION(...)
Definition profiler.h:54
#define PERF_BLOCK_END
Definition profiler.h:53
#define PERF_BLOCK(...)
Definition profiler.h:52