Apollo 10.0
自动驾驶开放平台
lidar_pointcloud.h
浏览该文件的文档.
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
17#pragma once
18
19#include <algorithm>
20#include <cstring>
21#include <memory>
22#include <string>
23
25
26#include "cyber/proto/simple.pb.h"
27#include "modules/common_msgs/sensor_msgs/pointcloud.pb.h"
28#include "cyber/cyber.h"
30
31#if __has_include("sensor_msgs/point_cloud2_iterator.hpp")
32#include "sensor_msgs/point_cloud2_iterator.hpp"
33#define ENABLE_ROS_MSG
34#endif
35
36#ifdef ENABLE_ROS_MSG
37using InputMsg = sensor_msgs::msg::PointCloud2;
38#else
40#endif
41
43
44using InputMsgPtr = std::shared_ptr<InputMsg>;
45using OutputMsgPtr = std::shared_ptr<OutputMsg>;
46
47namespace apollo {
48namespace cyber {
49
52 InputTypes<InputMsgPtr>, OutputTypes<OutputMsgPtr>> {
53 public:
56
65
66#ifdef ENABLE_ROS_MSG
67 inline int FindFieldIndex(
68 std::string name, sensor_msgs::msg::PointCloud2& cloud_msg) { // NOLINT
69 for (int i = 0; i < cloud_msg.fields.size(); i++) {
70 if (cloud_msg.fields[i].name == name) {
71 return i;
72 }
73 }
74 return -1;
75 }
76#endif
77};
78
81
82} // namespace cyber
83} // namespace apollo
virtual bool ConvertMsg(InputTypes< InputMsgPtr > &, OutputTypes< OutputMsgPtr > &)
convert the message between ros and apollo
#define CYBER_PLUGIN_MANAGER_REGISTER_PLUGIN(name, base)
std::shared_ptr< OutputMsg > OutputMsgPtr
std::shared_ptr< InputMsg > InputMsgPtr
class register implement
Definition arena_queue.h:37