CARLA
 
载入中...
搜索中...
未找到
LidarMeasurement.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// 预处理指令,确保该头文件在整个项目编译过程中只会被包含一次
9#include "carla/Debug.h"
10// 引入carla项目中与调试相关的头文件
11#include "carla/rpc/Location.h"
12// 引入carla项目里rpc模块下关于Location(通常用于表示位置信息)的头文件
14// 引入carla项目中传感器数据里关于Array(数组相关)的头文件
16// 引入carla项目中传感器序列化相关模块(s11n)里关于激光雷达序列化(LidarSerializer)的头文件
17
18namespace carla {
19namespace sensor {
20namespace data {
21
22 /// Measurement produced by a Lidar. Consists of an array of 3D points plus
23 /// some extra meta-information about the Lidar.
24 class LidarMeasurement : public Array<data::LidarDetection> {
25 static_assert(sizeof(data::LidarDetection) == 4u * sizeof(float), "Location size missmatch");
26// 使用静态断言(static_assert)检查data::LidarDetection类型的大小是否等于4倍float类型的大小,如果不相等则输出给定的错误信息("Location size missmatch")
27
29 // 使用using关键字定义一个类型别名Super
30
31 protected:
33// 使用using关键字定义一个类型别名Serializer
34
35 friend Serializer;
36// 声明s11n::LidarSerializer类为友元类,意味着LidarSerializer类可以访问LidarMeasurement类的私有和保护成员
37
39 : Super(std::move(data), [](const RawData &d) {
41 }) {}
42// 定义构造函数,接收一个右值引用类型的RawData(传感器原始数据)参数。
43// 传递给父类构造函数的参数除了移动语义传入的原始数据(std::move(data))外,还有一个匿名函数(lambda表达式)
44 // 这个匿名函数以RawData类型的引用作为参数,在函数体中调用Serializer(即LidarSerializer类)的GetHeaderOffset函数
45 private:
46
50// 定义一个常成员函数GetHeader
51// 具体做法是先通过调用父类(Super)的GetRawData函数获取原始数据,然后将其作为参数传递给Serializer(LidarSerializer类)的DeserializeHeader函数
52// 利用该函数进行反序列化操作来获取头部信息并返回,这样后续其他成员函数就能基于这个头部信息进行相应的操作了。
53
54 public:
55 /// Horizontal angle of the Lidar at the time of the measurement.
56 auto GetHorizontalAngle() const {
57 return GetHeader().GetHorizontalAngle();
58 }
59 // 定义一个常成员函数GetHorizontalAngle
60 // 它通过先调用GetHeader函数获取头部信息,然后再调用头部信息对象的GetHorizontalAngle函数来获取具体的水平角度值并返回。
61
62 /// Number of channels of the Lidar.
63 auto GetChannelCount() const {
64 return GetHeader().GetChannelCount();
65 }
66// 定义一个常成员函数GetChannelCount
67// 同样是先获取头部信息(调用GetHeader函数),再调用头部信息对象的GetChannelCount函数来获取具体的通道数量值并返回。
68
69 /// Retrieve the number of points that @a channel generated. Points are
70 /// sorted by channel, so this method allows to identify the channel that
71 /// generated each point.
72 auto GetPointCount(size_t channel) const {
73 return GetHeader().GetPointCount(channel);
74 }
75// 定义一个常成员函数GetPointCount,用于获取指定通道(由参数channel指定)所产生的点数信息。
76 // 还是先获取头部信息,然后调用头部信息对象的GetPointCount函数,并传入指定的通道索引(channel)来获取对应通道的点数并返回
77 // 由于点是按照通道进行排序的,所以这个函数可以帮助确定每个点是由哪个通道生成的。
78
79 };
80
81} // namespace data
82} // namespace sensor
83} // namespace carla
包装一个传感器生成的原始数据以及一些有用的元信息。
Definition RawData.h:20
所有传感器数据的基类,包含一个项目数组。
Definition Array.h:23
Measurement produced by a Lidar.
auto GetPointCount(size_t channel) const
Retrieve the number of points that channel generated.
auto GetHorizontalAngle() const
Horizontal angle of the Lidar at the time of the measurement.
auto GetChannelCount() const
Number of channels of the Lidar.
Serializes the data generated by Lidar sensors.
static LidarHeaderView DeserializeHeader(const RawData &data)
static size_t GetHeaderOffset(const RawData &data)
CARLA模拟器的主命名空间。
Definition Carla.cpp:139