CARLA
载入中...
搜索中...
未找到
LibCarla
source
carla
road
element
road/element/Waypoint.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/road/element/Waypoint.h
"
// 引入Waypoint类的定义
8
9
#include <boost/container_hash/hash.hpp>
// 引入Boost库中的hash工具,用于辅助生成哈希值
10
11
// 在std命名空间中定义一个新的类型别名和使用自定义的哈希函数
12
namespace
std
{
13
14
// 使用std::hash模板特化,为carla::road::element::Waypoint类定义一个哈希函数类型
15
using
WaypointHash
= hash<carla::road::element::Waypoint>;
16
17
// 定义WaypointHash的operator()函数,这是哈希函数的核心,用于计算Waypoint对象的哈希值
18
WaypointHash::result_type
WaypointHash::operator()
(
const
argument_type
&waypoint)
const
{
19
// 初始化哈希种子为0
20
WaypointHash::result_type
seed = 0u;
21
22
// 使用boost::hash_combine函数结合waypoint的各个属性(road_id, section_id, lane_id, s的近似值)来生成哈希值
23
// road_id, section_id, lane_id是Waypoint对象的标识符,s是Waypoint在道路上的位置(可能是以米为单位)
24
// 注意:s的值被乘以200并向下取整到最近的浮点数,这可能是为了增加哈希值的分布范围,减少哈希冲突
25
boost::hash_combine(seed, waypoint.
road_id
);
26
boost::hash_combine(seed, waypoint.
section_id
);
27
boost::hash_combine(seed, waypoint.
lane_id
);
28
boost::hash_combine(seed,
static_cast<
float
>
(std::floor(waypoint.
s
* 200.0)));
29
30
// 返回最终生成的哈希值
31
return
seed;
32
}
33
34
}
// namespace std
std
Definition
CarlaRecorderCollision.h:31
Waypoint.h
carla::road::element::Waypoint
Definition
road/element/Waypoint.h:18
carla::road::element::Waypoint::section_id
SectionId section_id
Definition
road/element/Waypoint.h:22
carla::road::element::Waypoint::road_id
RoadId road_id
Definition
road/element/Waypoint.h:20
carla::road::element::Waypoint::lane_id
LaneId lane_id
Definition
road/element/Waypoint.h:24
carla::road::element::Waypoint::s
double s
Definition
road/element/Waypoint.h:26
std::hash< carla::road::element::Waypoint >
Definition
road/element/Waypoint.h:36
std::hash< carla::road::element::Waypoint >::operator()
result_type operator()(const argument_type &waypoint) const
根据waypoint的road_id、lane_id、section_id和"s"偏移量生成一个唯一的ID "s"偏移量被截断到半厘米精度
Definition
road/element/Waypoint.cpp:18
std::hash< carla::road::element::Waypoint >::result_type
uint64_t result_type
Definition
road/element/Waypoint.h:40
制作者
1.10.0