Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:CARLA simulator Carla MapData

From Leeroopedia
Knowledge Sources
Domains Road Network, Simulation
Last Updated 2026-02-15 05:00 GMT

Overview

The MapData class is the primary data container for the parsed OpenDRIVE road network, holding all roads, junctions, signals, and controllers.

Description

carla::road::MapData is a MovableNonCopyable class that stores the complete road network data parsed from an OpenDRIVE file. It is constructed by MapBuilder and consumed by Map. It contains:

  • Roads -- an unordered_map<RoadId, Road> holding all road segments
  • Junctions -- an unordered_map<JuncId, Junction> holding all junction definitions
  • Signals -- an unordered_map<SignId, unique_ptr<Signal>> holding all traffic signals
  • Controllers -- an unordered_map<ContId, unique_ptr<Controller>> holding signal controllers
  • Geo-reference -- a GeoLocation for coordinate system reference

Template methods GetRoadInfo<T>(road_id, s) and GetLaneInfo<T>(road_id, section_id, lane_id, s) provide convenient typed access to road information records.

Usage

This class is the internal data store created by MapBuilder during OpenDRIVE parsing and passed to Map for spatial indexing and query operations. Direct usage is typically limited to the map construction pipeline.

Code Reference

Source Location

  • Repository: CARLA
  • File: LibCarla/source/carla/road/MapData.h

Signature

class MapData : private MovableNonCopyable {
public:
  const geom::GeoLocation &GetGeoReference() const;

  std::unordered_map<RoadId, Road> &GetRoads();
  const std::unordered_map<RoadId, Road> &GetRoads() const;
  std::unordered_map<JuncId, Junction> &GetJunctions();
  const std::unordered_map<JuncId, Junction> &GetJunctions() const;

  bool ContainsRoad(RoadId id) const;
  Road &GetRoad(const RoadId id);
  const Road &GetRoad(const RoadId id) const;
  Junction *GetJunction(JuncId id);
  size_t GetRoadCount() const;

  const std::unordered_map<SignId, std::unique_ptr<Signal>> &GetSignals() const;
  const std::unordered_map<ContId, std::unique_ptr<Controller>> &GetControllers() const;

  template <typename T> auto GetRoadInfo(const RoadId id, const double s);
  template <typename T> auto GetLaneInfo(const RoadId road_id, const SectionId section_id,
                                          const LaneId lane_id, const double s);
};

Import

#include "carla/road/MapData.h"

I/O Contract

Input Type Description
RoadId | Unique road identifier
JuncId | Unique junction identifier
Output Type Description
Road & | Reference to the road object
Junction * | Pointer to the junction object
unordered_map | Map of all traffic signals

Usage Examples

// Access roads from map data
const auto &roads = map_data.GetRoads();
for (const auto &[id, road] : roads) {
  double length = road.GetLength();
}

// Check if a road exists
if (map_data.ContainsRoad(42)) {
  const auto &road = map_data.GetRoad(42);
}

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment