CARLA
Loading...
Searching...
No Matches
client/Map.h
Go to the documentation of this file.
1// Copyright (c) 2026 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"
15#include "carla/rpc/MapInfo.h"
16#include "Landmark.h"
17
18#include <string>
19
20namespace carla {
21namespace geom { class GeoLocation; struct GeoProjection; }
22namespace client {
23
24 class Waypoint;
25 class Junction;
26 class Road;
27 class LaneSection;
28 class Lane;
29
30 class Map
31 : public EnableSharedFromThis<Map>,
32 private NonCopyable {
33 public:
34
35 explicit Map(rpc::MapInfo description, std::string xodr_content);
36
37 explicit Map(std::string name, std::string xodr_content);
38
40
41 const std::string &GetName() const {
42 return _description.name;
43 }
44
45 const road::Map &GetMap() const {
46 return _map;
47 }
48
49 const std::string &GetOpenDrive() const {
50 return open_drive_file;
51 }
52
53 const std::vector<geom::Transform> &GetRecommendedSpawnPoints() const {
55 }
56
58 const geom::Location &location,
59 bool project_to_road = true,
60 int32_t lane_type = static_cast<uint32_t>(road::Lane::LaneType::Driving)) const;
61
64 carla::road::LaneId lane_id,
65 float s) const;
66
67 using TopologyList = std::vector<std::pair<SharedPtr<Waypoint>, SharedPtr<Waypoint>>>;
68
70
71 std::vector<SharedPtr<Waypoint>> GenerateWaypoints(double distance) const;
72
73 std::vector<road::element::LaneMarking> CalculateCrossedLanes(
74 const geom::Location &origin,
75 const geom::Location &destination) const;
76
78
80
81 std::vector<geom::Location> GetAllCrosswalkZones() const;
82
83 SharedPtr<Junction> GetJunction(const Waypoint &waypoint) const;
84
85 /// Returns a pair of waypoints (start and end) for each lane in the
86 /// junction
87 std::vector<std::pair<SharedPtr<Waypoint>, SharedPtr<Waypoint>>> GetJunctionWaypoints(
88 road::JuncId id, road::Lane::LaneType type) const;
89
90 /// Returns the junction with this id, or nullptr when the map has none.
92
93 /// Returns every junction in the map.
94 std::vector<SharedPtr<Junction>> GetJunctions() const;
95
96 /// Returns every road in the map.
97 std::vector<SharedPtr<Road>> GetRoads() const;
98
99 /// Returns the road with this id, or nullptr when the map has none.
101
102 /// Returns the lane section, or nullptr when road or section is unknown.
105 road::SectionId section_id) const;
106
107 /// Returns the lane, or nullptr when road, section or lane is unknown.
110 road::SectionId section_id,
111 road::LaneId lane_id) const;
112
113 /// @internal Wraps a road-level waypoint. Every client-side wrapper builds
114 /// its waypoints through here, so Waypoint only needs to befriend Map.
116
117 /// Returns all the larndmarks in the map
118 std::vector<SharedPtr<Landmark>> GetAllLandmarks() const;
119
120 /// Returns all the larndmarks in the map with a specific OpenDRIVE id
121 std::vector<SharedPtr<Landmark>> GetLandmarksFromId(std::string id) const;
122
123 /// Returns all the landmarks in the map of a specific type
124 std::vector<SharedPtr<Landmark>> GetAllLandmarksOfType(std::string type) const;
125
126 /// Returns all the landmarks in the same group including this one
127 std::vector<SharedPtr<Landmark>> GetLandmarkGroup(const Landmark &landmark) const;
128
129 /// Cooks InMemoryMap used by the traffic manager
130 void CookInMemoryMap(const std::string& path) const;
131
132 private:
133
134 std::string open_drive_file;
135
137
139 };
140
141} // namespace client
142} // namespace carla
float distance
std::string road_id
Definition LaneGraph.cpp:39
Inherit (privately) to suppress copy/move construction and assignment.
Class containing a reference to RoadInfoSignal.
Definition Landmark.h:22
const road::Map & GetMap() const
Definition client/Map.h:45
const geom::GeoProjection & GetGeoProjection() const
std::vector< geom::Location > GetAllCrosswalkZones() const
const std::string & GetOpenDrive() const
Definition client/Map.h:49
const std::vector< geom::Transform > & GetRecommendedSpawnPoints() const
Definition client/Map.h:53
SharedPtr< Waypoint > GetWaypointXODR(carla::road::RoadId road_id, carla::road::LaneId lane_id, float s) const
SharedPtr< Junction > GetJunctionById(road::JuncId id) const
Returns the junction with this id, or nullptr when the map has none.
SharedPtr< Waypoint > MakeWaypoint(road::element::Waypoint waypoint) const
SharedPtr< Junction > GetJunction(const Waypoint &waypoint) const
void CookInMemoryMap(const std::string &path) const
Cooks InMemoryMap used by the traffic manager.
std::string open_drive_file
Definition client/Map.h:134
SharedPtr< LaneSection > GetLaneSection(road::RoadId road_id, road::SectionId section_id) const
Returns the lane section, or nullptr when road or section is unknown.
SharedPtr< Lane > GetLane(road::RoadId road_id, road::SectionId section_id, road::LaneId lane_id) const
Returns the lane, or nullptr when road, section or lane is unknown.
std::vector< SharedPtr< Landmark > > GetLandmarksFromId(std::string id) const
Returns all the larndmarks in the map with a specific OpenDRIVE id.
std::vector< SharedPtr< Landmark > > GetAllLandmarksOfType(std::string type) const
Returns all the landmarks in the map of a specific type.
TopologyList GetTopology() const
const rpc::MapInfo _description
Definition client/Map.h:136
const geom::GeoLocation & GetGeoReference() const
SharedPtr< Road > GetRoad(road::RoadId road_id) const
Returns the road with this id, or nullptr when the map has none.
std::vector< SharedPtr< Landmark > > GetLandmarkGroup(const Landmark &landmark) const
Returns all the landmarks in the same group including this one.
std::vector< road::element::LaneMarking > CalculateCrossedLanes(const geom::Location &origin, const geom::Location &destination) const
SharedPtr< Waypoint > GetWaypoint(const geom::Location &location, bool project_to_road=true, int32_t lane_type=static_cast< uint32_t >(road::Lane::LaneType::Driving)) const
std::vector< std::pair< SharedPtr< Waypoint >, SharedPtr< Waypoint > > > TopologyList
Definition client/Map.h:67
const road::Map _map
Definition client/Map.h:138
std::vector< SharedPtr< Junction > > GetJunctions() const
Returns every junction in the map.
std::vector< SharedPtr< Road > > GetRoads() const
Returns every road in the map.
std::vector< SharedPtr< Landmark > > GetAllLandmarks() const
Returns all the larndmarks in the map.
const std::string & GetName() const
Definition client/Map.h:41
std::vector< SharedPtr< Waypoint > > GenerateWaypoints(double distance) const
std::vector< std::pair< SharedPtr< Waypoint >, SharedPtr< Waypoint > > > GetJunctionWaypoints(road::JuncId id, road::Lane::LaneType type) const
Returns a pair of waypoints (start and end) for each lane in the junction.
LaneType
Can be used as flags.
Definition road/Lane.h:29
std::string name
Definition MapInfo.h:21
std::vector< geom::Transform > recommended_spawn_points
Definition MapInfo.h:23
int32_t JuncId
Definition RoadTypes.h:17
uint32_t RoadId
Definition RoadTypes.h:15
int32_t LaneId
Definition RoadTypes.h:19
uint32_t SectionId
Definition RoadTypes.h:21
carla::SharedPtr< carla::client::Junction > Junction
This file contains definitions of common data structures used in traffic manager.
std::shared_ptr< T > SharedPtr
Definition Memory.h:15