Apollo 11.0
自动驾驶开放平台
pointcloud_ground_detection_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
20
21namespace apollo {
22namespace perception {
23namespace lidar {
24
26
29 if (!GetProtoConfig(&comp_config)) {
30 AERROR << "Get PointCloudGroundDetectComponentConfig file failed";
31 return false;
32 }
33 AINFO << "PointCloud Ground Detect Component Configs: "
34 << comp_config.DebugString();
35 output_channel_name_ = comp_config.output_channel_name();
36 writer_ =
37 node_->CreateWriter<onboard::LidarFrameMessage>(output_channel_name_);
38
39 // groun detector
40 auto plugin_param = comp_config.plugin_param();
41 std::string ground_detector_name = plugin_param.name();
42 ground_detector_ =
43 BaseGroundDetectorRegisterer::GetInstanceByName(ground_detector_name);
44 CHECK_NOTNULL(ground_detector_);
45
46 GroundDetectorInitOptions ground_detector_init_options;
47 ground_detector_init_options.config_path = plugin_param.config_path();
48 ground_detector_init_options.config_file = plugin_param.config_file();
49 ACHECK(ground_detector_->Init(ground_detector_init_options))
50 << "Failed to init ground detection.";
51 return true;
52}
53
55 const std::shared_ptr<LidarFrameMessage>& message) {
57 // internal proc
58 bool status = InternalProc(message);
59 if (status) {
60 writer_->Write(message);
61 AINFO << "Send pointcloud ground detect output message.";
62 }
63 return true;
64}
65
66bool PointCloudGroundDetectComponent::InternalProc(
67 const std::shared_ptr<LidarFrameMessage>& message) {
68 auto lidar_frame_ref = message->lidar_frame_;
69 PERF_BLOCK("ground_detector")
70 GroundDetectorOptions ground_detector_options;
71 if (!ground_detector_->Detect(
72 ground_detector_options, lidar_frame_ref.get())) {
73 AERROR << "Ground detect error.";
74 return false;
75 }
77
78 return true;
79}
80
81} // namespace lidar
82} // namespace perception
83} // namespace apollo
bool GetProtoConfig(T *config) const
std::shared_ptr< Node > node_
virtual bool Init(const GroundDetectorInitOptions &options=GroundDetectorInitOptions())=0
Init ground detector
bool Proc(const std::shared_ptr< LidarFrameMessage > &message) override
Process of pointcloud ground detection
#define ACHECK(cond)
Definition log.h:80
#define AERROR
Definition log.h:44
#define AINFO
Definition log.h:42
std::string GetAbsolutePath(const std::string &prefix, const std::string &relative_path)
Get absolute path by concatenating prefix and relative_path.
Definition file.cc:179
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