CARLA
Loading...
Searching...
No Matches
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
10
11#include <cstdint>
12#include <vector>
13
14namespace carla {
15namespace ros2 {
16
18public:
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.
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;
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.
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
52private:
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
std::vector< std::uint8_t > ComputePointCloud(std::uint32_t height, std::uint32_t width, const std::uint8_t *data) const override
std::vector< std::uint32_t > _channel_point_counts
CarlaLidarPublisher(std::string base_topic_name, std::string frame_id, bool exact_topic=false)
std::size_t GetFieldDescriptorCount() const override
bool WritePointCloud(std::int32_t seconds, std::uint32_t nanoseconds, std::uint32_t height, std::uint32_t width, const std::uint8_t *data)
const PointFieldDescriptor * GetFieldDescriptors() const override
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)
std::size_t GetPointSize() const override
bool WritePointCloud(std::int32_t seconds, std::uint32_t nanoseconds, std::uint32_t height, std::uint32_t width, const std::uint8_t *data)
This file contains definitions of common data structures used in traffic manager.