CARLA
 
载入中...
搜索中...
未找到
RoadInfoCrosswalk.h
浏览该文件的文档.
1// Copyright (c) 2019 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/road/element/RoadInfo.h" // 引入 RoadInfo 头文件
10
11namespace carla { // 开始 carla 命名空间
12namespace road { // 开始 road 命名空间
13namespace element { // 开始 element 命名空间
14
15 // 定义一个结构体 CrosswalkPoint,表示人行横道的点
17 double u { 0.0 }; // 横向坐标 u,初始化为 0.0
18 double v { 0.0 }; // 纵向坐标 v,初始化为 0.0
19 double z { 0.0 }; // 高度坐标 z,初始化为 0.0
20 // 构造函数,初始化 u、v 和 z 的值
21 CrosswalkPoint(double _u, double _v, double _z) : u(_u), v(_v), z(_z) {};
22 };
23
24 // 定义一个类 RoadInfoCrosswalk,继承自 RoadInfo
25 class RoadInfoCrosswalk final : public RoadInfo {
26 public:
27
28 // 构造函数,初始化 RoadInfoCrosswalk 的成员变量
30 const double s, // 路段的 s 坐标
31 const std::string name, // 人行横道的名称
32 const double t, // 路段的 t 坐标
33 const double zOffset, // z 方向的偏移量
34 const double hdg, // 航向角
35 const double pitch, // 俯仰角
36 const double roll, // 横滚角
37 const std::string orientation, // 定位方向
38 const double width, // 人行横道的宽度
39 const double length, // 人行横道的长度
40 const std::vector<CrosswalkPoint> points) // 人行横道的点集合
41 : RoadInfo(s), // 初始化基类 RoadInfo 的 s 坐标
42 _name(name), // 初始化名称
43 _t(t), // 初始化 t 坐标
44 _zOffset(zOffset), // 初始化 z 偏移量
45 _hdg(hdg), // 初始化航向角
46 _pitch(pitch), // 初始化俯仰角
47 _roll(roll), // 初始化横滚角
48 _orientation(orientation), // 初始化定位方向
49 _width(width), // 初始化宽度
50 _length(length), // 初始化长度
51 _points(points) {} // 初始化人行横道的点集合
52
53 // 接受访问者模式
55 v.Visit(*this); // 让访问者访问当前对象
56 }
57
58 // 获取 s 坐标
59 double GetS() const { return GetDistance(); };
60 // 获取 t 坐标
61 double GetT() const { return _t; };
62 // 获取人行横道的宽度
63 double GetWidth() const { return _width; };
64 // 获取人行横道的长度
65 double GetLength() const { return _length; };
66 // 获取航向角
67 double GetHeading() const { return _hdg; };
68 // 获取俯仰角
69 double GetPitch() const { return _pitch; };
70 // 获取横滚角
71 double GetRoll() const { return _roll; };
72 // 获取 z 偏移量
73 double GetZOffset() const { return _zOffset; };
74 // 获取定位方向
75 std::string GetOrientation() const { return _orientation; };
76 // 获取人行横道的点集合
77 const std::vector<CrosswalkPoint> &GetPoints() const { return _points; };
78
79 private:
80 std::string _name; // 存储人行横道的名称
81 double _t; // 存储 t 坐标
82 double _zOffset; // 存储 z 偏移量
83 double _hdg; // 存储航向角
84 double _pitch; // 存储俯仰角
85 double _roll; // 存储横滚角
86 std::string _orientation; // 存储定位方向
87 double _width; // 存储人行横道的宽度
88 double _length; // 存储人行横道的长度
89 std::vector<CrosswalkPoint> _points; // 存储人行横道的点集合
90 };
91
92} // namespace element
93} // namespace road
94} // namespace carla
std::vector< CrosswalkPoint > _points
const std::vector< CrosswalkPoint > & GetPoints() const
RoadInfoCrosswalk(const double s, const std::string name, const double t, const double zOffset, const double hdg, const double pitch, const double roll, const std::string orientation, const double width, const double length, const std::vector< CrosswalkPoint > points)
void AcceptVisitor(RoadInfoVisitor &v) final
double GetDistance() const
获取从道路起始位置的距离。 Distance from road's start location.
Definition RoadInfo.h:29
CARLA模拟器的主命名空间。
Definition Carla.cpp:139
CrosswalkPoint(double _u, double _v, double _z)