CARLA
ServerSideSensor.h
Go to the documentation of this file.
1 // Copyright (c) 2017 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/client/Sensor.h"
10 #include <bitset>
11 
12 namespace carla {
13 namespace client {
14 
15  class ServerSideSensor final : public Sensor {
16  public:
17 
18  using Sensor::Sensor;
19 
21 
22  /// Register a @a callback to be executed each time a new measurement is
23  /// received.
24  ///
25  /// @warning Calling this function on a sensor that is already listening
26  /// steals the data stream from the previously set callback. Note that
27  /// several instances of Sensor (even in different processes) may point to
28  /// the same sensor in the simulator.
29  void Listen(CallbackFunctionType callback) override;
30 
31  /// Stop listening for new measurements.
32  void Stop() override;
33 
34  /// Return whether this Sensor instance is currently listening to the
35  /// associated sensor in the simulator.
36  bool IsListening() const override {
37  return listening_mask.test(0);
38  }
39 
40  /// Listen fr
41  void ListenToGBuffer(uint32_t GBufferId, CallbackFunctionType callback);
42 
43  /// Stop listening for a specific gbuffer stream.
44  void StopGBuffer(uint32_t GBufferId);
45 
46  inline bool IsListeningGBuffer(uint32_t id) const {
47  return listening_mask.test(id + 1);
48  }
49 
50  /// Enable this sensor for ROS2 publishing
51  void EnableForROS();
52 
53  /// Disable this sensor for ROS2 publishing
54  void DisableForROS();
55 
56  /// Return if the sensor is publishing for ROS2
57  bool IsEnabledForROS();
58 
59  /// @copydoc Actor::Destroy()
60  ///
61  /// Additionally stop listening.
62  bool Destroy() override;
63 
64  private:
65 
66  std::bitset<16> listening_mask;
67  };
68 
69 } // namespace client
70 } // namespace carla
void Listen(CallbackFunctionType callback) override
Register a callback to be executed each time a new measurement is received.
This file contains definitions of common data structures used in traffic manager. ...
Definition: Carla.cpp:133
void EnableForROS()
Enable this sensor for ROS2 publishing.
void ListenToGBuffer(uint32_t GBufferId, CallbackFunctionType callback)
Listen fr.
bool IsListening() const override
Return whether this Sensor instance is currently listening to the associated sensor in the simulator...
bool IsListeningGBuffer(uint32_t id) const
void DisableForROS()
Disable this sensor for ROS2 publishing.
bool IsEnabledForROS()
Return if the sensor is publishing for ROS2.
bool Destroy() override
Tell the simulator to destroy this Actor, and return whether the actor was successfully destroyed...
std::function< void(SharedPtr< sensor::SensorData >)> CallbackFunctionType
void StopGBuffer(uint32_t GBufferId)
Stop listening for a specific gbuffer stream.
void Stop() override
Stop listening for new measurements.