CARLA
Light.cpp
Go to the documentation of this file.
1 
2 // Copyright (c) 2020 Computer Vision Center (CVC) at the Universitat Autonoma
3 // de Barcelona (UAB).
4 //
5 // This work is licensed under the terms of the MIT license.
6 // For a copy, see <https://opensource.org/licenses/MIT>.
7 
8 #include "carla/client/Light.h"
10 
11 #include <assert.h>
12 
13 namespace carla {
14 namespace client {
15 
17 
19  auto light_manager = _light_manager.lock();
20  assert(light_manager && "No light_manager");
21  return light_manager->GetColor(_id);
22 }
23 
24 float Light::GetIntensity() const {
25  auto light_manager = _light_manager.lock();
26  assert(light_manager && "No light_manager");
27  return light_manager->GetIntensity(_id);
28 }
29 
31  auto light_manager = _light_manager.lock();
32  assert(light_manager && "No light_manager");
33  return light_manager->GetLightGroup(_id);
34 }
35 
37  auto light_manager = _light_manager.lock();
38  assert(light_manager && "No light_manager");
39  return light_manager->GetLightState(_id);
40 }
41 
42 bool Light::IsOn() const {
43  auto light_manager = _light_manager.lock();
44  assert(light_manager && "No light_manager");
45  return light_manager->IsActive(_id) == true;
46 }
47 
48 bool Light::IsOff() const {
49  auto light_manager = _light_manager.lock();
50  assert(light_manager && "No light_manager");
51  return light_manager->IsActive(_id) == false;
52 }
53 
54 void Light::SetColor(Color color) {
55  auto light_manager = _light_manager.lock();
56  assert(light_manager && "No light_manager");
57  light_manager->SetColor(_id, color);
58 }
59 
60 void Light::SetIntensity(float intensity) {
61  auto light_manager = _light_manager.lock();
62  assert(light_manager && "No light_manager");
63  light_manager->SetIntensity(_id, intensity);
64 }
65 
67  auto light_manager = _light_manager.lock();
68  assert(light_manager && "No light_manager");
69  light_manager->SetLightGroup(_id, group);
70 }
71 
72 void Light::SetLightState(const LightState& state) {
73  auto light_manager = _light_manager.lock();
74  assert(light_manager && "No light_manager");
75  light_manager->SetLightState(_id, state);
76 }
77 
78 void Light::TurnOn() {
79  auto light_manager = _light_manager.lock();
80  assert(light_manager && "No light_manager");
81  light_manager->SetActive(_id, true);
82 }
83 
85  auto light_manager = _light_manager.lock();
86  assert(light_manager && "No light_manager");
87  light_manager->SetActive(_id, false);
88 }
89 
90 
91 } // namespace client
92 } // namespace carla
bool IsOff() const
Definition: Light.cpp:48
LightState GetLightState() const
Definition: Light.cpp:36
void SetLightGroup(LightGroup group)
Definition: Light.cpp:66
void SetLightState(const LightState &state)
Definition: Light.cpp:72
void SetColor(Color color)
Definition: Light.cpp:54
A 32-bit BGRA color.
This file contains definitions of common data structures used in traffic manager. ...
Definition: Carla.cpp:133
void SetIntensity(float intensity)
Definition: Light.cpp:60
bool IsOn() const
Definition: Light.cpp:42
WeakPtr< LightManager > _light_manager
Definition: Light.h:72
float GetIntensity() const
Definition: Light.cpp:24
Color GetColor() const
Definition: Light.cpp:18
LightGroup GetLightGroup() const
Definition: Light.cpp:30