CARLA
road/element/Waypoint.h
Go to the documentation of this file.
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 
14 namespace carla {
15 namespace road {
16 namespace element {
17 
18  struct Waypoint {
19 
21 
23 
25 
26  double s = 0.0;
27  };
28 
29 } // namespace element
30 } // namespace road
31 } // namespace carla
32 
33 namespace std {
34 
35  template <>
36  struct hash<carla::road::element::Waypoint> {
37 
39 
40  using result_type = uint64_t;
41 
42  /// Generates an unique id for @a waypoint based on its road_id, lane_id,
43  /// section_id, and "s" offset. The "s" offset is truncated to half
44  /// centimetre precision.
45  result_type operator()(const argument_type &waypoint) const;
46 
47  };
48 
49 } // namespace std
50 
51 namespace carla {
52 namespace road {
53 namespace 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
uint32_t RoadId
Definition: RoadTypes.h:15
bool operator==(const Waypoint &lhs, const Waypoint &rhs)
This file contains definitions of common data structures used in traffic manager. ...
Definition: Carla.cpp:133
uint32_t SectionId
Definition: RoadTypes.h:21
bool operator!=(const Waypoint &lhs, const Waypoint &rhs)
int32_t LaneId
Definition: RoadTypes.h:19