CARLA
client/Map.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"
12 #include "carla/road/Lane.h"
13 #include "carla/road/Map.h"
14 #include "carla/road/RoadTypes.h"
15 #include "carla/rpc/MapInfo.h"
16 #include "Landmark.h"
17 
18 #include <string>
19 
20 namespace carla {
21 namespace geom { class GeoLocation; }
22 namespace client {
23 
24  class Waypoint;
25  class Junction;
26 
27  class Map
28  : public EnableSharedFromThis<Map>,
29  private NonCopyable {
30  public:
31 
32  explicit Map(rpc::MapInfo description, std::string xodr_content);
33 
34  explicit Map(std::string name, std::string xodr_content);
35 
36  ~Map();
37 
38  const std::string &GetName() const {
39  return _description.name;
40  }
41 
42  const road::Map &GetMap() const {
43  return _map;
44  }
45 
46  const std::string &GetOpenDrive() const {
47  return open_drive_file;
48  }
49 
50  const std::vector<geom::Transform> &GetRecommendedSpawnPoints() const {
51  return _description.recommended_spawn_points;
52  }
53 
54  SharedPtr<Waypoint> GetWaypoint(
55  const geom::Location &location,
56  bool project_to_road = true,
57  int32_t lane_type = static_cast<uint32_t>(road::Lane::LaneType::Driving)) const;
58 
59  SharedPtr<Waypoint> GetWaypointXODR(
60  carla::road::RoadId road_id,
61  carla::road::LaneId lane_id,
62  float s) const;
63 
64  using TopologyList = std::vector<std::pair<SharedPtr<Waypoint>, SharedPtr<Waypoint>>>;
65 
66  TopologyList GetTopology() const;
67 
68  std::vector<SharedPtr<Waypoint>> GenerateWaypoints(double distance) const;
69 
70  std::vector<road::element::LaneMarking> CalculateCrossedLanes(
71  const geom::Location &origin,
72  const geom::Location &destination) const;
73 
74  const geom::GeoLocation &GetGeoReference() const;
75 
76  std::vector<geom::Location> GetAllCrosswalkZones() const;
77 
78  SharedPtr<Junction> GetJunction(const Waypoint &waypoint) const;
79 
80  /// Returns a pair of waypoints (start and end) for each lane in the
81  /// junction
82  std::vector<std::pair<SharedPtr<Waypoint>, SharedPtr<Waypoint>>> GetJunctionWaypoints(
83  road::JuncId id, road::Lane::LaneType type) const;
84 
85  /// Returns all the larndmarks in the map
86  std::vector<SharedPtr<Landmark>> GetAllLandmarks() const;
87 
88  /// Returns all the larndmarks in the map with a specific OpenDRIVE id
89  std::vector<SharedPtr<Landmark>> GetLandmarksFromId(std::string id) const;
90 
91  /// Returns all the landmarks in the map of a specific type
92  std::vector<SharedPtr<Landmark>> GetAllLandmarksOfType(std::string type) const;
93 
94  /// Returns all the landmarks in the same group including this one
95  std::vector<SharedPtr<Landmark>> GetLandmarkGroup(const Landmark &landmark) const;
96 
97  /// Cooks InMemoryMap used by the traffic manager
98  void CookInMemoryMap(const std::string& path) const;
99 
100  private:
101 
102  std::string open_drive_file;
103 
105 
107  };
108 
109 } // namespace client
110 } // namespace carla
uint32_t RoadId
Definition: RoadTypes.h:15
const road::Map & GetMap() const
Definition: client/Map.h:42
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
This file contains definitions of common data structures used in traffic manager. ...
Definition: Carla.cpp:133
const rpc::MapInfo _description
Definition: client/Map.h:104
Class containing a reference to RoadInfoSignal.
Definition: Landmark.h:22
std::vector< std::pair< SharedPtr< Waypoint >, SharedPtr< Waypoint > >> TopologyList
Definition: client/Map.h:64
int32_t JuncId
Definition: RoadTypes.h:17
const std::vector< geom::Transform > & GetRecommendedSpawnPoints() const
Definition: client/Map.h:50
LaneType
Can be used as flags.
Definition: Lane.h:29
int32_t LaneId
Definition: RoadTypes.h:19
std::string open_drive_file
Definition: client/Map.h:102
const road::Map _map
Definition: client/Map.h:106
Inherit (privately) to suppress copy/move construction and assignment.
const std::string & GetName() const
Definition: client/Map.h:38
const std::string & GetOpenDrive() const
Definition: client/Map.h:46
carla::SharedPtr< carla::client::Junction > Junction