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