CARLA
 
载入中...
搜索中...
未找到
Light.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 "carla/Memory.h" // 包含内存管理相关的头文件
10
11
12#include "carla/client/LightState.h" // 包含光照状态相关的客户端头文件
13#include "carla/geom/Location.h" // 包含位置几何信息的头文件
14#include "carla/geom/Rotation.h" // 包含旋转几何信息的头文件
15#include "carla/rpc/LightState.h" // 包含远程过程调用的光照状态定义头文件
16
17
18namespace carla { // 开始 carla 命名空间
19namespace client { // 开始 client 命名空间
20
21class LightManager; // 前向声明 LightManager 类
22
23class Light { // 定义 Light 类
24
25
26 using LightGroup = rpc::LightState::LightGroup; // 定义 LightGroup 类型别名
27
28public:
29
30 Light() {} // 默认构造函数
31
32 Color GetColor() const; // 获取颜色的成员函数
33
34 LightId GetId() const { // 获取光源 ID 的成员函数
35 return _id; // 返回光源的 ID
36 }
37
38 float GetIntensity() const; // 获取光强度的成员函数
39
40 const geom::Location GetLocation() const { // 获取位置的成员函数
41 return _location; // 返回光源的位置
42 }
43
44 LightGroup GetLightGroup() const; // 获取光源组的成员函数
45
46 LightState GetLightState() const; // 获取光照状态的成员函数
47
48
49 bool IsOn() const; // 检查光源是否开启的成员函数
50
51 bool IsOff() const; // 检查光源是否关闭的成员函数
52
53 void SetColor(Color color); // 设置光源颜色的成员函数
54
55 void SetIntensity(float intensity); // 设置光源强度的成员函数
56
57 void SetLightGroup(LightGroup group); // 设置光源组的成员函数
58
59 void SetLightState(const LightState& state); // 设置光照状态的成员函数
60
61 void TurnOn(); // 开启光源的成员函数
62
63
64 void TurnOff(); // 关闭光源的成员函数
65
66private: // 私有成员
67
68
69 friend class LightManager; // 声明 LightManager 为友元类,可以访问私有成员
70
71 Light(WeakPtr<LightManager> light_manager, // 构造函数,接受弱指针的 LightManager
72 geom::Location location, // 位置参数
73 LightId id) // 光源 ID 参数
74 : _light_manager(light_manager), // 初始化光源管理器
75 _location (location), // 初始化位置
76 _id (id) {} // 初始化光源 ID
77
78 WeakPtr<LightManager> _light_manager; // 存储光源管理器的弱指针
79
80 geom::Location _location; // 存储光源位置
81
82 LightId _id; // 存储光源 ID
83
84};
85
86} // namespace client
87} // namespace carla
void SetLightState(const LightState &state)
Definition Light.cpp:77
LightGroup GetLightGroup() const
Definition Light.cpp:33
Color GetColor() const
Definition Light.cpp:18
LightState GetLightState() const
Definition Light.cpp:39
geom::Location _location
Definition Light.h:80
bool IsOn() const
Definition Light.cpp:45
float GetIntensity() const
Definition Light.cpp:27
bool IsOff() const
Definition Light.cpp:52
void SetColor(Color color)
Definition Light.cpp:59
void SetIntensity(float intensity)
Definition Light.cpp:65
WeakPtr< LightManager > _light_manager
Definition Light.h:78
Light(WeakPtr< LightManager > light_manager, geom::Location location, LightId id)
Definition Light.h:71
LightId GetId() const
Definition Light.h:34
const geom::Location GetLocation() const
Definition Light.h:40
void SetLightGroup(LightGroup group)
Definition Light.cpp:71
uint32_t LightId
定义灯光ID的类型,使用uint32_t表示。
CARLA模拟器的主命名空间。
Definition Carla.cpp:139
boost::weak_ptr< T > WeakPtr
类似于SharedPtr,但提供对boost::weak_ptr的别名,用于弱引用
Definition Memory.h:22
包含CARLA客户端相关类和函数的命名空间。
表示车辆灯光状态的结构体。