CARLA
LibCarla/source/carla/client/LaneInvasionSensor.h
Go to the documentation of this file.
1 // Copyright (c) 2019 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 <atomic>
12 
13 namespace carla {
14 namespace client {
15 
16  class Map;
17  class Vehicle;
18 
19  class LaneInvasionSensor final : public ClientSideSensor {
20  public:
21 
22  using ClientSideSensor::ClientSideSensor;
23 
25 
26  /// Register a @a callback to be executed each time a new measurement is
27  /// received.
28  ///
29  /// @warning Calling this function on a sensor that is already listening
30  /// steals the data stream from the previously set callback. Note that
31  /// several instances of Sensor (even in different processes) may point to
32  /// the same sensor in the simulator.
33  void Listen(CallbackFunctionType callback) override;
34 
35  /// Stop listening for new measurements.
36  void Stop() override;
37 
38  /// Return whether this Sensor instance is currently listening to the
39  /// associated sensor in the simulator.
40  bool IsListening() const override {
41  return _callback_id != 0u;
42  }
43 
44  private:
45 
46  std::atomic_size_t _callback_id{0u};
47  };
48 
49 } // namespace client
50 } // namespace carla
This file contains definitions of common data structures used in traffic manager. ...
Definition: Carla.cpp:133
bool IsListening() const override
Return whether this Sensor instance is currently listening to the associated sensor in the simulator...
void Stop() override
Stop listening for new measurements.
std::function< void(SharedPtr< sensor::SensorData >)> CallbackFunctionType
void Listen(CallbackFunctionType callback) override
Register a callback to be executed each time a new measurement is received.