CARLA
TrafficLight.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 
11 #include "carla/client/Waypoint.h"
12 #include "carla/client/Map.h"
13 #include "carla/geom/BoundingBox.h"
14 
15 namespace carla {
16 namespace client {
17 
18  class TrafficLight : public TrafficSign {
19 
20  public:
21 
22  explicit TrafficLight(ActorInitializer init) : TrafficSign(std::move(init)) {}
23 
24  void SetState(rpc::TrafficLightState state);
25 
26  /// Return the current state of the traffic light.
27  ///
28  /// @note This function does not call the simulator, it returns the data
29  /// received in the last tick.
31 
32  void SetGreenTime(float green_time);
33 
34  /// @note This function does not call the simulator, it returns the data
35  /// received in the last tick.
36  float GetGreenTime() const;
37 
38  void SetYellowTime(float yellow_time);
39 
40  /// @note This function does not call the simulator, it returns the data
41  /// received in the last tick.
42  float GetYellowTime() const;
43 
44  void SetRedTime(float red_time);
45 
46  /// @note This function does not call the simulator, it returns the data
47  /// received in the last tick.
48  float GetRedTime() const;
49 
50  /// @note This function does not call the simulator, it returns the data
51  /// received in the last tick.
52  float GetElapsedTime() const;
53 
54  void Freeze(bool freeze);
55 
56  /// @note This function does not call the simulator, it returns the data
57  /// received in the last tick.
58  bool IsFrozen() const;
59 
60  /// Returns the index of the pole in the traffic light group
61  uint32_t GetPoleIndex();
62 
63  /// Return all traffic lights in the group this one belongs to.
64  ///
65  /// @note This function calls the simulator
66  std::vector<SharedPtr<TrafficLight>> GetGroupTrafficLights();
67 
68  // resets the timers and states of all groups
69  void ResetGroup();
70 
71  std::vector<SharedPtr<Waypoint>> GetAffectedLaneWaypoints() const;
72 
73  std::vector<geom::BoundingBox> GetLightBoxes() const;
74 
76 
77  std::vector<SharedPtr<Waypoint>> GetStopWaypoints() const;
78 
79  };
80 
81 } // namespace client
82 } // namespace carla
std::string SignId
Definition: RoadTypes.h:25
void SetGreenTime(float green_time)
std::vector< SharedPtr< TrafficLight > > GetGroupTrafficLights()
Return all traffic lights in the group this one belongs to.
std::vector< SharedPtr< Waypoint > > GetAffectedLaneWaypoints() const
This file contains definitions of common data structures used in traffic manager. ...
Definition: Carla.cpp:133
std::vector< SharedPtr< Waypoint > > GetStopWaypoints() const
void SetRedTime(float red_time)
Used to initialize Actor classes.
void SetState(rpc::TrafficLightState state)
rpc::TrafficLightState GetState() const
Return the current state of the traffic light.
void Freeze(bool freeze)
void SetYellowTime(float yellow_time)
TrafficLight(ActorInitializer init)
Definition: TrafficLight.h:22
std::vector< geom::BoundingBox > GetLightBoxes() const
uint32_t GetPoleIndex()
Returns the index of the pole in the traffic light group.
road::SignId GetOpenDRIVEID() const