CARLA
 
载入中...
搜索中...
未找到
DebugHelper.cpp
浏览该文件的文档.
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#include "carla/client/DebugHelper.h" // 引入DebugHelper头文件
8
9#include "carla/client/detail/Simulator.h" // 引入Simulator的细节实现
10#include "carla/rpc/DebugShape.h" // 引入DebugShape的RPC接口
11// 命名空间和别名
12namespace carla {
13namespace client {
14// 使用rpc::DebugShape作为Shape的别名,简化代码书写
15 using Shape = rpc::DebugShape; // 使用rpc::DebugShape作为Shape的别名
16
17 // 绘制形状的模板函数
18// 绘制不同类型的形状
19 template <typename T>
20 static void DrawShape(
21 detail::EpisodeProxy &episode, // 细节:当前剧集代理
22// 用于锁定和绘制形状
23 const T &primitive, // 形状的基本元素
24//表示形状的颜色
25 rpc::Color color, // 颜色
26// 表示形状的生存时间
27 float life_time, // 生存时间
28 bool persistent_lines) { // 是否为持久线
29 const Shape shape{primitive, color, life_time, persistent_lines}; // 创建形状对象
30 episode.Lock()->DrawDebugShape(shape); // 锁定剧集并绘制调试形状
31 }
32
33 // 绘制点
35 const geom::Location &location, // 点的位置
36 float size, // 点的大小
37 sensor::data::Color color, // 点的颜色
38 float life_time, // 生存时间
39 bool persistent_lines) { // 是否为持久线
40 // 创造一个点的对象
41 Shape::Point point{location, size}; // 创建点形状
42 //调用模版函数
43 DrawShape(_episode, point, color, life_time, persistent_lines); // 调用绘制形状
44 }
45
46 // 绘制HUD点
48 const geom::Location &location, // 点的位置
49 float size, // 点的大小
50 sensor::data::Color color, // 点的颜色
51 float life_time, // 生存时间
52 bool persistent_lines) { // 是否为持久线
53 Shape::HUDPoint point{location, size}; // 创建HUD点形状
54 DrawShape(_episode, point, color, life_time, persistent_lines); // 调用绘制形状
55 }
56
57 // 绘制线
59 const geom::Location &begin, // 线的起点
60 const geom::Location &end, // 线的终点
61 float thickness, // 线的粗细
62 sensor::data::Color color, // 线的颜色
63 float life_time, // 生存时间
64 bool persistent_lines) { // 是否为持久线
65 Shape::Line line{begin, end, thickness}; // 创建线形状
66 DrawShape(_episode, line, color, life_time, persistent_lines); // 调用绘制形状
67 }
68
69 // 绘制HUD线
71 const geom::Location &begin, // 线的起点
72 const geom::Location &end, // 线的终点
73 float thickness, // 线的粗细
74 Color color, // 线的颜色
75 float life_time, // 生存时间
76 bool persistent_lines) { // 是否为持久线
77 Shape::HUDLine line{begin, end, thickness}; // 创建HUD线形状
78 DrawShape(_episode, line, color, life_time, persistent_lines); // 调用绘制形状
79 }
80
81 // 绘制箭头
83 const geom::Location &begin, // 箭头的起点
84 const geom::Location &end, // 箭头的终点
85 float thickness, // 箭头的粗细
86 float arrow_size, // 箭头的大小
87 sensor::data::Color color, // 箭头的颜色
88 float life_time, // 生存时间
89 bool persistent_lines) { // 是否为持久线
90 Shape::Line line{begin, end, thickness}; // 创建箭头的线形状
91 Shape::Arrow arrow{line, arrow_size}; // 创建箭头形状
92 DrawShape(_episode, arrow, color, life_time, persistent_lines); // 调用绘制形状
93 }
94
95 // 绘制HUD箭头
97 const geom::Location &begin, // 箭头的起点
98 const geom::Location &end, // 箭头的终点
99 float thickness, // 箭头的粗细
100 float arrow_size, // 箭头的大小
101 sensor::data::Color color, // 箭头的颜色
102 float life_time, // 生存时间
103 bool persistent_lines) { // 是否为持久线
104 Shape::HUDLine line{begin, end, thickness}; // 创建HUD箭头的线形状
105 Shape::HUDArrow arrow{line, arrow_size}; // 创建HUD箭头形状
106 DrawShape(_episode, arrow, color, life_time, persistent_lines); // 调用绘制形状
107 }
108
109 // 绘制框
110// 函数定义
112 const geom::BoundingBox &box, // 边界框
113 const geom::Rotation &rotation, // 旋转信息
114 float thickness, // 边框的粗细
115 sensor::data::Color color, // 边框的颜色
116 float life_time, // 生存时间
117 bool persistent_lines) { // 是否为持久线
118 // 创建一个HUD边界框形状对象
119 Shape::Box the_box{box, rotation, thickness}; // 创建框形状
120 // 将创建的形状对象绘制到场景中
121 DrawShape(_episode, the_box, color, life_time, persistent_lines); // 调用绘制形状
122 }
123
124 // 绘制HUD框
126 const geom::BoundingBox &box, // 边界框
127 const geom::Rotation &rotation, // 旋转信息
128 float thickness, // 边框的粗细
129 sensor::data::Color color, // 边框的颜色
130 float life_time, // 生存时间
131 bool persistent_lines) { // 是否为持久线
132 Shape::HUDBox the_box{box, rotation, thickness}; // 创建HUD框形状
133 DrawShape(_episode, the_box, color, life_time, persistent_lines); // 调用绘制形状
134 }
135
136 // 绘制字符串
138 const geom::Location &location, // 字符串的位置
139 const std::string &text, // 字符串内容
140 bool draw_shadow, // 是否绘制阴影
141 sensor::data::Color color, // 字符串的颜色
142 float life_time, // 生存时间
143 bool persistent_lines) { // 是否为持久线
144 Shape::String string{location, text, draw_shadow}; // 创建字符串形状
145 DrawShape(_episode, string, color, life_time, persistent_lines); // 调用绘制形状
146 }
147
148} // namespace client
149} // namespace carla
auto end() const noexcept
auto begin() const noexcept
名称范围迭代支持
void DrawHUDArrow(const geom::Location &begin, const geom::Location &end, float thickness=0.1f, float arrow_size=0.1f, Color color=Color{255u, 0u, 0u}, float life_time=-1.0f, bool persistent_lines=true)
void DrawString(const geom::Location &location, const std::string &text, bool draw_shadow=false, Color color=Color{255u, 0u, 0u}, float life_time=-1.0f, bool persistent_lines=true)
void DrawLine(const geom::Location &begin, const geom::Location &end, float thickness=0.1f, Color color=Color{255u, 0u, 0u}, float life_time=-1.0f, bool persistent_lines=true)
void DrawHUDLine(const geom::Location &begin, const geom::Location &end, float thickness=1.0f, Color color=Color{225u, 0u, 0u}, float life_time=-1.0f, bool persistent_lines=true)
detail::EpisodeProxy _episode
void DrawHUDPoint(const geom::Location &location, float size=0.1f, Color color=Color{255u, 0u, 0u}, float life_time=-1.0f, bool persistent_lines=true)
void DrawHUDBox(const geom::BoundingBox &box, const geom::Rotation &rotation, float thickness=0.1f, Color color=Color{255u, 0u, 0u}, float life_time=-1.0f, bool persistent_lines=true)
void DrawArrow(const geom::Location &begin, const geom::Location &end, float thickness=0.1f, float arrow_size=0.1f, Color color=Color{255u, 0u, 0u}, float life_time=-1.0f, bool persistent_lines=true)
void DrawPoint(const geom::Location &location, float size=0.1f, Color color=Color{255u, 0u, 0u}, float life_time=-1.0f, bool persistent_lines=true)
void DrawBox(const geom::BoundingBox &box, const geom::Rotation &rotation, float thickness=0.1f, Color color=Color{255u, 0u, 0u}, float life_time=-1.0f, bool persistent_lines=true)
SharedPtrType Lock() const
与 TryLock 相同,但永远不会返回 nullptr。
static void DrawShape(detail::EpisodeProxy &episode, const T &primitive, rpc::Color color, float life_time, bool persistent_lines)
CARLA模拟器的主命名空间。
Definition Carla.cpp:139
包含CARLA客户端相关类和函数的命名空间。