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 Junction

From Leeroopedia
Revision as of 12:13, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/CARLA_simulator_Carla_Junction.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains Road Network, Simulation
Last Updated 2026-02-15 05:00 GMT

Overview

The Junction class represents a road junction (intersection) in the OpenDRIVE road network, storing connections between incoming and connecting roads with lane-level link information.

Description

carla::road::Junction is a MovableNonCopyable class that models an OpenDRIVE junction element. It contains:

  • Connections -- an unordered_map<ConId, Connection> where each Connection specifies an incoming road, a connecting road, and a list of LaneLink pairs (from/to lane IDs)
  • Controllers -- a set of ContId references to signal controllers managing this junction
  • Road conflicts -- an unordered_map<RoadId, unordered_set<RoadId>> mapping each road to the set of roads it conflicts with at this junction
  • Bounding box -- a geom::BoundingBox for spatial queries

The nested Connection struct provides AddLaneLink(from, to) for building the lane-level mapping between incoming and connecting roads.

Usage

Use this class to query junction topology, determine which roads connect through an intersection, resolve lane-level connectivity at intersections, and check for road conflicts.

Code Reference

Source Location

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

Signature

class Junction : private MovableNonCopyable {
public:
  struct LaneLink { LaneId from; LaneId to; };

  struct Connection {
    ConId id;
    RoadId incoming_road;
    RoadId connecting_road;
    std::vector<LaneLink> lane_links;
    void AddLaneLink(LaneId from, LaneId to);
    Connection(ConId id, RoadId incoming_road, RoadId connecting_road);
  };

  Junction(const JuncId id, const std::string name);

  JuncId GetId() const;
  Connection *GetConnection(ConId id);
  std::unordered_map<ConId, Connection> &GetConnections();
  std::unordered_map<ConId, Connection> GetConnections() const;
  carla::geom::BoundingBox GetBoundingBox() const;
  bool RoadHasConflicts(RoadId road_id) const;
  const std::unordered_set<RoadId> &GetConflictsOfRoad(RoadId road_id) const;
  const std::set<ContId> &GetControllers() const;
};

Import

#include "carla/road/Junction.h"

I/O Contract

Input Type Description
JuncId | Junction identifier
ConId | Connection identifier within the junction
RoadId | Road identifier for conflict queries
Output Type Description
Connection * | Pointer to a specific connection, or nullptr
geom::BoundingBox | Spatial bounding box of the junction
unordered_set<RoadId> | Set of conflicting road IDs

Usage Examples

auto *junction = map_data.GetJunction(junc_id);
for (auto &[con_id, connection] : junction->GetConnections()) {
  for (auto &link : connection.lane_links) {
    // Process lane link: link.from -> link.to
  }
}

Related Pages

Page Connections

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