CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
LibCarla
source
carla
ros2
publishers
CarlaDVSCameraPublisher.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/CarlaCameraPublisher.h
"
11
#include "
carla/ros2/publishers/CarlaPointCloudPublisher.h
"
12
13
#include <cstdint>
14
#include <memory>
15
#include <string>
16
#include <vector>
17
18
namespace
carla
{
19
namespace
ros2
{
20
21
// Image-side companion publisher: writes the dense visualisation of the DVS
22
// event stream as a 3-channel BGR sensor_msgs/Image to the existing wire
23
// format ROS 2 subscribers depend on. The encoding (positive polarity =
24
// red, negative polarity = blue) lives in DvsEventEncoding.h so a GTest
25
// pins it without instantiating FastDDS.
26
class
CarlaDVSImagePublisher
final :
public
CarlaCameraPublisher
{
27
public
:
28
CarlaDVSImagePublisher
(std::string base_topic_name, std::string frame_id)
29
:
CarlaCameraPublisher
(
std
::move(base_topic_name),
std
::move(frame_id)) {}
30
31
// Encode-from-events overload: walks the DVSEvent stream and writes the
32
// dense image via the seam.
33
bool
WriteImageFromEvents
(
34
std::int32_t seconds,
35
std::uint32_t nanoseconds,
36
std::uint32_t height,
37
std::uint32_t width,
38
const
std::uint8_t *events,
39
std::size_t event_count,
40
std::size_t event_stride);
41
42
protected
:
43
[[nodiscard]] std::uint8_t
GetChannels
()
const override
{
return
3u; }
44
[[nodiscard]] std::string
GetEncoding
()
const override
{
return
"bgr8"
; }
45
};
46
47
// Point-cloud-side companion publisher: emits the raw DVS events as a
48
// sensor_msgs/PointCloud2 with the (x, y, t, pol) field layout shared with
49
// PR-3's pre-existing ue5-dev wire format.
50
class
CarlaDVSPointCloudPublisher
final :
public
CarlaPointCloudPublisher
{
51
public
:
52
CarlaDVSPointCloudPublisher
(std::string base_topic_name, std::string frame_id)
53
:
CarlaPointCloudPublisher
(
std
::move(base_topic_name),
std
::move(frame_id)) {}
54
55
private
:
56
[[nodiscard]] std::size_t
GetPointSize
()
const override
;
57
[[nodiscard]]
const
PointFieldDescriptor
*
GetFieldDescriptors
()
const override
;
58
[[nodiscard]] std::size_t
GetFieldDescriptorCount
()
const override
;
59
[[nodiscard]] std::vector<std::uint8_t>
ComputePointCloud
(
60
std::uint32_t height, std::uint32_t width,
const
std::uint8_t *data)
const override
;
61
};
62
63
// Public composite. Each tick the simulator hands the raw DVS event buffer
64
// once; the composite fans the data out to the image-side (encoded BGR
65
// visualisation) and the point-cloud-side (raw events) publishers.
66
class
CarlaDVSCameraPublisher
:
public
BasePublisher
{
67
public
:
68
CarlaDVSCameraPublisher
(std::string base_topic_name, std::string frame_id);
69
~CarlaDVSCameraPublisher
()
override
;
70
71
CarlaDVSCameraPublisher
(
const
CarlaDVSCameraPublisher
&) =
delete
;
72
CarlaDVSCameraPublisher
&
operator=
(
const
CarlaDVSCameraPublisher
&) =
delete
;
73
CarlaDVSCameraPublisher
(
CarlaDVSCameraPublisher
&&) noexcept = default;
74
CarlaDVSCameraPublisher
&operator=(
CarlaDVSCameraPublisher
&&) noexcept = default;
75
76
bool
Publish
() override;
77
78
bool
WriteCameraInfo
(
79
std
::int32_t seconds,
80
std
::uint32_t nanoseconds,
81
std
::uint32_t x_offset,
82
std
::uint32_t y_offset,
83
std
::uint32_t height,
84
std
::uint32_t width,
85
float
fov,
86
bool
do_rectify);
87
88
bool
WriteImage
(
89
std
::int32_t seconds,
90
std
::uint32_t nanoseconds,
91
std
::uint32_t height,
92
std
::uint32_t width,
93
std
::
size_t
event_count,
94
const
std
::uint8_t *events,
95
std
::
size_t
event_stride);
96
97
bool
WritePointCloud
(
98
std
::int32_t seconds,
99
std
::uint32_t nanoseconds,
100
std
::uint32_t height,
101
std
::uint32_t width,
102
const
std
::uint8_t *data);
103
104
private:
105
std
::shared_ptr<
CarlaDVSImagePublisher
>
_image_pub
;
106
std
::shared_ptr<
CarlaDVSPointCloudPublisher
>
_point_cloud_pub
;
107
};
108
109
}
// namespace ros2
110
}
// namespace carla
BasePublisher.h
CarlaCameraPublisher.h
CarlaPointCloudPublisher.h
carla::ros2::BasePublisher::BasePublisher
BasePublisher()=default
carla::ros2::CarlaCameraPublisher::CarlaCameraPublisher
CarlaCameraPublisher(std::string base_topic_name, std::string frame_id)
Definition
CarlaCameraPublisher.cpp:29
carla::ros2::CarlaDVSCameraPublisher::~CarlaDVSCameraPublisher
~CarlaDVSCameraPublisher() override
carla::ros2::CarlaDVSCameraPublisher::_point_cloud_pub
std::shared_ptr< CarlaDVSPointCloudPublisher > _point_cloud_pub
Definition
CarlaDVSCameraPublisher.h:106
carla::ros2::CarlaDVSCameraPublisher::CarlaDVSCameraPublisher
CarlaDVSCameraPublisher(std::string base_topic_name, std::string frame_id)
Definition
CarlaDVSCameraPublisher.cpp:57
carla::ros2::CarlaDVSCameraPublisher::WriteCameraInfo
bool WriteCameraInfo(std::int32_t seconds, std::uint32_t nanoseconds, std::uint32_t x_offset, std::uint32_t y_offset, std::uint32_t height, std::uint32_t width, float fov, bool do_rectify)
Definition
CarlaDVSCameraPublisher.cpp:72
carla::ros2::CarlaDVSCameraPublisher::WriteImage
bool WriteImage(std::int32_t seconds, std::uint32_t nanoseconds, std::uint32_t height, std::uint32_t width, std::size_t event_count, const std::uint8_t *events, std::size_t event_stride)
Definition
CarlaDVSCameraPublisher.cpp:85
carla::ros2::CarlaDVSCameraPublisher::CarlaDVSCameraPublisher
CarlaDVSCameraPublisher(CarlaDVSCameraPublisher &&) noexcept=default
carla::ros2::CarlaDVSCameraPublisher::Publish
bool Publish() override
Definition
CarlaDVSCameraPublisher.cpp:66
carla::ros2::CarlaDVSCameraPublisher::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
CarlaDVSCameraPublisher.cpp:97
carla::ros2::CarlaDVSCameraPublisher::_image_pub
std::shared_ptr< CarlaDVSImagePublisher > _image_pub
Definition
CarlaDVSCameraPublisher.h:105
carla::ros2::CarlaDVSCameraPublisher::CarlaDVSCameraPublisher
CarlaDVSCameraPublisher(const CarlaDVSCameraPublisher &)=delete
carla::ros2::CarlaDVSCameraPublisher::operator=
CarlaDVSCameraPublisher & operator=(const CarlaDVSCameraPublisher &)=delete
carla::ros2::CarlaDVSImagePublisher
Definition
CarlaDVSCameraPublisher.h:26
carla::ros2::CarlaDVSImagePublisher::GetEncoding
std::string GetEncoding() const override
Definition
CarlaDVSCameraPublisher.h:44
carla::ros2::CarlaDVSImagePublisher::GetChannels
std::uint8_t GetChannels() const override
Definition
CarlaDVSCameraPublisher.h:43
carla::ros2::CarlaDVSImagePublisher::CarlaDVSImagePublisher
CarlaDVSImagePublisher(std::string base_topic_name, std::string frame_id)
Definition
CarlaDVSCameraPublisher.h:28
carla::ros2::CarlaDVSImagePublisher::WriteImageFromEvents
bool WriteImageFromEvents(std::int32_t seconds, std::uint32_t nanoseconds, std::uint32_t height, std::uint32_t width, const std::uint8_t *events, std::size_t event_count, std::size_t event_stride)
Definition
CarlaDVSCameraPublisher.cpp:18
carla::ros2::CarlaDVSPointCloudPublisher
Definition
CarlaDVSCameraPublisher.h:50
carla::ros2::CarlaDVSPointCloudPublisher::ComputePointCloud
std::vector< std::uint8_t > ComputePointCloud(std::uint32_t height, std::uint32_t width, const std::uint8_t *data) const override
Definition
CarlaDVSCameraPublisher.cpp:46
carla::ros2::CarlaDVSPointCloudPublisher::CarlaDVSPointCloudPublisher
CarlaDVSPointCloudPublisher(std::string base_topic_name, std::string frame_id)
Definition
CarlaDVSCameraPublisher.h:52
carla::ros2::CarlaDVSPointCloudPublisher::GetFieldDescriptors
const PointFieldDescriptor * GetFieldDescriptors() const override
Definition
CarlaDVSCameraPublisher.cpp:38
carla::ros2::CarlaDVSPointCloudPublisher::GetPointSize
std::size_t GetPointSize() const override
Definition
CarlaDVSCameraPublisher.cpp:34
carla::ros2::CarlaDVSPointCloudPublisher::GetFieldDescriptorCount
std::size_t GetFieldDescriptorCount() const override
Definition
CarlaDVSCameraPublisher.cpp:42
carla::ros2::CarlaPointCloudPublisher::CarlaPointCloudPublisher
CarlaPointCloudPublisher(std::string base_topic_name, std::string frame_id, bool exact_topic=false)
Definition
CarlaPointCloudPublisher.cpp:62
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