Apollo 11.0
自动驾驶开放平台
pointcloud_semantic_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
27 if (!GetProtoConfig(&comp_config)) {
28 AERROR << "Get PointCloudSemanticComponentConfig file failed";
29 return false;
30 }
31 AINFO << "PointCloud semantic Component Configs: " << comp_config.DebugString();
32
33 // writer
34 output_channel_name_ = comp_config.output_channel_name();
35 writer_ = node_->CreateWriter<LidarFrameMessage>(output_channel_name_);
36
37 // init parser
38 auto plugin_param = comp_config.plugin_param();
39 std::string parser_name = plugin_param.name();
40 BasePointCloudParser* parser = BasePointCloudParserRegisterer::GetInstanceByName(parser_name);
41 CHECK_NOTNULL(parser);
42 parser_.reset(parser);
43 PointCloudParserInitOptions init_options;
44 init_options.config_path = plugin_param.config_path();
45 init_options.config_file = plugin_param.config_file();
46 ACHECK(parser_->Init(init_options)) << "PointCloud parser init error";
47
48 AINFO << "Successfully init pointcloud parser component.";
49 return true;
50}
51
52bool PointCloudSemanticComponent::Proc(const std::shared_ptr<LidarFrameMessage>& message) {
54 // internal proc
55 bool status = InternalProc(message);
56
57 if (status) {
58 writer_->Write(message);
59 AINFO << "Send PointCloud Semantic message.";
60 } else {
61 AERROR << "PointCloudSemanticComponent InternalProc error.";
62 }
63 return status;
64}
65
66bool PointCloudSemanticComponent::InternalProc(const std::shared_ptr<LidarFrameMessage>& in_message) {
67 // parser
68 PERF_BLOCK("pointcloud_parser")
69 PointCloudParserOptions parser_options;
70 if (!parser_->Parse(parser_options, in_message->lidar_frame_.get())) {
71 AERROR << "PointCloud parser error!";
72 return false;
73 }
75
76 return true;
77}
78
79} // namespace lidar
80} // namespace perception
81} // namespace apollo
bool GetProtoConfig(T *config) const
std::shared_ptr< Node > node_
bool Proc(const std::shared_ptr< LidarFrameMessage > &message) override
Process of pointcloud semantic component
bool Init() override
Init pointcloud semantic component
#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