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 
11 namespace carla {
12 namespace client {
13 
14  class ServerSideSensor final : public Sensor {
15  public:
16 
17  using Sensor::Sensor;
18 
20 
21  /// Register a @a callback to be executed each time a new measurement is
22  /// received.
23  ///
24  /// @warning Calling this function on a sensor that is already listening
25  /// steals the data stream from the previously set callback. Note that
26  /// several instances of Sensor (even in different processes) may point to
27  /// the same sensor in the simulator.
28  void Listen(CallbackFunctionType callback) override;
29 
30  /// Stop listening for new measurements.
31  void Stop() override;
32 
33  /// Return whether this Sensor instance is currently listening to the
34  /// associated sensor in the simulator.
35  bool IsListening() const override {
36  return _is_listening;
37  }
38 
39  /// @copydoc Actor::Destroy()
40  ///
41  /// Additionally stop listening.
42  bool Destroy() override;
43 
44  private:
45 
46  bool _is_listening = false;
47  };
48 
49 } // namespace client
50 } // 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:99
bool IsListening() const override
Return whether this Sensor instance is currently listening to the associated sensor in the simulator...
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 Stop() override
Stop listening for new measurements.