CARLA
 
载入中...
搜索中...
未找到
LightManager.h
浏览该文件的文档.
1// Copyright (c) 2020 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 <mutex>
10#include <vector>
11#include <unordered_map>
12#include <unordered_set>
13
14#include "carla/Memory.h"
15#include "carla/NonCopyable.h"
16
18#include "carla/client/Light.h"
21
22namespace carla {
23namespace client {
24
26 : public EnableSharedFromThis<LightManager> {
27
29
30public:
31
33
35
45
47
48 std::vector<Light> GetAllLights(LightGroup type = LightGroup::None) const;
49 // TODO: std::vector<Light> GetAllLightsInRoad(RoadId id, LightGroup type = LightGroup::None);
50 // TODO: std::vector<Light> GetAllLightsInDistance(Vec3 origin, float distance, LightGroup type = Light::LightType::None);
51
52 void TurnOn(std::vector<Light>& lights);
53 void TurnOff(std::vector<Light>& lights);
54 void SetActive(std::vector<Light>& lights, std::vector<bool>& active);
55 std::vector<bool> IsActive(std::vector<Light>& lights) const;
56 std::vector<Light> GetTurnedOnLights(LightGroup type = LightGroup::None) const;
57 std::vector<Light> GetTurnedOffLights(LightGroup type = LightGroup::None) const;
58
59 void SetColor(std::vector<Light>& lights, Color color);
60 void SetColor(std::vector<Light>& lights, std::vector<Color>& colors);
61 std::vector<Color> GetColor(std::vector<Light>& lights) const;
62
63 void SetIntensity(std::vector<Light>& lights, float intensity);
64 void SetIntensity(std::vector<Light>& lights, std::vector<float>& intensities);
65 std::vector<float> GetIntensity(std::vector<Light>& lights) const;
66
67 void SetLightGroup(std::vector<Light>& lights, LightGroup group);
68 void SetLightGroup(std::vector<Light>& lights, std::vector<LightGroup>& groups);
69 std::vector<LightGroup> GetLightGroup(std::vector<Light>& lights) const;
70
71 void SetLightState(std::vector<Light>& lights, LightState state);
72 void SetLightState(std::vector<Light>& lights, std::vector<LightState>& states);
73 std::vector<LightState> GetLightState(std::vector<Light>& lights) const;
74
75 Color GetColor(LightId id) const;
76 float GetIntensity(LightId id) const;
79 bool IsActive(LightId id) const;
80
81 void SetActive(LightId id, bool active);
82 void SetColor(LightId id, Color color);
83 void SetIntensity(LightId id, float intensity);
84 void SetLightState(LightId id, const LightState& new_state);
85 void SetLightStateNoLock(LightId id, const LightState& new_state);
86 void SetLightGroup(LightId id, LightGroup group);
87
88 void SetDayNightCycle(const bool active);
89
90private:
91
92 const LightState& RetrieveLightState(LightId id) const;
93
95 void UpdateServerLightsState(bool discard_client = false);
96 void ApplyChanges();
97
98 std::unordered_map<LightId, LightState> _lights_state;
99 std::unordered_map<LightId, LightState> _lights_changes;
100 std::unordered_map<LightId, Light> _lights;
101
103
104 std::mutex _mutex;
105
109 bool _dirty = false;
110};
111
112} // namespace client
113} // namespace carla
std::vector< Light > GetTurnedOffLights(LightGroup type=LightGroup::None) const
LightManager(const LightManager &other)
std::vector< Light > GetTurnedOnLights(LightGroup type=LightGroup::None) const
std::vector< LightGroup > GetLightGroup(std::vector< Light > &lights) const
void SetIntensity(std::vector< Light > &lights, float intensity)
std::vector< bool > IsActive(std::vector< Light > &lights) const
std::vector< Color > GetColor(std::vector< Light > &lights) const
const LightState & RetrieveLightState(LightId id) const
void SetLightState(std::vector< Light > &lights, LightState state)
std::unordered_map< LightId, LightState > _lights_changes
void TurnOff(std::vector< Light > &lights)
void SetLightStateNoLock(LightId id, const LightState &new_state)
detail::WeakEpisodeProxy _episode
void SetColor(std::vector< Light > &lights, Color color)
void TurnOn(std::vector< Light > &lights)
std::vector< float > GetIntensity(std::vector< Light > &lights) const
void SetDayNightCycle(const bool active)
std::unordered_map< LightId, LightState > _lights_state
void SetLightGroup(std::vector< Light > &lights, LightGroup group)
void SetEpisode(detail::WeakEpisodeProxy episode)
void SetActive(std::vector< Light > &lights, std::vector< bool > &active)
std::unordered_map< LightId, Light > _lights
void UpdateServerLightsState(bool discard_client=false)
std::vector< LightState > GetLightState(std::vector< Light > &lights) const
std::vector< Light > GetAllLights(LightGroup type=LightGroup::None) const
EpisodeProxyImpl< EpisodeProxyPointerType::Weak > WeakEpisodeProxy
This file contains definitions of common data structures used in traffic manager.
Definition Carla.cpp:133