CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
LibCarla
source
carla
ros2
publishers
CarlaPointCloudPublisher.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/BasePublisher.h
"
10
#include "
carla/ros2/publishers/PointCloudFieldsLayout.h
"
11
12
#include <cstddef>
13
#include <cstdint>
14
#include <memory>
15
#include <vector>
16
17
namespace
carla
{
18
namespace
ros2
{
19
20
// Forward declarations keep the FastDDS-heavy PublisherImpl<> definition out
21
// of the main carla-server compile unit. The full template definition + the
22
// PointCloud2 Traits instantiation live in CarlaPointCloudPublisher.cpp,
23
// which is built by the carla-ros2-native ExternalProject (where FastDDS
24
// headers are on the include path). Same Pimpl pattern as PR-3's
25
// CarlaCameraPublisher.{h,cpp}.
26
template
<
typename
Traits>
class
PublisherImpl
;
27
struct
CarlaPointCloudMsgTraits
;
28
29
// Abstract base for ROS 2 publishers that ship sensor_msgs::msg::PointCloud2:
30
// lidar, semantic-lidar, radar, and the point-cloud side of the DVS sensor.
31
// Each subclass declares its PointField layout (via PointCloudFieldsLayout.h)
32
// and implements ComputePointCloud(), which is responsible for any per-point
33
// transform (handedness flip, polar-to-Cartesian conversion, etc.) and
34
// returns the bytes that get written to the wire. The Init() call on the
35
// underlying PublisherImpl happens in the ctor, so a subclass only has to
36
// pass the (base_topic_name, frame_id) pair through.
37
class
CarlaPointCloudPublisher
:
public
BasePublisher
{
38
public
:
39
// exact_topic: when true the writer publishes on base_topic_name verbatim
40
// (no "/point_cloud" suffix). Used by single-topic point-cloud sensors when
41
// the actor carries a ros_topic_name override — tier4's custom topic names
42
// replaced the whole topic for those publishers (e.g. Autoware expects
43
// exactly /sensing/lidar/top/pointcloud_raw_ex). The DVS point-cloud lane
44
// keeps the suffix: it shares its base with the image/camera_info topics.
45
CarlaPointCloudPublisher
(
46
std::string base_topic_name, std::string frame_id,
bool
exact_topic =
false
);
47
~CarlaPointCloudPublisher
()
override
;
48
49
CarlaPointCloudPublisher
(
const
CarlaPointCloudPublisher
&) =
delete
;
50
CarlaPointCloudPublisher
&
operator=
(
const
CarlaPointCloudPublisher
&) =
delete
;
51
CarlaPointCloudPublisher
(
CarlaPointCloudPublisher
&&) noexcept = default;
52
CarlaPointCloudPublisher
&operator=(
CarlaPointCloudPublisher
&&) noexcept = default;
53
54
bool
Publish
() override;
55
56
bool
WritePointCloud
(
57
std
::int32_t seconds,
58
std
::uint32_t nanoseconds,
59
std
::uint32_t height,
60
std
::uint32_t width,
61
const
std
::uint8_t *data);
62
63
protected:
64
[[nodiscard]] virtual
std
::
size_t
GetPointSize
() const = 0;
65
[[nodiscard]] virtual const
PointFieldDescriptor
*
GetFieldDescriptors
() const = 0;
66
[[nodiscard]] virtual
std
::
size_t
GetFieldDescriptorCount
() const = 0;
67
[[nodiscard]] virtual
std
::vector<
std
::uint8_t>
ComputePointCloud
(
68
std
::uint32_t height,
std
::uint32_t width, const
std
::uint8_t *data) const = 0;
69
70
private:
71
bool
WritePointCloud
(
72
std
::int32_t seconds,
73
std
::uint32_t nanoseconds,
74
std
::uint32_t height,
75
std
::uint32_t width,
76
std
::vector<
std
::uint8_t> data);
77
78
std
::shared_ptr<
PublisherImpl
<
CarlaPointCloudMsgTraits
>>
_impl
;
79
};
80
81
}
// namespace ros2
82
}
// namespace carla
BasePublisher.h
PointCloudFieldsLayout.h
carla::ros2::BasePublisher::BasePublisher
BasePublisher()=default
carla::ros2::CarlaPointCloudPublisher::GetPointSize
virtual std::size_t GetPointSize() const =0
carla::ros2::CarlaPointCloudPublisher::GetFieldDescriptorCount
virtual std::size_t GetFieldDescriptorCount() const =0
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::operator=
CarlaPointCloudPublisher & operator=(const CarlaPointCloudPublisher &)=delete
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::CarlaPointCloudPublisher::ComputePointCloud
virtual std::vector< std::uint8_t > ComputePointCloud(std::uint32_t height, std::uint32_t width, const std::uint8_t *data) const =0
carla::ros2::CarlaPointCloudPublisher::GetFieldDescriptors
virtual const PointFieldDescriptor * GetFieldDescriptors() const =0
carla::ros2::CarlaPointCloudPublisher::CarlaPointCloudPublisher
CarlaPointCloudPublisher(const CarlaPointCloudPublisher &)=delete
carla::ros2::CarlaPointCloudPublisher::Publish
bool Publish() override
Definition
CarlaPointCloudPublisher.cpp:73
carla::ros2::CarlaPointCloudPublisher::CarlaPointCloudPublisher
CarlaPointCloudPublisher(CarlaPointCloudPublisher &&) noexcept=default
carla::ros2::CarlaPointCloudPublisher::_impl
std::shared_ptr< PublisherImpl< CarlaPointCloudMsgTraits > > _impl
Definition
CarlaPointCloudPublisher.h:78
carla::ros2::CarlaPointCloudPublisher::~CarlaPointCloudPublisher
~CarlaPointCloudPublisher() override
carla::ros2::PublisherImpl
Definition
PublisherImpl.h:28
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::CarlaPointCloudMsgTraits
Definition
CarlaPointCloudPublisher.cpp:21
carla::ros2::PointFieldDescriptor
Definition
PointCloudFieldsLayout.h:33
Generated by
1.18.0