37 namespace traffic_manager {
39 namespace chr = std::chrono;
43 using TimePoint = chr::time_point<chr::system_clock, chr::nanoseconds>;
44 using TLGroup = std::vector<carla::SharedPtr<carla::client::TrafficLight>>;
90 uint64_t current_reserved_capacity {0u};
101 std::atomic<bool> run_traffic_manger{
true};
103 std::atomic<bool> step_begin{
false};
104 std::atomic<bool> step_end{
false};
113 uint64_t seed {
static_cast<uint64_t
>(time(NULL))};
121 bool CheckAllFrozen(
TLGroup tl_to_freeze);
126 std::vector<float> longitudinal_highway_PID_parameters,
127 std::vector<float> lateral_PID_parameters,
128 std::vector<float> lateral_highway_PID_parameters,
129 float perc_decrease_from_limit,
131 uint16_t &RPCportTM);
137 void SetupLocalMap();
155 void RegisterVehicles(
const std::vector<ActorPtr> &actor_list);
158 void UnregisterVehicles(
const std::vector<ActorPtr> &actor_list);
162 void SetPercentageSpeedDifference(
const ActorPtr &actor,
const float percentage);
165 void SetDesiredSpeed(
const ActorPtr &actor,
const float value);
169 void SetGlobalPercentageSpeedDifference(
float const percentage);
173 void SetLaneOffset(
const ActorPtr &actor,
const float offset);
177 void SetGlobalLaneOffset(
float const offset);
180 void SetUpdateVehicleLights(
const ActorPtr &actor,
const bool do_update);
183 void SetCollisionDetection(
const ActorPtr &reference_actor,
const ActorPtr &other_actor,
const bool detect_collision);
187 void SetForceLaneChange(
const ActorPtr &actor,
const bool direction);
190 void SetAutoLaneChange(
const ActorPtr &actor,
const bool enable);
194 void SetDistanceToLeadingVehicle(
const ActorPtr &actor,
const float distance);
197 void SetPercentageIgnoreWalkers(
const ActorPtr &actor,
const float perc);
200 void SetPercentageIgnoreVehicles(
const ActorPtr &actor,
const float perc);
203 void SetPercentageRunningLight(
const ActorPtr &actor,
const float perc);
206 void SetPercentageRunningSign(
const ActorPtr &actor,
const float perc);
209 void SetSynchronousMode(
bool mode);
212 void SetSynchronousModeTimeOutInMiliSecond(
double time);
215 bool SynchronousTick();
221 std::vector<ActorId> GetRegisteredVehiclesIDs();
225 void SetGlobalDistanceToLeadingVehicle(
const float distance);
228 void SetKeepRightPercentage(
const ActorPtr &actor,
const float percentage);
231 void SetRandomLeftLaneChangePercentage(
const ActorPtr &actor,
const float percentage);
234 void SetRandomRightLaneChangePercentage(
const ActorPtr &actor,
const float percentage);
237 void SetHybridPhysicsMode(
const bool mode_switch);
240 void SetHybridPhysicsRadius(
const float radius);
243 void SetRandomDeviceSeed(
const uint64_t _seed);
246 void SetOSMMode(
const bool mode_switch);
249 void SetCustomPath(
const ActorPtr &actor,
const Path path,
const bool empty_buffer);
252 void RemoveUploadPath(
const ActorId &actor_id,
const bool remove_path);
255 void UpdateUploadPath(
const ActorId &actor_id,
const Path path);
258 void SetImportedRoute(
const ActorPtr &actor,
const Route route,
const bool empty_buffer);
261 void RemoveImportedRoute(
const ActorId &actor_id,
const bool remove_path);
264 void UpdateImportedRoute(
const ActorId &actor_id,
const Route route);
267 void SetRespawnDormantVehicles(
const bool mode_switch);
270 void SetBoundariesRespawnDormantVehicles(
const float lower_bound,
const float upper_bound);
273 void SetMaxBoundaries(
const float lower,
const float upper);
CollisionFrame collision_frame
Array to hold output data of collision avoidance.
TrafficManagerServer server
Traffic manager server instance.
std::vector< carla::rpc::Command > ControlFrame
VehicleLightStage vehicle_light_stage
carla::SharedPtr< cc::Actor > ActorPtr
MotionPlanStage motion_plan_stage
std::vector< float > lateral_PID_parameters
std::vector< float > longitudinal_highway_PID_parameters
std::vector< bool > TLFrame
std::vector< float > longitudinal_PID_parameters
PID controller parameters.
chr::time_point< chr::system_clock, chr::nanoseconds > TimePoint
std::condition_variable step_begin_trigger
Condition variables for progressing synchronous execution.
std::vector< cg::Location > Path
std::shared_ptr< InMemoryMap > LocalMapPtr
This class holds the state of all the vehicles in the simlation.
This file contains definitions of common data structures used in traffic manager. ...
std::unordered_map< carla::ActorId, Buffer > BufferMap
ALSM: Agent Lifecycle and State Managerment This class has functionality to update the local cache of...
Parameters parameters
Parameterization object.
std::vector< carla::SharedPtr< carla::client::TrafficLight > > TLGroup
std::pair< RoadOption, WaypointPtr > Action
std::condition_variable step_end_trigger
carla::client::detail::EpisodeProxy episode_proxy
CARLA client connection object.
std::mutex step_execution_mutex
Mutex for progressing synchronous execution.
std::vector< ActorId > marked_for_removal
SimulationState simulation_state
Type containing the current state of all actors involved in the simulation.
cc::World world
CARLA client and object.
AtomicActorSet registered_vehicles
Set of all actors registered with traffic manager.
The function of this class is to integrate all the various stages of the traffic manager appropriatel...
std::vector< uint8_t > Route
This class has functionality for responding to traffic lights and managing entry into non-signalized ...
std::mutex registration_mutex
Mutex to prevent vehicle registration during frame array re-allocation.
std::vector< ActorId > vehicle_id_list
List of vehicles registered with the traffic manager in current update cycle.
TimePoint previous_update_instance
Time instance used to calculate dt in asynchronous mode.
std::vector< float > lateral_highway_PID_parameters
ControlFrame control_frame
Array to hold output data of motion planning.
static const double HYBRID_MODE_DT
BufferMap buffer_map
Structures to hold waypoint buffers for all vehicles.
TrackTraffic track_traffic
Object for tracking paths of the traffic vehicles.
The function of this class is to integrate all the various stages of the traffic manager appropriatel...
std::vector< LocalizationData > LocalizationFrame
TLFrame tl_frame
Array to hold output data of traffic light response.
TrafficLightStage traffic_light_stage
LocalizationFrame localization_frame
Array to hold output data of localization stage.
LocalMapPtr local_map
Pointer to local map cache.
LocalizationStage localization_stage
Various stages representing core operations of traffic manager.
EpisodeProxyImpl< EpisodeProxyPointerType::Strong > EpisodeProxy
int registered_vehicles_state
State counter to track changes in registered actors.
This class has functionality to maintain a horizon of waypoints ahead of the vehicle for it to follow...
std::unique_ptr< std::thread > worker_thread
Single worker thread for sequential execution of sub-components.
std::vector< Action > ActionBuffer
CollisionStage collision_stage
This class has functionality for turning on/off the vehicle lights according to the current vehicle s...
This class has functionality to detect potential collision with a nearby actor.
std::vector< CollisionHazardData > CollisionFrame