CARLA
 
载入中...
搜索中...
未找到
DebugShape.h
浏览该文件的文档.
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
9#include "carla/MsgPack.h"
12#include "carla/geom/Location.h"
13#include "carla/geom/Rotation.h"
14#include "carla/rpc/Color.h"
15
16#ifdef _MSC_VER
17#pragma warning(push)
18#pragma warning(disable:4583)
19#pragma warning(disable:4582)
20#include <boost/variant2/variant.hpp>
21#pragma warning(pop)
22#else
23#include <boost/variant2/variant.hpp>
24#endif
25
26namespace carla {
27namespace rpc {
28
29 // 定义 DebugShape 类,用于表示调试绘制的几何形状
30 class DebugShape {
31 public:
32
33 // 点结构体,包含位置和大小
34 struct Point {
35 geom::Location location; // 点的位置(geom::Location 类型)
36 float size; // 点的大小
37 MSGPACK_DEFINE_ARRAY(location, size); // 使用 MsgPack 序列化,定义该结构的字段
38 };
39
40 // HUD 点结构体,包含位置和大小
41 struct HUDPoint {
42 geom::Location location; // 点的位置(geom::Location 类型)
43 float size; // 点的大小
44 MSGPACK_DEFINE_ARRAY(location, size); // 使用 MsgPack 序列化,定义该结构的字段
45 };
46
47 // 线段结构体,包含起始点、结束点和线的粗细
48 struct Line {
49 geom::Location begin; // 线段的起始点
50 geom::Location end; // 线段的结束点
51 float thickness; // 线段的粗细
52 MSGPACK_DEFINE_ARRAY(begin, end, thickness); // 使用 MsgPack 序列化,定义该结构的字段
53 };
54
55 // HUD 线段结构体,包含起始点、结束点和线的粗细
56 struct HUDLine {
57 geom::Location begin; // 线段的起始点
58 geom::Location end; // 线段的结束点
59 float thickness; // 线段的粗细
60 MSGPACK_DEFINE_ARRAY(begin, end, thickness); // 使用 MsgPack 序列化,定义该结构的字段
61 };
62
63 // 箭头结构体,包含线段和箭头大小
64 struct Arrow {
65 Line line; // 箭头的线段
66 float arrow_size; // 箭头的大小
67 MSGPACK_DEFINE_ARRAY(line, arrow_size); // 使用 MsgPack 序列化,定义该结构的字段
68 };
69
70 // HUD 箭头结构体,包含线段和箭头大小
71 struct HUDArrow {
72 HUDLine line; // HUD 箭头的线段
73 float arrow_size; // 箭头的大小
74 MSGPACK_DEFINE_ARRAY(line, arrow_size); // 使用 MsgPack 序列化,定义该结构的字段
75 };
76
77 // 方框结构体,包含边界框、旋转角度和线的粗细
78 struct Box {
79 geom::BoundingBox box; // 方框的边界框
80 geom::Rotation rotation; // 方框的旋转角度
81 float thickness; // 方框的线粗细
82 MSGPACK_DEFINE_ARRAY(box, rotation, thickness); // 使用 MsgPack 序列化,定义该结构的字段
83 };
84
85 // HUD 方框结构体,包含边界框、旋转角度和线的粗细
86 struct HUDBox {
87 geom::BoundingBox box; // 方框的边界框
88 geom::Rotation rotation; // 方框的旋转角度
89 float thickness; // 方框的线粗细
90 MSGPACK_DEFINE_ARRAY(box, rotation, thickness); // 使用 MsgPack 序列化,定义该结构的字段
91 };
92
93 // 字符串结构体,包含位置、文本和是否绘制阴影
94 struct String {
95 geom::Location location; // 文本的绘制位置
96 std::string text; // 要绘制的文本
97 bool draw_shadow; // 是否绘制文本阴影
98 MSGPACK_DEFINE_ARRAY(location, text, draw_shadow); // 使用 MsgPack 序列化,定义该结构的字段
99 };
100
101 // 使用 boost::variant 存储多种几何形状的变种类型
102 boost::variant2::variant<Point, Line, Arrow, Box, String, HUDPoint, HUDLine, HUDArrow, HUDBox> primitive;
103
104 // 颜色,默认为红色(255u, 0u, 0u)
105 Color color = {255u, 0u, 0u};
106
107 // 生命周期,默认为 -1.0f 表示永远存在
108 float life_time = -1.0f;
109
110 // 是否为持久化线条,默认为 true
111 bool persistent_lines = true;
112
113 // 使用 MsgPack 序列化,定义该结构的字段
115 };
116
117} // namespace rpc
118} // namespace carla
boost::variant2::variant< Point, Line, Arrow, Box, String, HUDPoint, HUDLine, HUDArrow, HUDBox > primitive
Definition DebugShape.h:102
MSGPACK_DEFINE_ARRAY(primitive, color, life_time, persistent_lines)
CARLA模拟器的主命名空间。
Definition Carla.cpp:139
MSGPACK_DEFINE_ARRAY(line, arrow_size)
MSGPACK_DEFINE_ARRAY(box, rotation, thickness)
geom::BoundingBox box
Definition DebugShape.h:79
MSGPACK_DEFINE_ARRAY(line, arrow_size)
MSGPACK_DEFINE_ARRAY(box, rotation, thickness)
MSGPACK_DEFINE_ARRAY(begin, end, thickness)
MSGPACK_DEFINE_ARRAY(location, size)
MSGPACK_DEFINE_ARRAY(begin, end, thickness)
MSGPACK_DEFINE_ARRAY(location, size)
MSGPACK_DEFINE_ARRAY(location, text, draw_shadow)