Implementation:CARLA simulator Carla LaneSection
| Knowledge Sources | |
|---|---|
| Domains | Road Network, Simulation |
| Last Updated | 2026-02-15 05:00 GMT |
Overview
The LaneSection class groups lanes at a specific distance range along a road, providing access to the collection of lanes and their properties within that section.
Description
carla::road::LaneSection is a MovableNonCopyable class representing a lane section from the OpenDRIVE specification. A road may have multiple lane sections; each lane section starts at a specific s-coordinate and contains a map of lanes keyed by LaneId.
Key functionality:
- Distance and length --
GetDistance()returns the s-coordinate where the section begins;GetLength()computes the section length as the difference to the next section's start (or the road's total length) - Lane access --
GetLane(id)retrieves a specific lane by ID;GetLanes()returns the full ordered map of lanes - Lane filtering --
GetLanesOfType(type)returns lanes matching a bitmask lane type - Road access --
GetRoad()provides a pointer back to the parent Road
The lane map is ordered by LaneId, where negative IDs are right lanes, 0 is the center lane, and positive IDs are left lanes.
Usage
Use this class when iterating over lanes within a specific section of a road, filtering lanes by type (e.g., finding all drivable lanes), or computing section-level properties.
Code Reference
Source Location
- Repository: CARLA
- Files:
LibCarla/source/carla/road/LaneSection.h,LibCarla/source/carla/road/LaneSection.cpp
Signature
class LaneSection : private MovableNonCopyable {
public:
explicit LaneSection(SectionId id, double s);
double GetDistance() const;
double GetLength() const;
Road *GetRoad() const;
SectionId GetId() const;
Lane *GetLane(const LaneId id);
const Lane *GetLane(const LaneId id) const;
bool ContainsLane(LaneId id) const;
std::map<LaneId, Lane> &GetLanes();
const std::map<LaneId, Lane> &GetLanes() const;
std::vector<Lane *> GetLanesOfType(Lane::LaneType type);
};
Import
#include "carla/road/LaneSection.h"
I/O Contract
| Input | Type | Description |
|---|---|---|
SectionId | Unique section identifier
| ||
double | Start distance of this section along the road
| ||
LaneId | Lane identifier for lookup
| ||
Lane::LaneType | Bitmask type filter for lane queries
|
| Output | Type | Description |
|---|---|---|
Lane * | Pointer to the requested lane, or nullptr
| ||
std::map<LaneId, Lane> | All lanes in this section ordered by ID
| ||
std::vector<Lane *> | Lanes matching the type bitmask
|
Usage Examples
// Get all driving lanes in a section
auto driving_lanes = lane_section.GetLanesOfType(Lane::LaneType::Driving);
// Check if a specific lane exists
if (lane_section.ContainsLane(-1)) {
auto *lane = lane_section.GetLane(-1);
}