CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
LibCarla
source
carla
ros2
publishers
CarlaLidarPublisher.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 "
carla/ros2/publishers/CarlaPointCloudPublisher.h
"
10
11
#include <cstdint>
12
#include <vector>
13
14
namespace
carla
{
15
namespace
ros2
{
16
17
class
CarlaLidarPublisher
:
public
CarlaPointCloudPublisher
{
18
public
:
19
CarlaLidarPublisher
(std::string base_topic_name, std::string frame_id,
bool
exact_topic =
false
)
20
:
CarlaPointCloudPublisher
(
std
::move(base_topic_name),
std
::move(frame_id), exact_topic) {}
21
22
// Plain XYZI path (4 float32 per point). Shadows the base method so a call
23
// through a CarlaLidarPublisher pointer always resets the extended mode
24
// before the base implementation consults the layout virtuals.
25
bool
WritePointCloud
(
26
std::int32_t seconds,
27
std::uint32_t nanoseconds,
28
std::uint32_t height,
29
std::uint32_t width,
30
const
std::uint8_t *data) {
31
_extended
=
false
;
32
return
CarlaPointCloudPublisher::WritePointCloud
(
33
seconds, nanoseconds, height, width, data);
34
}
35
36
// Extended XYZIRCAEDT path (tier4 SetDataEx port): expands each 16 B XYZI
37
// detection into the 32 B Autoware PointXYZIRCAEDT layout declared by
38
// kLidarFieldsEx. `data` is the raw XYZI buffer (`width` points of 4
39
// float32s), `channel_point_counts` holds `channel_count` per-channel point
40
// counts (the LidarData header tail), and `vertical_angles` provides one
41
// elevation (radians) per channel.
42
bool
WriteExtendedPointCloud
(
43
std::int32_t seconds,
44
std::uint32_t nanoseconds,
45
std::uint32_t height,
46
std::uint32_t width,
47
const
std::uint8_t *data,
48
const
std::uint32_t *channel_point_counts,
49
std::size_t channel_count,
50
const
std::vector<float> &vertical_angles);
51
52
private
:
53
[[nodiscard]] std::size_t
GetPointSize
()
const override
;
54
[[nodiscard]]
const
PointFieldDescriptor
*
GetFieldDescriptors
()
const override
;
55
[[nodiscard]] std::size_t
GetFieldDescriptorCount
()
const override
;
56
[[nodiscard]] std::vector<std::uint8_t>
ComputePointCloud
(
57
std::uint32_t height, std::uint32_t width,
const
std::uint8_t *data)
const override
;
58
59
// Extended-mode state, set by WriteExtendedPointCloud before it delegates
60
// to the base WritePointCloud (which consults the virtuals above).
61
bool
_extended
=
false
;
62
std::vector<std::uint32_t>
_channel_point_counts
;
63
std::vector<float>
_vertical_angles
;
64
};
65
66
}
// namespace ros2
67
}
// namespace carla
CarlaPointCloudPublisher.h
carla::ros2::CarlaLidarPublisher::ComputePointCloud
std::vector< std::uint8_t > ComputePointCloud(std::uint32_t height, std::uint32_t width, const std::uint8_t *data) const override
Definition
CarlaLidarPublisher.cpp:87
carla::ros2::CarlaLidarPublisher::_channel_point_counts
std::vector< std::uint32_t > _channel_point_counts
Definition
CarlaLidarPublisher.h:62
carla::ros2::CarlaLidarPublisher::_extended
bool _extended
Definition
CarlaLidarPublisher.h:61
carla::ros2::CarlaLidarPublisher::CarlaLidarPublisher
CarlaLidarPublisher(std::string base_topic_name, std::string frame_id, bool exact_topic=false)
Definition
CarlaLidarPublisher.h:19
carla::ros2::CarlaLidarPublisher::_vertical_angles
std::vector< float > _vertical_angles
Definition
CarlaLidarPublisher.h:63
carla::ros2::CarlaLidarPublisher::GetFieldDescriptorCount
std::size_t GetFieldDescriptorCount() const override
Definition
CarlaLidarPublisher.cpp:66
carla::ros2::CarlaLidarPublisher::WritePointCloud
bool WritePointCloud(std::int32_t seconds, std::uint32_t nanoseconds, std::uint32_t height, std::uint32_t width, const std::uint8_t *data)
Definition
CarlaLidarPublisher.h:25
carla::ros2::CarlaLidarPublisher::GetFieldDescriptors
const PointFieldDescriptor * GetFieldDescriptors() const override
Definition
CarlaLidarPublisher.cpp:62
carla::ros2::CarlaLidarPublisher::WriteExtendedPointCloud
bool WriteExtendedPointCloud(std::int32_t seconds, std::uint32_t nanoseconds, std::uint32_t height, std::uint32_t width, const std::uint8_t *data, const std::uint32_t *channel_point_counts, std::size_t channel_count, const std::vector< float > &vertical_angles)
Definition
CarlaLidarPublisher.cpp:70
carla::ros2::CarlaLidarPublisher::GetPointSize
std::size_t GetPointSize() const override
Definition
CarlaLidarPublisher.cpp:58
carla::ros2::CarlaPointCloudPublisher::CarlaPointCloudPublisher
CarlaPointCloudPublisher(std::string base_topic_name, std::string frame_id, bool exact_topic=false)
Definition
CarlaPointCloudPublisher.cpp:62
carla::ros2::CarlaPointCloudPublisher::WritePointCloud
bool WritePointCloud(std::int32_t seconds, std::uint32_t nanoseconds, std::uint32_t height, std::uint32_t width, const std::uint8_t *data)
Definition
CarlaPointCloudPublisher.cpp:77
carla::ros2
Definition
AutowareSteeringCompensation.h:15
carla
This file contains definitions of common data structures used in traffic manager.
Definition
SignComponent.h:21
std
Definition
CarlaRecorderCollision.h:31
carla::ros2::PointFieldDescriptor
Definition
PointCloudFieldsLayout.h:33
Generated by
1.18.0