CARLA
Loading...
Searching...
No Matches
CarlaOpticalFlowCameraPublisher.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 <string>
13#include <utility>
14#include <vector>
15
16namespace carla {
17namespace ros2 {
18
19// Non-alias subclass: the UE optical flow sensor produces a height*width buffer
20// of (vx, vy) float pairs (8 bytes per pixel) which CARLA encodes on the wire
21// as a 4-channel BGRA uint8 image via the HSV colour wheel. The conversion is
22// the same one that ue5-dev shipped before this refactor; it now lives in
23// OpticalFlowEncoding.h so the math is unit-testable without FastDDS, and the
24// publisher only has to call ComputeImage(...) to plug it into the unified
25// base.
27public:
28 CarlaOpticalFlowCameraPublisher(std::string base_topic_name, std::string frame_id)
29 : CarlaCameraPublisher(std::move(base_topic_name), std::move(frame_id)) {}
30
31protected:
32 [[nodiscard]] uint8_t GetChannels() const override { return 4; }
33 [[nodiscard]] std::string GetEncoding() const override { return "bgra8"; }
34 [[nodiscard]] std::vector<uint8_t> ComputeImage(
35 uint32_t height, uint32_t width, const uint8_t *data) const override;
36};
37
38} // namespace ros2
39} // namespace carla
CarlaOpticalFlowCameraPublisher(std::string base_topic_name, std::string frame_id)
std::vector< uint8_t > ComputeImage(uint32_t height, uint32_t width, const uint8_t *data) const override
This file contains definitions of common data structures used in traffic manager.