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 RoadElementSet

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

Overview

The RoadElementSet template class provides an ordered, distance-indexed collection of road elements with efficient subset and reverse-subset queries.

Description

carla::road::RoadElementSet<T> is a MovableNonCopyable template container that stores elements sorted by their distance (s-coordinate) along a road. It uses a sorted std::vector internally and supports:

  • GetAll() -- returns a const reference to the full sorted vector
  • GetReverseSubset(k) -- returns a reverse view of all elements with distance <= k, useful for finding the most recent record before a given point
  • GetSubsetInRange(min_k, max_k) -- returns a forward view of elements in the range [min_k, max_k]
  • GetReverseSubsetInRange(min_k, max_k) -- returns a reverse view of elements in the range [min_k, max_k]
  • Standard container operations -- empty(), size(), begin(), end()

Distance extraction is handled by overloaded static GetDistance() methods supporting raw doubles, objects with a GetDistance() method, raw pointers, and unique_ptr wrappers. The internal LessComp comparator uses transparent comparison for heterogeneous lookups.

Usage

This is the foundational container used by InformationSet and LaneSectionMap to store distance-ordered road data. It provides the binary-search-based subset queries that make typed road information retrieval efficient.

Code Reference

Source Location

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

Signature

template <typename T>
class RoadElementSet : private MovableNonCopyable {
public:
  using mapped_type = T;
  using key_type = double;

  RoadElementSet() = default;

  template <typename InputTypeT>
  RoadElementSet(std::vector<InputTypeT> &&range);

  const std::vector<mapped_type> &GetAll() const;
  auto GetReverseSubset(const key_type k) const;
  auto GetSubsetInRange(const key_type min_k, const key_type max_k) const;
  auto GetReverseSubsetInRange(const key_type min_k, const key_type max_k) const;

  bool empty() const;
  size_t size() const;
  auto begin() const;
  auto end() const;
};

Import

#include "carla/road/RoadElementSet.h"

I/O Contract

Input Type Description
std::vector<InputTypeT> && | Unsorted elements to sort and store
double | Distance key for subset queries
double | Distance range for range queries
Output Type Description
const std::vector<T> & | Complete sorted element list
ListView | View over matching elements

Usage Examples

// Create a set from unsorted elements
RoadElementSet<std::unique_ptr<RoadInfo>> set(std::move(info_vec));

// Get the most recent record at s=50
auto reverse_view = set.GetReverseSubset(50.0);

// Get all records between s=10 and s=30
auto range_view = set.GetSubsetInRange(10.0, 30.0);

Related Pages

Page Connections

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