CARLA
Loading...
Searching...
No Matches
ServerSideSensor.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
11
12#include <bitset>
13
14namespace carla {
15namespace client {
16
17 class ServerSideSensor final : public Sensor {
18 public:
19
20 using Sensor::Sensor;
21
23
24 /// Register a @a callback to be executed each time a new measurement is
25 /// received.
26 ///
27 /// @warning Calling this function on a sensor that is already listening
28 /// steals the data stream from the previously set callback. Note that
29 /// several instances of Sensor (even in different processes) may point to
30 /// the same sensor in the simulator.
31 void Listen(CallbackFunctionType callback) override;
32
33 /// Stop listening for new measurements.
34 void Stop() override;
35
36 /// Return whether this Sensor instance is currently listening to the
37 /// associated sensor in the simulator.
38 bool IsListening() const override {
39 return listening_mask.test(0);
40 }
41
42 /// Listen fr
43 void ListenToGBuffer(uint32_t GBufferId, CallbackFunctionType callback);
44
45 /// Stop listening for a specific gbuffer stream.
46 void StopGBuffer(uint32_t GBufferId);
47
48 inline bool IsListeningGBuffer(uint32_t id) const {
49 return listening_mask.test(id + 1);
50 }
51
52 /// Enable this sensor for ROS2 publishing
53 void EnableForROS();
54
55 /// Disable this sensor for ROS2 publishing
56 void DisableForROS();
57
58 /// Return if the sensor is publishing for ROS2
59 bool IsEnabledForROS();
60
61 /// Send a binary message through this sensor. Only supported on the custom
62 /// V2X sensor (sensor.other.v2x_custom).
63 void Send(const rpc::CustomV2XBytes &data);
64
65 /// @copydoc Actor::Destroy()
66 ///
67 /// Additionally stop listening.
68 bool Destroy() override;
69
70 private:
71
72 std::bitset<16> listening_mask;
73 };
74
75} // namespace client
76} // namespace carla
std::function< void(SharedPtr< sensor::SensorData >)> CallbackFunctionType
bool IsEnabledForROS()
Return if the sensor is publishing for ROS2.
bool IsListeningGBuffer(uint32_t id) const
void Send(const rpc::CustomV2XBytes &data)
Send a binary message through this sensor.
void EnableForROS()
Enable this sensor for ROS2 publishing.
void ListenToGBuffer(uint32_t GBufferId, CallbackFunctionType callback)
Listen fr.
void Stop() override
Stop listening for new measurements.
void DisableForROS()
Disable this sensor for ROS2 publishing.
bool IsListening() const override
Return whether this Sensor instance is currently listening to the associated sensor in the simulator.
void Listen(CallbackFunctionType callback) override
Register a callback to be executed each time a new measurement is received.
void StopGBuffer(uint32_t GBufferId)
Stop listening for a specific gbuffer stream.
Fixed-size binary payload carried by the custom V2X sensor (sensor.other.v2x_custom).
This file contains definitions of common data structures used in traffic manager.