CARLA
Loading...
Searching...
No Matches
carla::traffic_manager Namespace Reference

Namespaces

namespace  constants
namespace  PID

Classes

struct  ActuationSignal
 Structure to hold the actuation signals. More...
class  ALSM
 ALSM: Agent Lifecycle and State Managerment This class has functionality to update the local cache of kinematic states and manage memory and cleanup for varying number of vehicles in the simulation. More...
class  AtomicActorSet
class  AtomicMap
class  CachedSimpleWaypoint
struct  ChangeLaneInfo
struct  CollisionHazardData
struct  CollisionLock
class  CollisionStage
 This class has functionality to detect potential collision with a nearby actor. More...
struct  GeometryComparison
class  InMemoryMap
 This class builds a discretized local map-cache. More...
struct  KinematicState
struct  LocalizationData
class  LocalizationStage
 This class has functionality to maintain a horizon of waypoints ahead of the vehicle for it to follow. More...
class  MotionPlanStage
class  Parameters
class  RandomGenerator
class  SimpleWaypoint
 This is a simple wrapper class on Carla's waypoint object. More...
class  SimulationState
 This class holds the state of all the vehicles in the simlation. More...
class  SnippetProfiler
class  Stage
 Stage type interface. More...
struct  StateEntry
 Structure to hold the controller state. More...
struct  StaticAttributes
class  TrackTraffic
class  TrafficLightStage
 This class has functionality for responding to traffic lights and managing entry into non-signalized junctions. More...
struct  TrafficLightState
class  TrafficManager
 This class integrates all the various stages of the traffic manager appropriately using messengers. More...
class  TrafficManagerBase
 The function of this class is to integrate all the various stages of the traffic manager appropriately using messengers. More...
class  TrafficManagerClient
 Provides communication with the rpc of TrafficManagerServer. More...
class  TrafficManagerLocal
 The function of this class is to integrate all the various stages of the traffic manager appropriately using messengers. More...
class  TrafficManagerRemote
 The function of this class is to integrate all the various stages of the traffic manager appropriately using messengers. More...
class  TrafficManagerServer
class  VehicleLightStage
 This class has functionality for turning on/off the vehicle lights according to the current vehicle state and its surrounding environment. More...

Typedefs

using Action = std::pair<RoadOption, WaypointPtr>
using ActionBuffer = std::vector<Action>
using Actor = carla::SharedPtr<cc::Actor>
using ActorId = carla::ActorId
using ActorIdSet = std::unordered_set<ActorId>
using ActorList = carla::SharedPtr<cc::ActorList>
using ActorMap = std::unordered_map<ActorId, ActorPtr>
using ActorPtr = carla::SharedPtr<cc::Actor>
using Box = bg::model::box<Point3D>
using Buffer = std::deque<std::shared_ptr<SimpleWaypoint>>
using BufferMap = std::unordered_map<carla::ActorId, Buffer>
using CollisionFrame = std::vector<CollisionHazardData>
using CollisionLockMap = std::unordered_map<ActorId, CollisionLock>
using ControlFrame = std::vector<carla::rpc::Command>
using GeodesicBoundaryMap = std::unordered_map<ActorId, LocationVector>
using GeoGridId = crd::JuncId
using GeometryComparisonMap = std::unordered_map<uint64_t, GeometryComparison>
using IdleTimeMap = std::unordered_map<ActorId, double>
using Junction = carla::SharedPtr<carla::client::Junction>
using JunctionID = carla::road::JuncId
using KinematicStateMap = std::unordered_map<ActorId, KinematicState>
using LaneChangeSWptMap = std::unordered_map<ActorId, SimpleWaypointPtr>
using LocalizationFrame = std::vector<LocalizationData>
using LocalMapPtr = std::shared_ptr<InMemoryMap>
using LocationVector = std::vector<cg::Location>
using NodeList = std::vector<SimpleWaypointPtr>
using Path = std::vector<cg::Location>
using Point2D = bg::model::point<double, 2, bg::cs::cartesian>
using Point3D = bg::model::point<float, 3, bg::cs::cartesian>
using Polygon = bg::model::polygon<bg::model::d2::point_xy<double>>
using RawNodeList = std::vector<WaypointPtr>
using Route = std::vector<uint8_t>
using Rtree = bgi::rtree<SpatialTreeEntry, bgi::rstar<16>>
using SegmentId = std::tuple<crd::RoadId, crd::LaneId, crd::SectionId>
using SegmentMap = std::map<SegmentId, std::vector<SimpleWaypointPtr>>
using SegmentTopology = std::map<SegmentId, std::pair<std::vector<SegmentId>, std::vector<SegmentId>>>
using SimpleWaypointPtr = std::shared_ptr<SimpleWaypoint>
using SpatialTreeEntry = std::pair<Point3D, SimpleWaypointPtr>
using StaticAttributeMap = std::unordered_map<ActorId, StaticAttributes>
using TargetWPInfo = std::pair<SimpleWaypointPtr,uint64_t>
 Method to return the wayPoints from the waypoint Buffer by using target point distance.
using TimeInstance = chr::time_point<chr::system_clock, chr::nanoseconds>
using TimePoint = chr::time_point<chr::system_clock, chr::nanoseconds>
using TLFrame = std::vector<bool>
using TLGroup = std::vector<carla::SharedPtr<carla::client::TrafficLight>>
using TLMap = std::unordered_map<std::string, SharedPtr<client::Actor>>
using TLS = carla::rpc::TrafficLightState
using TopologyList = std::vector<std::pair<WaypointPtr, WaypointPtr>>
using TrafficLightStateMap = std::unordered_map<ActorId, TrafficLightState>
using WaypointPtr = carla::SharedPtr<cc::Waypoint>
using WorldMap = carla::SharedPtr<const cc::Map>

Enumerations

enum  ActorType { Vehicle , Pedestrian , Any }
enum class  RoadOption : uint8_t {
  Void = 0 , Left = 1 , Right = 2 , Straight = 3 ,
  LaneFollow = 4 , ChangeLaneLeft = 5 , ChangeLaneRight = 6 , RoadEnd = 7
}

Functions

static void AppendReleased (std::vector< ActorPtr > &out, TrafficManagerBase &tm)
float DeviationCrossProduct (const cg::Location &reference_location, const cg::Vector3D &heading_vector, const cg::Location &target_location)
 Returns the cross product (z component value) between the vehicle's heading vector and the vector along the direction to the next target waypoint on the horizon.
float DeviationDotProduct (const cg::Location &reference_location, const cg::Vector3D &heading_vector, const cg::Location &target_location)
 Returns the dot product between the vehicle's heading vector and the vector along the direction to the next target waypoint on the horizon.
float GetPathSpeedLimit (const std::vector< cg::Location > &path, float path_start_offset, float sample_spacing, float lateral_acceleration, float braking_deceleration, float max_speed)
 Lowest sqrt(R * lateral_acceleration + 2 * braking_deceleration * distance) over every three consecutive samples taken at sample_spacing along path.
std::pair< cg::Location, uint64_t > GetTargetData (const Buffer &waypoint_buffer, float target_distance, cg::Location vehicle_location)
 Returns the location reached by walking target_distance along the waypoint buffer from vehicle_location, plus the index of the bracketing waypoint.
TargetWPInfo GetTargetWaypoint (const Buffer &waypoint_buffer, const float &target_point_distance)
float GetThreePointCircleRadius (cg::Location first_location, cg::Location middle_location, cg::Location last_location)
 Returns the radius of the circle defined by three points in the XY plane.
std::pair< cg::Location, uint64_t > InterpolateBufferAt (const std::vector< cg::Location > &waypoint_locations, float target_distance, cg::Location vehicle_location)
 Locations-only variant of GetTargetData.
bool IsOffsetSideOccupied (cg::Location ego_location, cg::Vector3D ego_forward, cg::Vector3D offset_direction, float offset_magnitude, float lateral_clearance, float longitudinal_window, const std::vector< std::pair< cg::Location, float > > &neighbours)
 Returns true when a neighbouring vehicle sits in the lateral band that the wide-turn offset would swing the ego vehicle into.
float LargeVehicleJunctionOffsetProfile (float t, float max_offset, float max_offset_point, float inboard_scale)
 Lateral offset profile for the large-vehicle wide turn, as a function of t, the fraction of the junction still ahead of the target waypoint (1 at the entry, 0 at the exit).
float LargeVehicleOffsetMagnitude (float vehicle_length, float reference_length, float gain, float offset_cap)
 Wide-turn offset magnitude scaled by vehicle length: clamp(gain * (vehicle_length - reference_length), 0, offset_cap).
void PopWaypoint (ActorId actor_id, TrackTraffic &track_traffic, Buffer &buffer, bool front_or_back)
void PushWaypoint (ActorId actor_id, TrackTraffic &track_traffic, Buffer &buffer, SimpleWaypointPtr &waypoint)

Typedef Documentation

◆ Action

Definition at line 23 of file LocalizationStage.h.

◆ ActionBuffer

typedef std::vector< Action > carla::traffic_manager::ActionBuffer = std::vector<Action>

Definition at line 24 of file LocalizationStage.h.

◆ Actor

Definition at line 26 of file LocalizationUtils.h.

◆ ActorId

◆ ActorIdSet

typedef std::unordered_set< ActorId > carla::traffic_manager::ActorIdSet = std::unordered_set<ActorId>

Definition at line 28 of file LocalizationUtils.h.

◆ ActorList

Definition at line 35 of file ALSM.h.

◆ ActorMap

using carla::traffic_manager::ActorMap = std::unordered_map<ActorId, ActorPtr>

Definition at line 36 of file ALSM.h.

◆ ActorPtr

◆ Box

using carla::traffic_manager::Box = bg::model::box<Point3D>

Definition at line 52 of file InMemoryMap.h.

◆ Buffer

typedef std::deque< SimpleWaypointPtr > carla::traffic_manager::Buffer = std::deque<std::shared_ptr<SimpleWaypoint>>

Definition at line 44 of file CollisionStage.h.

◆ BufferMap

typedef std::unordered_map< carla::ActorId, Buffer > carla::traffic_manager::BufferMap = std::unordered_map<carla::ActorId, Buffer>

Definition at line 45 of file CollisionStage.h.

◆ CollisionFrame

Definition at line 54 of file DataStructures.h.

◆ CollisionLockMap

Definition at line 39 of file CollisionStage.h.

◆ ControlFrame

Definition at line 56 of file DataStructures.h.

◆ GeodesicBoundaryMap

Definition at line 47 of file CollisionStage.h.

◆ GeoGridId

Definition at line 48 of file InMemoryMap.h.

◆ GeometryComparisonMap

Definition at line 48 of file CollisionStage.h.

◆ IdleTimeMap

using carla::traffic_manager::IdleTimeMap = std::unordered_map<ActorId, double>

Definition at line 37 of file ALSM.h.

◆ Junction

◆ JunctionID

◆ KinematicStateMap

Definition at line 25 of file SimulationState.h.

◆ LaneChangeSWptMap

Definition at line 21 of file LocalizationStage.h.

◆ LocalizationFrame

Definition at line 47 of file DataStructures.h.

◆ LocalMapPtr

typedef std::shared_ptr< InMemoryMap > carla::traffic_manager::LocalMapPtr = std::shared_ptr<InMemoryMap>

Definition at line 38 of file ALSM.h.

◆ LocationVector

Definition at line 46 of file CollisionStage.h.

◆ NodeList

Definition at line 47 of file InMemoryMap.h.

◆ Path

typedef std::vector< cg::Location > carla::traffic_manager::Path = std::vector<cg::Location>

Definition at line 25 of file LocalizationStage.h.

◆ Point2D

using carla::traffic_manager::Point2D = bg::model::point<double, 2, bg::cs::cartesian>

Definition at line 12 of file CollisionStage.cpp.

◆ Point3D

using carla::traffic_manager::Point3D = bg::model::point<float, 3, bg::cs::cartesian>

Definition at line 51 of file InMemoryMap.h.

◆ Polygon

using carla::traffic_manager::Polygon = bg::model::polygon<bg::model::d2::point_xy<double>>

Definition at line 49 of file CollisionStage.h.

◆ RawNodeList

Definition at line 19 of file InMemoryMap.cpp.

◆ Route

typedef std::vector< uint8_t > carla::traffic_manager::Route = std::vector<uint8_t>

Definition at line 26 of file LocalizationStage.h.

◆ Rtree

using carla::traffic_manager::Rtree = bgi::rtree<SpatialTreeEntry, bgi::rstar<16>>

Definition at line 58 of file InMemoryMap.h.

◆ SegmentId

using carla::traffic_manager::SegmentId = std::tuple<crd::RoadId, crd::LaneId, crd::SectionId>

Definition at line 55 of file InMemoryMap.h.

◆ SegmentMap

Definition at line 57 of file InMemoryMap.h.

◆ SegmentTopology

using carla::traffic_manager::SegmentTopology = std::map<SegmentId, std::pair<std::vector<SegmentId>, std::vector<SegmentId>>>

Definition at line 56 of file InMemoryMap.h.

◆ SimpleWaypointPtr

typedef std::shared_ptr< SimpleWaypoint > carla::traffic_manager::SimpleWaypointPtr = std::shared_ptr<SimpleWaypoint>

Definition at line 12 of file CachedSimpleWaypoint.cpp.

◆ SpatialTreeEntry

Definition at line 53 of file InMemoryMap.h.

◆ StaticAttributeMap

Definition at line 43 of file SimulationState.h.

◆ TargetWPInfo

Method to return the wayPoints from the waypoint Buffer by using target point distance.

Definition at line 56 of file LocalizationUtils.h.

◆ TimeInstance

typedef chr::time_point< chr::system_clock, chr::nanoseconds > carla::traffic_manager::TimeInstance = chr::time_point<chr::system_clock, chr::nanoseconds>

Definition at line 34 of file DataStructures.h.

◆ TimePoint

typedef chr::time_point< chr::system_clock, chr::nanoseconds > carla::traffic_manager::TimePoint = chr::time_point<chr::system_clock, chr::nanoseconds>

Definition at line 18 of file SnippetProfiler.h.

◆ TLFrame

using carla::traffic_manager::TLFrame = std::vector<bool>

Definition at line 58 of file DataStructures.h.

◆ TLGroup

◆ TLMap

using carla::traffic_manager::TLMap = std::unordered_map<std::string, SharedPtr<client::Actor>>

Definition at line 20 of file MotionPlanStage.h.

◆ TLS

◆ TopologyList

Definition at line 18 of file InMemoryMap.cpp.

◆ TrafficLightStateMap

Definition at line 31 of file SimulationState.h.

◆ WaypointPtr

◆ WorldMap

Definition at line 49 of file InMemoryMap.h.

Enumeration Type Documentation

◆ ActorType

Enumerator
Vehicle 
Pedestrian 
Any 

Definition at line 11 of file SimulationState.h.

◆ RoadOption

enum class carla::traffic_manager::RoadOption : uint8_t
strong
Enumerator
Void 
Left 
Right 
Straight 
LaneFollow 
ChangeLaneLeft 
ChangeLaneRight 
RoadEnd 

Definition at line 25 of file SimpleWaypoint.h.

Function Documentation

◆ AppendReleased()

◆ DeviationCrossProduct()

float carla::traffic_manager::DeviationCrossProduct ( const cg::Location & reference_location,
const cg::Vector3D & heading_vector,
const cg::Location & target_location )

Returns the cross product (z component value) between the vehicle's heading vector and the vector along the direction to the next target waypoint on the horizon.

Definition at line 16 of file LocalizationUtils.cpp.

References DeviationCrossProduct(), carla::geom::Vector3D::MakeUnitVector(), carla::geom::Vector3D::x, and carla::geom::Vector3D::y.

Referenced by DeviationCrossProduct().

◆ DeviationDotProduct()

float carla::traffic_manager::DeviationDotProduct ( const cg::Location & reference_location,
const cg::Vector3D & heading_vector,
const cg::Location & target_location )

Returns the dot product between the vehicle's heading vector and the vector along the direction to the next target waypoint on the horizon.

Definition at line 25 of file LocalizationUtils.cpp.

References DeviationDotProduct(), carla::geom::Math::Dot(), carla::geom::Vector3D::MakeUnitVector(), carla::geom::Vector3D::x, carla::geom::Vector3D::y, and carla::geom::Vector3D::z.

Referenced by DeviationDotProduct(), and carla::traffic_manager::LocalizationStage::Update().

◆ GetPathSpeedLimit()

float carla::traffic_manager::GetPathSpeedLimit ( const std::vector< cg::Location > & path,
float path_start_offset,
float sample_spacing,
float lateral_acceleration,
float braking_deceleration,
float max_speed )
nodiscard

Lowest sqrt(R * lateral_acceleration + 2 * braking_deceleration * distance) over every three consecutive samples taken at sample_spacing along path.

path_start_offset is where path.front() sits relative to the vehicle, negative when behind it. Fewer than three points returns max_speed.

Definition at line 130 of file TrafficManagerGeometry.cpp.

References GetPathSpeedLimit(), GetThreePointCircleRadius(), carla::geom::Vector3D::x, carla::geom::Vector3D::y, and carla::geom::Vector3D::z.

Referenced by GetPathSpeedLimit(), and carla::traffic_manager::MotionPlanStage::GetTurnTargetVelocity().

◆ GetTargetData()

std::pair< cg::Location, uint64_t > carla::traffic_manager::GetTargetData ( const Buffer & waypoint_buffer,
float target_distance,
cg::Location vehicle_location )
nodiscard

Returns the location reached by walking target_distance along the waypoint buffer from vehicle_location, plus the index of the bracketing waypoint.

Thin adapter that extracts each waypoint's location and delegates to InterpolateBufferAt.

Definition at line 117 of file TrafficManagerGeometry.cpp.

References GetTargetData(), and InterpolateBufferAt().

Referenced by GetTargetData(), and carla::traffic_manager::MotionPlanStage::Update().

◆ GetTargetWaypoint()

TargetWPInfo carla::traffic_manager::GetTargetWaypoint ( const Buffer & waypoint_buffer,
const float & target_point_distance )

◆ GetThreePointCircleRadius()

float carla::traffic_manager::GetThreePointCircleRadius ( cg::Location first_location,
cg::Location middle_location,
cg::Location last_location )
nodiscard

Returns the radius of the circle defined by three points in the XY plane.

Returns std::numeric_limits<float>::max() when the three points are collinear (no circumscribing circle exists).

Definition at line 22 of file TrafficManagerGeometry.cpp.

References GetThreePointCircleRadius(), carla::geom::Vector3D::x, and carla::geom::Vector3D::y.

Referenced by GetPathSpeedLimit(), GetThreePointCircleRadius(), carla::traffic_manager::LocalizationStage::HandleLargeVehicleJunction(), and carla::traffic_manager::MotionPlanStage::Update().

◆ InterpolateBufferAt()

std::pair< cg::Location, uint64_t > carla::traffic_manager::InterpolateBufferAt ( const std::vector< cg::Location > & waypoint_locations,
float target_distance,
cg::Location vehicle_location )
nodiscard

Locations-only variant of GetTargetData.

Takes a flat list of waypoint locations and walks them to find the bracketing pair around target_distance from vehicle_location, then linearly interpolates. Exposed as a free function so the unit-test suite can exercise it without constructing SimpleWaypoint instances (which require a real carla::client::Waypoint and therefore a road map).

Defensive: an empty list returns {vehicle_location, 0u}; a single-element list returns that element.

Definition at line 50 of file TrafficManagerGeometry.cpp.

References carla::geom::Location::Distance(), carla::geom::Location::DistanceSquared(), InterpolateBufferAt(), carla::geom::Vector3D::x, carla::geom::Vector3D::y, and carla::geom::Vector3D::z.

Referenced by GetTargetData(), and InterpolateBufferAt().

◆ IsOffsetSideOccupied()

bool carla::traffic_manager::IsOffsetSideOccupied ( cg::Location ego_location,
cg::Vector3D ego_forward,
cg::Vector3D offset_direction,
float offset_magnitude,
float lateral_clearance,
float longitudinal_window,
const std::vector< std::pair< cg::Location, float > > & neighbours )
nodiscard

Returns true when a neighbouring vehicle sits in the lateral band that the wide-turn offset would swing the ego vehicle into.

offset_direction is a unit vector pointing to the swing side; ego_forward is the ego heading unit vector. A neighbour counts as blocking when it is on the offset side within offset_magnitude + lateral_clearance (plus its own radius) and roughly alongside the ego within longitudinal_window (plus its radius). Each neighbour is a {location, radius} pair.

Definition at line 223 of file TrafficManagerGeometry.cpp.

References IsOffsetSideOccupied(), carla::geom::Vector3D::x, and carla::geom::Vector3D::y.

Referenced by IsOffsetSideOccupied(), and carla::traffic_manager::MotionPlanStage::IsWideTurnSideOccupied().

◆ LargeVehicleJunctionOffsetProfile()

float carla::traffic_manager::LargeVehicleJunctionOffsetProfile ( float t,
float max_offset,
float max_offset_point,
float inboard_scale )
nodiscard

Lateral offset profile for the large-vehicle wide turn, as a function of t, the fraction of the junction still ahead of the target waypoint (1 at the entry, 0 at the exit).

Returns the unsigned offset in the right-turn convention: positive values are inboard (toward the inside of the turn, the exit "cut-in"), negative values are outboard (the entry swing that opens the turn up). The caller flips the sign for left turns.

The raw profile is a cosine blend that is 0 at both entry and exit. The inboard (positive) lobe is then scaled by inboard_scale in [0, 1] so the cut-in that drives a long vehicle's rear into the inside shoulder can be attenuated (0) or kept (1) independently of the outboard swing.

Definition at line 180 of file TrafficManagerGeometry.cpp.

References LargeVehicleJunctionOffsetProfile().

Referenced by carla::traffic_manager::MotionPlanStage::CalculateBaseOffset(), and LargeVehicleJunctionOffsetProfile().

◆ LargeVehicleOffsetMagnitude()

float carla::traffic_manager::LargeVehicleOffsetMagnitude ( float vehicle_length,
float reference_length,
float gain,
float offset_cap )
nodiscard

Wide-turn offset magnitude scaled by vehicle length: clamp(gain * (vehicle_length - reference_length), 0, offset_cap).

Short vehicles (at or below the reference length) get no offset; longer vehicles ramp up to the cap.

Definition at line 213 of file TrafficManagerGeometry.cpp.

References LargeVehicleOffsetMagnitude().

Referenced by carla::traffic_manager::MotionPlanStage::CalculateBaseOffset(), and LargeVehicleOffsetMagnitude().

◆ PopWaypoint()

◆ PushWaypoint()