CARLA
 
载入中...
搜索中...
未找到
road/element/Waypoint.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/road/RoadTypes.h" // 包含道路类型定义
10
11#include <cstdint> // 包含标准整数类型定义
12#include <functional> // 包含函数对象和函数适配器定义
13
14namespace carla {
15namespace road {
16namespace element {
17
18 struct Waypoint { // 定义Waypoint结构体
19
20 RoadId road_id = 0u; // 道路ID
21
22 SectionId section_id = 0u; // 路段ID
23
24 LaneId lane_id = 0; // 车道ID
25
26 double s = 0.0; // 沿道路的偏移量
27 };
28
29} // namespace element
30} // namespace road
31} // namespace carla
32
33namespace std {
34
35 template <>
36 struct hash<carla::road::element::Waypoint> { // 定义Waypoint的哈希函数
37
39
40 using result_type = uint64_t; // 结果类型
41
42 /// 根据@a waypoint的road_id、lane_id、section_id和"s"偏移量生成一个唯一的ID
43 /// "s"偏移量被截断到半厘米精度
44 ///
45 result_type operator()(const argument_type &waypoint) const; // 哈希函数实现
46
47 };
48
49} // namespace std
50
51namespace carla {
52namespace road {
53namespace element {
54
55 inline bool operator==(const Waypoint &lhs, const Waypoint &rhs) { // 定义等于运算符
56 auto hasher = std::hash<Waypoint>(); // 创建哈希对象
57 return hasher(lhs) == hasher(rhs); // 返回哈希值是否相等
58 }
59
60 inline bool operator!=(const Waypoint &lhs, const Waypoint &rhs) { // 定义不等于运算符
61 return !operator==(lhs, rhs); // 返回不等于运算符的结果
62 }
63
64} // namespace element
65} // namespace road
66} // namespace carla
bool operator==(const Waypoint &lhs, const Waypoint &rhs)
bool operator!=(const Waypoint &lhs, const Waypoint &rhs)
uint32_t SectionId
Definition RoadTypes.h:29
int32_t LaneId
Definition RoadTypes.h:26
uint32_t RoadId
Definition RoadTypes.h:20
CARLA模拟器的主命名空间。
Definition Carla.cpp:139