Apollo 11.0
自动驾驶开放平台
pointcloud_motion_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 PointCloudMotionComponentConfig file failed";
29 return false;
30 }
31 AINFO << "PointCloud Motion 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 BaseMotionParser* parser = BaseMotionParserRegisterer::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 motion component.";
49 return true;
50}
51
52bool PointCloudMotionComponent::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 Motion message.";
60 }
61 return status;
62}
63
64bool PointCloudMotionComponent::InternalProc(const std::shared_ptr<LidarFrameMessage>& in_message) {
65 // parser
66 PERF_BLOCK("pointcloud_motion")
67 PointCloudParserOptions parser_options;
68 if (!parser_->Parse(parser_options, in_message->lidar_frame_.get())) {
69 AERROR << "PointCloud motion error!";
70 return false;
71 }
73
74 return true;
75}
76
77} // namespace lidar
78} // namespace perception
79} // namespace apollo
bool GetProtoConfig(T *config) const
std::shared_ptr< Node > node_
bool Init() override
Init pointcloud motion component
bool Proc(const std::shared_ptr< LidarFrameMessage > &message) override
Process of pointcloud motion 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