CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
LibCarla
source
carla
ros2
publishers
PointCloudFieldsLayout.h
Go to the documentation of this file.
1
// Copyright (c) 2026 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 <array>
10
#include <cstdint>
11
#include <string_view>
12
13
namespace
carla
{
14
namespace
ros2
{
15
16
// PointField datatype constants mirror the numeric constants in
17
// carla/ros2/types/msg/PointField.h (carla::ros2::msg::PointField::*). They are
18
// kept here as an enum class so this header does not pull the message types into
19
// the Build-Tests/ compile unit. Producers in publishers/Carla*Publisher.cpp map
20
// these values onto carla::ros2::msg::PointField; this enum mirrors the same
21
// numeric values so layout tests can verify field offsets / sizes.
22
enum class
PointFieldDataType
: std::uint8_t {
23
Int8
= 1,
24
UInt8
= 2,
25
Int16
= 3,
26
UInt16
= 4,
27
Int32
= 5,
28
UInt32
= 6,
29
Float32
= 7,
30
Float64
= 8,
31
};
32
33
struct
PointFieldDescriptor
{
34
std::string_view
name
;
35
std::uint32_t
offset
;
36
PointFieldDataType
datatype
;
37
std::uint32_t
count
;
38
};
39
40
// Lidar: 4 FLOAT32 fields. Point stride = 16 B = sizeof(sensor::data::LidarDetection).
41
inline
constexpr
std::array<PointFieldDescriptor, 4>
kLidarFields
= {{
42
{
"x"
, 0u,
PointFieldDataType::Float32
, 1u},
43
{
"y"
, 4u,
PointFieldDataType::Float32
, 1u},
44
{
"z"
, 8u,
PointFieldDataType::Float32
, 1u},
45
{
"intensity"
, 12u,
PointFieldDataType::Float32
, 1u},
46
}};
47
48
// Extended lidar (Autoware PointXYZIRCAEDT, tier4 SetDataEx port): x/y/z
49
// FLOAT32, intensity + return_type UINT8, channel UINT16, azimuth/elevation/
50
// distance FLOAT32, time_stamp UINT32. Point stride = 32 B, matching both the
51
// tightly packed field layout and the naturally aligned LidarPointEx POD in
52
// CarlaLidarPublisher.cpp (the uint16 lands on offset 14, so no padding).
53
inline
constexpr
std::array<PointFieldDescriptor, 10>
kLidarFieldsEx
= {{
54
{
"x"
, 0u,
PointFieldDataType::Float32
, 1u},
55
{
"y"
, 4u,
PointFieldDataType::Float32
, 1u},
56
{
"z"
, 8u,
PointFieldDataType::Float32
, 1u},
57
{
"intensity"
, 12u,
PointFieldDataType::UInt8
, 1u},
58
{
"return_type"
, 13u,
PointFieldDataType::UInt8
, 1u},
59
{
"channel"
, 14u,
PointFieldDataType::UInt16
, 1u},
60
{
"azimuth"
, 16u,
PointFieldDataType::Float32
, 1u},
61
{
"elevation"
, 20u,
PointFieldDataType::Float32
, 1u},
62
{
"distance"
, 24u,
PointFieldDataType::Float32
, 1u},
63
{
"time_stamp"
, 28u,
PointFieldDataType::UInt32
, 1u},
64
}};
65
66
// Semantic lidar: 6 fields. 4 FLOAT32 + 2 UINT32. Point stride = 24 B =
67
// sizeof(sensor::data::SemanticLidarDetection).
68
inline
constexpr
std::array<PointFieldDescriptor, 6>
kSemanticLidarFields
= {{
69
{
"x"
, 0u,
PointFieldDataType::Float32
, 1u},
70
{
"y"
, 4u,
PointFieldDataType::Float32
, 1u},
71
{
"z"
, 8u,
PointFieldDataType::Float32
, 1u},
72
{
"cos_inc_angle"
, 12u,
PointFieldDataType::Float32
, 1u},
73
{
"object_idx"
, 16u,
PointFieldDataType::UInt32
, 1u},
74
{
"object_tag"
, 20u,
PointFieldDataType::UInt32
, 1u},
75
}};
76
77
// Radar: 7 FLOAT32 fields. Point stride = 28 B =
78
// sizeof(RadarDetectionWithPosition) — 3 Cartesian floats prepended to the
79
// raw RadarDetection payload (velocity, azimuth, altitude, depth).
80
inline
constexpr
std::array<PointFieldDescriptor, 7>
kRadarFields
= {{
81
{
"x"
, 0u,
PointFieldDataType::Float32
, 1u},
82
{
"y"
, 4u,
PointFieldDataType::Float32
, 1u},
83
{
"z"
, 8u,
PointFieldDataType::Float32
, 1u},
84
{
"velocity"
, 12u,
PointFieldDataType::Float32
, 1u},
85
{
"azimuth"
, 16u,
PointFieldDataType::Float32
, 1u},
86
{
"altitude"
, 20u,
PointFieldDataType::Float32
, 1u},
87
{
"depth"
, 24u,
PointFieldDataType::Float32
, 1u},
88
}};
89
90
// DVS events: x/y UINT16, t FLOAT64, pol INT8. The producer converts the
91
// underlying int64 event timestamp to a real double in the 8-byte t slot
92
// (sensor_msgs PointField has no 8-byte integer datatype). Per-point stride
93
// matches the packed sensor::data::DVSEvent (13 B with #pragma pack(push, 1)).
94
inline
constexpr
std::array<PointFieldDescriptor, 4>
kDvsFields
= {{
95
{
"x"
, 0u,
PointFieldDataType::UInt16
, 1u},
96
{
"y"
, 2u,
PointFieldDataType::UInt16
, 1u},
97
{
"t"
, 4u,
PointFieldDataType::Float64
, 1u},
98
{
"pol"
, 12u,
PointFieldDataType::Int8
, 1u},
99
}};
100
101
// Each table's last field's offset + datatype size must equal the
102
// corresponding sensor's point stride. The producers check that with a
103
// runtime sizeof() assertion against the underlying POD; layout tests in
104
// test_point_cloud_fields.cpp verify the same property at compile time.
105
106
}
// namespace ros2
107
}
// namespace carla
carla::ros2
Definition
AutowareSteeringCompensation.h:15
carla::ros2::kLidarFields
constexpr std::array< PointFieldDescriptor, 4 > kLidarFields
Definition
PointCloudFieldsLayout.h:41
carla::ros2::kRadarFields
constexpr std::array< PointFieldDescriptor, 7 > kRadarFields
Definition
PointCloudFieldsLayout.h:80
carla::ros2::PointFieldDataType
PointFieldDataType
Definition
PointCloudFieldsLayout.h:22
carla::ros2::PointFieldDataType::Float32
@ Float32
Definition
PointCloudFieldsLayout.h:29
carla::ros2::PointFieldDataType::Int16
@ Int16
Definition
PointCloudFieldsLayout.h:25
carla::ros2::PointFieldDataType::Int8
@ Int8
Definition
PointCloudFieldsLayout.h:23
carla::ros2::PointFieldDataType::UInt16
@ UInt16
Definition
PointCloudFieldsLayout.h:26
carla::ros2::PointFieldDataType::UInt8
@ UInt8
Definition
PointCloudFieldsLayout.h:24
carla::ros2::PointFieldDataType::Int32
@ Int32
Definition
PointCloudFieldsLayout.h:27
carla::ros2::PointFieldDataType::Float64
@ Float64
Definition
PointCloudFieldsLayout.h:30
carla::ros2::PointFieldDataType::UInt32
@ UInt32
Definition
PointCloudFieldsLayout.h:28
carla::ros2::kDvsFields
constexpr std::array< PointFieldDescriptor, 4 > kDvsFields
Definition
PointCloudFieldsLayout.h:94
carla::ros2::kSemanticLidarFields
constexpr std::array< PointFieldDescriptor, 6 > kSemanticLidarFields
Definition
PointCloudFieldsLayout.h:68
carla::ros2::kLidarFieldsEx
constexpr std::array< PointFieldDescriptor, 10 > kLidarFieldsEx
Definition
PointCloudFieldsLayout.h:53
carla
This file contains definitions of common data structures used in traffic manager.
Definition
SignComponent.h:21
carla::ros2::PointFieldDescriptor
Definition
PointCloudFieldsLayout.h:33
carla::ros2::PointFieldDescriptor::datatype
PointFieldDataType datatype
Definition
PointCloudFieldsLayout.h:36
carla::ros2::PointFieldDescriptor::name
std::string_view name
Definition
PointCloudFieldsLayout.h:34
carla::ros2::PointFieldDescriptor::count
std::uint32_t count
Definition
PointCloudFieldsLayout.h:37
carla::ros2::PointFieldDescriptor::offset
std::uint32_t offset
Definition
PointCloudFieldsLayout.h:35
Generated by
1.18.0