CARLA
Constants.h
Go to the documentation of this file.
1 
2 /// This file contains various constants used in traffic manager
3 /// arranged into sensible namespaces for re-usability across
4 /// different files.
5 
6 #pragma once
7 
8 #include <limits>
9 #include <stdint.h>
10 #include <iostream>
11 #include <vector>
12 
13 #define SQUARE(a) ((a) * (a))
14 #define RATE(MaxY, MinY, DiffX) (((MaxY) - (MinY)) / (DiffX))
15 
16 namespace carla {
17 namespace traffic_manager {
18 namespace constants {
19 
20 namespace Networking {
21 static const uint64_t MIN_TRY_COUNT = 20u;
22 static const unsigned short TM_DEFAULT_PORT = 8000u;
23 static const int64_t TM_TIMEOUT = 2000; // ms
24 } // namespace Networking
25 
26 namespace VehicleRemoval {
27 static const float STOPPED_VELOCITY_THRESHOLD = 0.8f;
28 static const double BLOCKED_TIME_THRESHOLD = 90.0;
29 static const double RED_TL_BLOCKED_TIME_THRESHOLD = 180.0;
30 static const double DELTA_TIME_BETWEEN_DESTRUCTIONS = 10.0;
31 } // namespace VehicleRemoval
32 
33 namespace HybridMode {
34 static const float HYBRID_MODE_DT_FL = 0.05f;
35 static const double HYBRID_MODE_DT = 0.05;
36 static const double INV_HYBRID_DT = 1.0 / HYBRID_MODE_DT;
37 static const float PHYSICS_RADIUS = 50.0f;
38 } // namespace HybridMode
39 
40 namespace SpeedThreshold {
41 static const float HIGHWAY_SPEED = 60.0f / 3.6f;
42 static const float AFTER_JUNCTION_MIN_SPEED = 5.0f / 3.6f;
43 static const float INITIAL_PERCENTAGE_SPEED_DIFFERENCE = 0.0f;
44 } // namespace SpeedThreshold
45 
46 namespace PathBufferUpdate {
47 static const float MAX_START_DISTANCE = 20.0f;
48 static const float MINIMUM_HORIZON_LENGTH = 15.0f;
49 static const float HORIZON_RATE = 2.0f;
50 static const float HIGH_SPEED_HORIZON_RATE = 4.0f;
51 } // namespace PathBufferUpdate
52 
53 namespace WaypointSelection {
54 static const float TARGET_WAYPOINT_TIME_HORIZON = 0.3f;
55 static const float MIN_TARGET_WAYPOINT_DISTANCE = 3.0f;
56 static const float JUNCTION_LOOK_AHEAD = 5.0f;
57 static const float SAFE_DISTANCE_AFTER_JUNCTION = 4.0f;
58 static const float MIN_JUNCTION_LENGTH = 8.0f;
60 } // namespace WaypointSelection
61 
62 namespace LaneChange {
63 static const float MINIMUM_LANE_CHANGE_DISTANCE = 20.0f;
64 static const float MAXIMUM_LANE_OBSTACLE_DISTANCE = 50.0f;
65 static const float MAXIMUM_LANE_OBSTACLE_CURVATURE = 0.6f;
66 static const float INTER_LANE_CHANGE_DISTANCE = 10.0f;
67 static const float MIN_WPT_DISTANCE = 5.0f;
68 static const float MAX_WPT_DISTANCE = 20.0f;
69 static const float MIN_LANE_CHANGE_SPEED = 5.0f;
70 static const float FIFTYPERC = 50.0f;
71 } // namespace LaneChange
72 
73 namespace Collision {
74 static const float BOUNDARY_EXTENSION_MINIMUM = 2.5f;
75 static const float BOUNDARY_EXTENSION_RATE = 4.35f;
76 static const float COS_10_DEGREES = 0.9848f;
77 static const float OVERLAP_THRESHOLD = 0.1f;
78 static const float LOCKING_DISTANCE_PADDING = 4.0f;
79 static const float COLLISION_RADIUS_STOP = 8.0f;
80 static const float COLLISION_RADIUS_MIN = 20.0f;
81 static const float COLLISION_RADIUS_RATE = 2.65f;
82 static const float MAX_LOCKING_EXTENSION = 10.0f;
83 static const float WALKER_TIME_EXTENSION = 1.5f;
84 static const float SQUARE_ROOT_OF_TWO = 1.414f;
85 static const float VERTICAL_OVERLAP_THRESHOLD = 4.0f;
86 static const float EPSILON = 2.0f * std::numeric_limits<float>::epsilon();
87 static const float MIN_REFERENCE_DISTANCE = 0.5f;
88 static const float MIN_VELOCITY_COLL_RADIUS = 2.0f;
89 static const float VEL_EXT_FACTOR = 0.36f;
90 } // namespace Collision
91 
92 namespace FrameMemory {
93 static const uint64_t INITIAL_SIZE = 50u;
94 static const uint64_t GROWTH_STEP_SIZE = 50u;
95 static const float INV_GROWTH_STEP_SIZE = 1.0f / static_cast<float>(GROWTH_STEP_SIZE);
96 } // namespace FrameMemory
97 
98 namespace Map {
99 static const float INFINITE_DISTANCE = std::numeric_limits<float>::max();
100 static const float MAX_GEODESIC_GRID_LENGTH = 20.0f;
101 static const float MAP_RESOLUTION = 5.0f;
102 static const float INV_MAP_RESOLUTION = 1.0f / MAP_RESOLUTION;
103 static const double MAX_WPT_DISTANCE = MAP_RESOLUTION/2.0 + SQUARE(MAP_RESOLUTION);
104 static const float MAX_WPT_RADIANS = 0.087f; // 5º
105 static float const DELTA = 25.0f;
106 static float const Z_DELTA = 500.0f;
107 static float const STRAIGHT_DEG = 19.0f;
108 static const double MIN_LANE_WIDTH = 1.0f;
109 } // namespace Map
110 
111 namespace TrafficLight {
112 static const double MINIMUM_STOP_TIME = 2.0;
113 static const double EXIT_JUNCTION_THRESHOLD = 0; // Dot product of 90º
114 } // namespace TrafficLight
115 
116 namespace MotionPlan {
117 static const float RELATIVE_APPROACH_SPEED = 12.0f / 3.6f;
118 static const float MIN_FOLLOW_LEAD_DISTANCE = 2.0f;
119 static const float CRITICAL_BRAKING_MARGIN = 0.2f;
120 static const float EPSILON_RELATIVE_SPEED = 0.001f;
122 static const float TWO_KM = 2000.0f;
123 static const uint16_t ATTEMPTS_TO_TELEPORT = 5u;
124 static const float LANDMARK_DETECTION_TIME = 3.5f;
125 static const float TL_TARGET_VELOCITY = 15.0f / 3.6f;
126 static const float STOP_TARGET_VELOCITY = 10.0f / 3.6f;
127 static const float YIELD_TARGET_VELOCITY = 10.0f / 3.6f;
128 static const float FRICTION = 0.6f;
129 static const float GRAVITY = 9.81f;
130 static const float PI = 3.1415927f;
131 static const float PERC_MAX_SLOWDOWN = 0.08f;
132 static const float FOLLOW_LEAD_FACTOR = 2.0f;
133 } // namespace MotionPlan
134 
135 namespace VehicleLight {
136 static const float SUN_ALTITUDE_DEGREES_BEFORE_DAWN = 15.0f;
137 static const float SUN_ALTITUDE_DEGREES_AFTER_SUNSET = 165.0f;
138 static const float SUN_ALTITUDE_DEGREES_JUST_AFTER_DAWN = 35.0f;
139 static const float SUN_ALTITUDE_DEGREES_JUST_BEFORE_SUNSET = 145.0f;
140 static const float HEAVY_PRECIPITATION_THRESHOLD = 80.0f;
141 static const float FOG_DENSITY_THRESHOLD = 20.0f;
142 static const float MAX_DISTANCE_LIGHT_CHECK = 225.0f;
143 } // namespace VehicleLight
144 
145 namespace PID {
146 static const float MAX_THROTTLE = 0.85f;
147 static const float MAX_BRAKE = 0.7f;
148 static const float MAX_STEERING = 0.8f;
149 static const float MAX_STEERING_DIFF = 0.15f;
150 static const float DT = 0.05f;
151 static const float INV_DT = 1.0f / DT;
152 static const std::vector<float> LONGITUDIAL_PARAM = {12.0f, 0.05f, 0.02f};
153 static const std::vector<float> LONGITUDIAL_HIGHWAY_PARAM = {20.0f, 0.05f, 0.01f};
154 static const std::vector<float> LATERAL_PARAM = {4.0f, 0.02f, 0.08f};
155 static const std::vector<float> LATERAL_HIGHWAY_PARAM = {2.0f, 0.02f, 0.04f};
156 } // namespace PID
157 
158 namespace TrackTraffic {
159 static const uint64_t BUFFER_STEP_THROUGH = 5;
160 static const float INV_BUFFER_STEP_THROUGH = 1.0f / static_cast<float>(BUFFER_STEP_THROUGH);
161 } // namespace TrackTraffic
162 
163 } // namespace constants
164 } // namespace traffic_manager
165 } // namespace carla
static const float SUN_ALTITUDE_DEGREES_JUST_AFTER_DAWN
Definition: Constants.h:138
static const std::vector< float > LATERAL_HIGHWAY_PARAM
Definition: Constants.h:155
static const float MAXIMUM_LANE_OBSTACLE_DISTANCE
Definition: Constants.h:64
static const float MAXIMUM_LANE_OBSTACLE_CURVATURE
Definition: Constants.h:65
static const unsigned short TM_DEFAULT_PORT
Definition: Constants.h:22
static const std::vector< float > LATERAL_PARAM
Definition: Constants.h:154
This file contains definitions of common data structures used in traffic manager. ...
Definition: Carla.cpp:133
static const float MAX_STEERING_DIFF
Definition: Constants.h:149
static const double MIN_LANE_WIDTH
Definition: Constants.h:108
static const float INFINITE_DISTANCE
Definition: Constants.h:99
static const double MAX_WPT_DISTANCE
Definition: Constants.h:103
#define SQUARE(a)
This file contains various constants used in traffic manager arranged into sensible namespaces for re...
Definition: Constants.h:13
static const float MAX_GEODESIC_GRID_LENGTH
Definition: Constants.h:100
static const std::vector< float > LONGITUDIAL_HIGHWAY_PARAM
Definition: Constants.h:153
static const std::vector< float > LONGITUDIAL_PARAM
Definition: Constants.h:152
static const float SUN_ALTITUDE_DEGREES_JUST_BEFORE_SUNSET
Definition: Constants.h:139
static const float INV_MAP_RESOLUTION
Definition: Constants.h:102