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 TM Parameters

From Leeroopedia
Knowledge Sources
Domains Traffic_Management, Autonomous_Driving
Last Updated 2026-02-15 05:00 GMT

Overview

The Parameters class provides a thread-safe, centralized store for all per-vehicle and global configuration parameters used by the Traffic Manager pipeline stages.

Description

The Parameters class manages all configurable behavior of traffic-managed vehicles. It uses AtomicMap (a thread-safe hash map) and std::atomic types to ensure safe concurrent access from the main thread (setting parameters) and worker threads (reading parameters during pipeline execution). The class is organized into setters and getters:

Per-Vehicle Parameters (via AtomicMap):

  • percentage_difference_from_speed_limit: Percentage decrease (or increase if negative) in velocity relative to the road speed limit.
  • exact_desired_speed: An exact target velocity in km/h, mutually exclusive with the percentage-based setting.
  • lane_offset: Lateral offset from the lane center in meters (positive = right, negative = left).
  • distance_to_leading_vehicle: Minimum following distance to the vehicle ahead.
  • force_lane_change: One-shot forced lane change command with direction flag (true = left, false = right).
  • auto_lane_change: Enable/disable automatic lane change behavior.
  • perc_run_traffic_light / perc_run_traffic_sign: Percentage chance of running a red light or stop sign.
  • perc_ignore_walkers / perc_ignore_vehicles: Percentage chance of ignoring collision detection with walkers or vehicles.
  • perc_keep_slow_lane: Percentage chance of moving to the slower lane.
  • perc_random_left / perc_random_right: Percentage chance of random left/right lane change.
  • auto_update_vehicle_lights: Flag to enable automatic vehicle light management.
  • upload_path / custom_path: Custom path (list of locations) import for specific vehicles.
  • upload_route / custom_route: Custom route (list of road options) import for specific vehicles.

Global Parameters (via std::atomic or plain members):

  • global_percentage_difference_from_limit: Global speed percentage applied to all vehicles.
  • global_lane_offset: Global lateral offset applied to all vehicles.
  • synchronous_mode: Toggle synchronous execution mode.
  • synchronous_time_out: Timeout duration for synchronous tick (default 10ms).
  • hybrid_physics_mode: Toggle hybrid physics mode (teleportation for distant vehicles).
  • hybrid_physics_radius: Radius around hero vehicle within which full physics is used (default 70m).
  • respawn_dormant_vehicles: Toggle automatic respawning of dormant vehicles.
  • respawn_lower_bound / respawn_upper_bound: Distance bounds for respawn relative to hero vehicle.
  • osm_mode: Toggle Open Street Map mode.
  • distance_margin: Global distance margin (default 2.0m).

Usage

The Parameters object is created by TrafficManagerLocal and shared (by reference or const reference) with all pipeline stages. User-facing configuration methods on TrafficManager and TrafficManagerRemote ultimately call the setters on this class. Pipeline stages call the getters during their Update methods.

Code Reference

Source Location

  • Repository: CARLA
  • File: LibCarla/source/carla/trafficmanager/Parameters.cpp
  • Header: LibCarla/source/carla/trafficmanager/Parameters.h

Signature

class Parameters {
public:
  Parameters();
  ~Parameters();

  // Setters
  void SetHybridPhysicsMode(const bool mode_switch);
  void SetRespawnDormantVehicles(const bool mode_switch);
  void SetMaxBoundaries(const float lower, const float upper);
  void SetBoundariesRespawnDormantVehicles(const float lower_bound, const float upper_bound);
  void SetPercentageSpeedDifference(const ActorPtr &actor, const float percentage);
  void SetLaneOffset(const ActorPtr &actor, const float offset);
  void SetDesiredSpeed(const ActorPtr &actor, const float value);
  void SetGlobalPercentageSpeedDifference(const float percentage);
  void SetGlobalLaneOffset(const float offset);
  void SetCollisionDetection(const ActorPtr &reference_actor, const ActorPtr &other_actor, const bool detect_collision);
  void SetForceLaneChange(const ActorPtr &actor, const bool direction);
  void SetKeepSlowLanePercentage(const ActorPtr &actor, const float percentage);
  void SetRandomLeftLaneChangePercentage(const ActorPtr &actor, const float percentage);
  void SetRandomRightLaneChangePercentage(const ActorPtr &actor, const float percentage);
  void SetUpdateVehicleLights(const ActorPtr &actor, const bool do_update);
  void SetAutoLaneChange(const ActorPtr &actor, const bool enable);
  void SetDistanceToLeadingVehicle(const ActorPtr &actor, const float distance);
  void SetSynchronousMode(const bool mode_switch);
  void SetSynchronousModeTimeOutInMiliSecond(const double time);
  void SetOSMMode(const bool mode_switch);
  // ... additional setters for paths, routes, percentages

  // Getters
  bool GetHybridPhysicsMode() const;
  bool GetRespawnDormantVehicles() const;
  float GetVehicleTargetVelocity(const ActorId &actor_id, const float speed_limit) const;
  float GetLaneOffset(const ActorId &actor_id) const;
  bool GetCollisionDetection(const ActorId &reference_actor_id, const ActorId &other_actor_id) const;
  ChangeLaneInfo GetForceLaneChange(const ActorId &actor_id);
  float GetKeepSlowLanePercentage(const ActorId &actor_id);
  float GetDistanceToLeadingVehicle(const ActorId &actor_id) const;
  float GetPercentageIgnoreWalkers(const ActorId &actor_id) const;
  float GetPercentageIgnoreVehicles(const ActorId &actor_id) const;
  bool GetSynchronousMode() const;
  bool GetOSMMode() const;
  // ... additional getters
};

Import

#include "carla/trafficmanager/Parameters.h"

I/O Contract

Inputs

Name Type Required Description
actor const ActorPtr& Varies Actor reference for per-vehicle parameter setters
percentage/value/distance float Varies Numeric parameter value for the respective setter
mode_switch/enable bool Varies Boolean toggle for mode switches
direction bool Varies Lane change direction (true = left, false = right)

Outputs

Name Type Description
bool bool Mode flags, collision detection results
float float Velocity targets, percentages, distances, offsets
ChangeLaneInfo struct Lane change command with direction and enabled flag

Usage Examples

// Parameters is created inside TrafficManagerLocal:
Parameters parameters;

// User-facing configuration (via TrafficManager API):
parameters.SetPercentageSpeedDifference(actor, -20.0f); // 20% faster
parameters.SetDesiredSpeed(actor, 30.0f); // exact 30 km/h
parameters.SetDistanceToLeadingVehicle(actor, 5.0f);
parameters.SetAutoLaneChange(actor, true);
parameters.SetHybridPhysicsMode(true);
parameters.SetSynchronousMode(true);

// Pipeline stage reading parameters:
float target_velocity = parameters.GetVehicleTargetVelocity(actor_id, speed_limit);
bool hybrid_mode = parameters.GetHybridPhysicsMode();
ChangeLaneInfo lane_info = parameters.GetForceLaneChange(actor_id);

Related Pages

Page Connections

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