CARLA
 
载入中...
搜索中...
未找到
LidarData.h
浏览该文件的文档.
1// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
2// de Barcelona (UAB).
3//
4// This work is licensed under the terms of the MIT license.
5// For a copy, see <https://opensource.org/licenses/MIT>.
6
7#pragma once
8
11
12#include <cstdint>
13#include <vector>
14
15namespace carla {
16
17namespace ros2 {
18 class ROS2;
19}
20
21namespace sensor {
22
23namespace s11n {
24 class LidarSerializer;
25 class LidarHeaderView;
26}
27
28namespace data {
29
30 /// Helper class to store and serialize the data generated by a Lidar.
31 ///
32 /// The header of a Lidar measurement consists of an array of uint32_t's in
33 /// the following layout
34 ///
35 /// {
36 /// Horizontal angle (float),
37 /// Channel count,
38 /// Point count of channel 0,
39 /// ...
40 /// Point count of channel n,
41 /// }
42 ///
43 /// The points are stored in an array of floats
44 ///
45 /// {
46 /// X0, Y0, Z0, I0
47 /// ...
48 /// Xn, Yn, Zn, In
49 /// }
50 ///
51
53 public:
55 float intensity;
56
58 point(0.0f, 0.0f, 0.0f), intensity{0.0f} { }
59 LidarDetection(float x, float y, float z, float intensity) :
60 point(x, y, z), intensity{intensity} { }
63
64 void WritePlyHeaderInfo(std::ostream& out) const{
65 out << "property float32 x\n" \
66 "property float32 y\n" \
67 "property float32 z\n" \
68 "property float32 I";
69 }
70
71 void WriteDetection(std::ostream& out) const{
72 out << point.x << ' ' << point.y << ' ' << point.z << ' ' << intensity;
73 }
74 };
75
77
78 public:
79 explicit LidarData(uint32_t ChannelCount = 0u)
81 }
82
84
85 ~LidarData() = default;
86
87 virtual void ResetMemory(std::vector<uint32_t> points_per_channel) {
88 DEBUG_ASSERT(GetChannelCount() > points_per_channel.size());
89 std::memset(_header.data() + Index::SIZE, 0, sizeof(uint32_t) * GetChannelCount());
90
91 uint32_t total_points = static_cast<uint32_t>(
92 std::accumulate(points_per_channel.begin(), points_per_channel.end(), 0));
93
94 _points.clear();
95 _points.reserve(total_points * 4);
96 }
97
98 void WritePointSync(LidarDetection &detection) {
99 _points.emplace_back(detection.point.x);
100 _points.emplace_back(detection.point.y);
101 _points.emplace_back(detection.point.z);
102 _points.emplace_back(detection.intensity);
103 }
104
105 virtual void WritePointSync(SemanticLidarDetection &detection) {
106 (void) detection;
107 DEBUG_ASSERT(false);
108 }
109
110 private:
111 std::vector<float> _points;
112
115 friend class carla::ros2::ROS2;
116 };
117
118} // namespace s11n
119} // namespace sensor
120} // namespace carla
#define DEBUG_ASSERT(predicate)
Definition Debug.h:66
virtual void WritePointSync(SemanticLidarDetection &detection)
Definition LidarData.h:105
std::vector< float > _points
Definition LidarData.h:111
virtual void ResetMemory(std::vector< uint32_t > points_per_channel)
Definition LidarData.h:87
LidarData & operator=(LidarData &&)=default
LidarData(uint32_t ChannelCount=0u)
Definition LidarData.h:79
void WritePointSync(LidarDetection &detection)
Definition LidarData.h:98
Helper class to store and serialize the data generated by a Lidar.
Definition LidarData.h:52
void WritePlyHeaderInfo(std::ostream &out) const
Definition LidarData.h:64
LidarDetection(float x, float y, float z, float intensity)
Definition LidarData.h:59
void WriteDetection(std::ostream &out) const
Definition LidarData.h:71
LidarDetection(geom::Location p, float intensity)
Definition LidarData.h:61
Helper class to store and serialize the data generated by a RawLidar.
A view over the header of a Lidar measurement.
Serializes the data generated by Lidar sensors.
This file contains definitions of common data structures used in traffic manager.
Definition Carla.cpp:133