CARLA
client/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/Memory.h"
10 #include "carla/NonCopyable.h"
11 #include "carla/geom/Transform.h"
15 #include "carla/road/Lane.h"
16 #include "carla/road/RoadTypes.h"
17 
18 #include <boost/optional.hpp>
19 
20 namespace carla {
21 namespace client {
22 
23  class Map;
24  class Junction;
25  class Landmark;
26 
27  class Waypoint
28  : public EnableSharedFromThis<Waypoint>,
29  private NonCopyable {
30  public:
31 
32  ~Waypoint();
33 
34  /// Returns an unique Id identifying this waypoint.
35  ///
36  /// The Id takes into account OpenDrive's road Id, lane Id, and s distance
37  /// on its road segment up to half-centimetre precision.
38  uint64_t GetId() const {
39  return std::hash<road::element::Waypoint>()(_waypoint);
40  }
41 
42  auto GetRoadId() const {
43  return _waypoint.road_id;
44  }
45 
46  auto GetSectionId() const {
47  return _waypoint.section_id;
48  }
49 
50  auto GetLaneId() const {
51  return _waypoint.lane_id;
52  }
53 
54  auto GetDistance() const {
55  return _waypoint.s;
56  }
57 
58  const geom::Transform &GetTransform() const {
59  return _transform;
60  }
61 
63 
64  bool IsJunction() const;
65 
67 
68  double GetLaneWidth() const;
69 
71 
72  std::vector<SharedPtr<Waypoint>> GetNext(double distance) const;
73 
74  std::vector<SharedPtr<Waypoint>> GetPrevious(double distance) const;
75 
76  /// Returns a list of waypoints separated by distance from the current waypoint
77  /// to the end of the lane
78  std::vector<SharedPtr<Waypoint>> GetNextUntilLaneEnd(double distance) const;
79 
80  /// Returns a list of waypoints separated by distance from the current waypoint
81  /// to the start of the lane
82  std::vector<SharedPtr<Waypoint>> GetPreviousUntilLaneStart(double distance) const;
83 
85 
87 
88  boost::optional<road::element::LaneMarking> GetRightLaneMarking() const;
89 
90  boost::optional<road::element::LaneMarking> GetLeftLaneMarking() const;
91 
93 
94  /// Returns a list of landmarks from the current position to a certain distance
95  std::vector<SharedPtr<Landmark>> GetAllLandmarksInDistance(
96  double distance, bool stop_at_junction = false) const;
97 
98  /// Returns a list of landmarks from the current position to a certain distance
99  /// Filters by specified type
100  std::vector<SharedPtr<Landmark>> GetLandmarksOfTypeInDistance(
101  double distance, std::string filter_type, bool stop_at_junction = false) const;
102 
103  private:
104 
105  friend class Map;
106 
108 
110 
112 
114 
115  // Mark record right and left respectively.
116  std::pair<
118  const road::element::RoadInfoMarkRecord *> _mark_record;
119  };
120 
121 } // namespace client
122 } // namespace carla
const geom::Transform & GetTransform() const
std::vector< SharedPtr< Waypoint > > GetNext(double distance) const
Each lane within a road cross section can be provided with several road markentries.
std::vector< SharedPtr< Waypoint > > GetPreviousUntilLaneStart(double distance) const
Returns a list of waypoints separated by distance from the current waypoint to the start of the lane...
boost::shared_ptr< T > SharedPtr
Use this SharedPtr (boost::shared_ptr) to keep compatibility with boost::python, but it would be nice...
Definition: Memory.h:20
LaneChange
Can be used as flags.
Definition: LaneMarking.h:50
std::vector< SharedPtr< Landmark > > GetLandmarksOfTypeInDistance(double distance, std::string filter_type, bool stop_at_junction=false) const
Returns a list of landmarks from the current position to a certain distance Filters by specified type...
This file contains definitions of common data structures used in traffic manager. ...
Definition: Carla.cpp:133
road::element::LaneMarking::LaneChange GetLaneChange() const
uint64_t GetId() const
Returns an unique Id identifying this waypoint.
int32_t JuncId
Definition: RoadTypes.h:17
std::pair< const road::element::RoadInfoMarkRecord *, const road::element::RoadInfoMarkRecord * > _mark_record
std::vector< SharedPtr< Waypoint > > GetPrevious(double distance) const
road::JuncId GetJunctionId() const
road::Lane::LaneType GetType() const
LaneType
Can be used as flags.
Definition: Lane.h:29
Waypoint(SharedPtr< const Map > parent, road::element::Waypoint waypoint)
SharedPtr< Waypoint > GetLeft() const
SharedPtr< Junction > GetJunction() const
boost::optional< road::element::LaneMarking > GetRightLaneMarking() const
road::element::Waypoint _waypoint
boost::optional< road::element::LaneMarking > GetLeftLaneMarking() const
geom::Transform _transform
SharedPtr< Waypoint > GetRight() const
std::vector< SharedPtr< Landmark > > GetAllLandmarksInDistance(double distance, bool stop_at_junction=false) const
Returns a list of landmarks from the current position to a certain distance.
Inherit (privately) to suppress copy/move construction and assignment.
SharedPtr< const Map > _parent
carla::SharedPtr< carla::client::Junction > Junction
std::vector< SharedPtr< Waypoint > > GetNextUntilLaneEnd(double distance) const
Returns a list of waypoints separated by distance from the current waypoint to the end of the lane...