This class integrates all the various stages of the traffic manager appropriately using messengers. More...
#include <TrafficManager.h>
Public Member Functions | |
ActionBuffer | GetActionBuffer (const ActorId &actor_id) |
Method to get the action buffer. More... | |
Action | GetNextAction (const ActorId &actor_id) |
Method to get the next action. More... | |
bool | IsValidPort () const |
TrafficManager & | operator= (const TrafficManager &)=default |
TrafficManager & | operator= (TrafficManager &&)=default |
uint16_t | Port () const |
void | RegisterVehicles (const std::vector< ActorPtr > &actor_list) |
This method registers a vehicle with the traffic manager. More... | |
void | RemoveImportedRoute (const ActorId &actor_id, const bool remove_path) |
Method to remove a route. More... | |
void | RemoveUploadPath (const ActorId &actor_id, const bool remove_path) |
Method to remove a path. More... | |
void | SetAutoLaneChange (const ActorPtr &actor, const bool enable) |
Enable/disable automatic lane change on a vehicle. More... | |
void | SetBoundariesRespawnDormantVehicles (const float lower_bound, const float upper_bound) |
Method to set boundaries for respawning vehicles. More... | |
void | SetCollisionDetection (const ActorPtr &reference_actor, const ActorPtr &other_actor, const bool detect_collision) |
Method to set collision detection rules between vehicles. More... | |
void | SetCustomPath (const ActorPtr &actor, const Path path, const bool empty_buffer) |
Method to set our own imported path. More... | |
void | SetDesiredSpeed (const ActorPtr &actor, const float value) |
Set a vehicle's exact desired velocity. More... | |
void | SetDistanceToLeadingVehicle (const ActorPtr &actor, const float distance) |
Method to specify how much distance a vehicle should maintain to the leading vehicle. More... | |
void | SetForceLaneChange (const ActorPtr &actor, const bool direction) |
Method to force lane change on a vehicle. More... | |
void | SetGlobalDistanceToLeadingVehicle (const float distance) |
Method to Set Global distance to Leading vehicle. More... | |
void | SetGlobalLaneOffset (float const offset) |
Method to set a global lane offset displacement from the center line. More... | |
void | SetGlobalPercentageSpeedDifference (float const percentage) |
Set a global % decrease in velocity with respect to the speed limit. More... | |
void | SetHybridPhysicsMode (const bool mode_switch) |
This method sets the hybrid physics mode. More... | |
void | SetHybridPhysicsRadius (const float radius) |
This method sets the hybrid physics radius. More... | |
void | SetImportedRoute (const ActorPtr &actor, const Route route, const bool empty_buffer) |
Method to set our own imported route. More... | |
void | SetKeepRightPercentage (const ActorPtr &actor, const float percentage) |
Method to set % to keep on the right lane. More... | |
void | SetLaneOffset (const ActorPtr &actor, const float offset) |
Method to set a lane offset displacement from the center line. More... | |
void | SetMaxBoundaries (const float lower, const float upper) |
Method to set boundaries for respawning vehicles. More... | |
void | SetOSMMode (const bool mode_switch) |
Method to set Open Street Map mode. More... | |
void | SetPercentageIgnoreVehicles (const ActorPtr &actor, const float perc) |
Method to specify the % chance of ignoring collisions with any vehicle. More... | |
void | SetPercentageIgnoreWalkers (const ActorPtr &actor, const float perc) |
Method to specify the % chance of ignoring collisions with any walker. More... | |
void | SetPercentageRunningLight (const ActorPtr &actor, const float perc) |
Method to specify the % chance of running a light. More... | |
void | SetPercentageRunningSign (const ActorPtr &actor, const float perc) |
Method to specify the % chance of running a sign. More... | |
void | SetPercentageSpeedDifference (const ActorPtr &actor, const float percentage) |
Set a vehicle's % decrease in velocity with respect to the speed limit. More... | |
void | SetRandomDeviceSeed (const uint64_t seed) |
Method to set randomization seed. More... | |
void | SetRandomLeftLaneChangePercentage (const ActorPtr &actor, const float percentage) |
Method to set % to randomly do a left lane change. More... | |
void | SetRandomRightLaneChangePercentage (const ActorPtr &actor, const float percentage) |
Method to set % to randomly do a right lane change. More... | |
void | SetRespawnDormantVehicles (const bool mode_switch) |
Method to set if we are automatically respawning vehicles. More... | |
void | SetSynchronousMode (bool mode) |
Method to switch traffic manager into synchronous execution. More... | |
void | SetSynchronousModeTimeOutInMiliSecond (double time) |
Method to set tick timeout for synchronous execution. More... | |
void | SetUpdateVehicleLights (const ActorPtr &actor, const bool do_update) |
Set the automatic management of the vehicle lights. More... | |
void | ShutDown () |
bool | SynchronousTick () |
Method to provide synchronous tick. More... | |
TrafficManager (carla::client::detail::EpisodeProxy episode_proxy, uint16_t port=TM_DEFAULT_PORT) | |
Public constructor for singleton life cycle management. More... | |
TrafficManager (const TrafficManager &other) | |
TrafficManager () | |
TrafficManager (TrafficManager &&)=default | |
void | UnregisterVehicles (const std::vector< ActorPtr > &actor_list) |
This method unregisters a vehicle from traffic manager. More... | |
void | UpdateImportedRoute (const ActorId &actor_id, const Route route) |
Method to update an already set route. More... | |
void | UpdateUploadPath (const ActorId &actor_id, const Path path) |
Method to update an already set path. More... | |
Static Public Member Functions | |
static void | Release () |
static void | Reset () |
static void | Tick () |
Private Member Functions | |
bool | CreateTrafficManagerClient (carla::client::detail::EpisodeProxy episode_proxy, uint16_t port) |
void | CreateTrafficManagerServer (carla::client::detail::EpisodeProxy episode_proxy, uint16_t port) |
TrafficManagerBase * | GetTM (uint16_t port) const |
Private Attributes | |
uint16_t | _port = 0 |
Static Private Attributes | |
static std::mutex | _mutex |
static std::map< uint16_t, TrafficManagerBase * > | _tm_map |
This class integrates all the various stages of the traffic manager appropriately using messengers.
Definition at line 26 of file TrafficManager.h.
|
explicit |
Public constructor for singleton life cycle management.
Definition at line 31 of file TrafficManager.cpp.
References _port, CreateTrafficManagerClient(), CreateTrafficManagerServer(), and GetTM().
|
inline |
Definition at line 34 of file TrafficManager.h.
References _port.
|
inline |
Definition at line 38 of file TrafficManager.h.
References operator=(), Release(), Reset(), and Tick().
|
default |
|
private |
Get TM server info (Remote IP & PORT)
Set remote TM server IP and port
Try to connect to remote TM server
Check memory allocated or not
Try to reset all traffic lights
Set the pointer of the instance
If Connection error occurred
Clear previously allocated memory
Definition at line 176 of file TrafficManager.cpp.
References _tm_map, carla::traffic_manager::TrafficManagerRemote::HealthCheckRemoteTM(), and carla::client::detail::EpisodeProxyImpl< PointerT >::Lock().
Referenced by GetActionBuffer(), and TrafficManager().
|
private |
Define local constants
Create local instance of TM
Get TM server info (Local IP & PORT)
Set this client as the TM to server
Set the pointer of the instance
Definition at line 82 of file TrafficManager.cpp.
References _tm_map, carla::traffic_manager::constants::SpeedThreshold::INITIAL_PERCENTAGE_SPEED_DIFFERENCE, IP_DATA_BUFFER_SIZE, carla::traffic_manager::constants::PID::LATERAL_HIGHWAY_PARAM, carla::traffic_manager::constants::PID::LATERAL_PARAM, carla::client::detail::EpisodeProxyImpl< PointerT >::Lock(), carla::traffic_manager::constants::PID::LONGITUDIAL_HIGHWAY_PARAM, carla::traffic_manager::constants::PID::LONGITUDIAL_PARAM, and SOCK_INVALID_INDEX.
Referenced by GetActionBuffer(), and TrafficManager().
|
inline |
Method to get the action buffer.
Definition at line 368 of file TrafficManager.h.
References _port, CreateTrafficManagerClient(), CreateTrafficManagerServer(), carla::traffic_manager::TrafficManagerBase::GetActionBuffer(), and GetTM().
Method to get the next action.
Definition at line 357 of file TrafficManager.h.
References _port, carla::traffic_manager::TrafficManagerBase::GetNextAction(), and GetTM().
|
inlineprivate |
Definition at line 389 of file TrafficManager.h.
References _mutex, and _tm_map.
Referenced by GetActionBuffer(), GetNextAction(), RegisterVehicles(), RemoveImportedRoute(), RemoveUploadPath(), SetAutoLaneChange(), SetBoundariesRespawnDormantVehicles(), SetCollisionDetection(), SetCustomPath(), SetDesiredSpeed(), SetDistanceToLeadingVehicle(), SetForceLaneChange(), SetGlobalDistanceToLeadingVehicle(), SetGlobalLaneOffset(), SetGlobalPercentageSpeedDifference(), SetHybridPhysicsMode(), SetHybridPhysicsRadius(), SetImportedRoute(), SetKeepRightPercentage(), SetLaneOffset(), SetMaxBoundaries(), SetOSMMode(), SetPercentageIgnoreVehicles(), SetPercentageIgnoreWalkers(), SetPercentageRunningLight(), SetPercentageRunningSign(), SetPercentageSpeedDifference(), SetRandomDeviceSeed(), SetRandomLeftLaneChangePercentage(), SetRandomRightLaneChangePercentage(), SetRespawnDormantVehicles(), SetSynchronousMode(), SetSynchronousModeTimeOutInMiliSecond(), SetUpdateVehicleLights(), ShutDown(), SynchronousTick(), TrafficManager(), UnregisterVehicles(), UpdateImportedRoute(), and UpdateUploadPath().
|
inline |
Definition at line 55 of file TrafficManager.h.
References _port.
|
default |
|
default |
|
inline |
Definition at line 51 of file TrafficManager.h.
References _port.
|
inline |
This method registers a vehicle with the traffic manager.
Definition at line 156 of file TrafficManager.h.
References _port, GetTM(), and carla::traffic_manager::TrafficManagerBase::RegisterVehicles().
Referenced by carla::client::Vehicle::SetAutopilot().
|
static |
Definition at line 45 of file TrafficManager.cpp.
References _mutex, and _tm_map.
Referenced by carla::client::detail::Episode::OnEpisodeStarted(), and TrafficManager().
|
inline |
Method to remove a route.
Definition at line 101 of file TrafficManager.h.
References _port, GetTM(), and carla::traffic_manager::TrafficManagerBase::RemoveImportedRoute().
|
inline |
Method to remove a path.
Definition at line 77 of file TrafficManager.h.
References _port, GetTM(), and carla::traffic_manager::TrafficManagerBase::RemoveUploadPath().
|
static |
Definition at line 55 of file TrafficManager.cpp.
References _mutex, and _tm_map.
Referenced by carla::client::detail::Episode::OnEpisodeChanged(), and TrafficManager().
|
inline |
Enable/disable automatic lane change on a vehicle.
Definition at line 241 of file TrafficManager.h.
References _port, GetTM(), and carla::traffic_manager::TrafficManagerBase::SetAutoLaneChange().
|
inline |
Method to set boundaries for respawning vehicles.
Definition at line 124 of file TrafficManager.h.
References _port, GetTM(), and carla::traffic_manager::TrafficManagerBase::SetBoundariesRespawnDormantVehicles().
|
inline |
Method to set collision detection rules between vehicles.
Definition at line 224 of file TrafficManager.h.
References _port, GetTM(), and carla::traffic_manager::TrafficManagerBase::SetCollisionDetection().
|
inline |
Method to set our own imported path.
Definition at line 69 of file TrafficManager.h.
References _port, GetTM(), and carla::traffic_manager::TrafficManagerBase::SetCustomPath().
|
inline |
Set a vehicle's exact desired velocity.
Definition at line 190 of file TrafficManager.h.
References _port, GetTM(), and carla::traffic_manager::TrafficManagerBase::SetDesiredSpeed().
|
inline |
Method to specify how much distance a vehicle should maintain to the leading vehicle.
Definition at line 250 of file TrafficManager.h.
References _port, GetTM(), and carla::traffic_manager::TrafficManagerBase::SetDistanceToLeadingVehicle().
|
inline |
Method to force lane change on a vehicle.
Direction flag can be set to true for left and false for right.
Definition at line 233 of file TrafficManager.h.
References _port, GetTM(), and carla::traffic_manager::TrafficManagerBase::SetForceLaneChange().
|
inline |
Method to Set Global distance to Leading vehicle.
Definition at line 315 of file TrafficManager.h.
References _port, GetTM(), and carla::traffic_manager::TrafficManagerBase::SetGlobalDistanceToLeadingVehicle().
|
inline |
Method to set a global lane offset displacement from the center line.
Positive values imply a right offset while negative ones mean a left one.
Definition at line 208 of file TrafficManager.h.
References _port, GetTM(), and carla::traffic_manager::TrafficManagerBase::SetGlobalLaneOffset().
|
inline |
Set a global % decrease in velocity with respect to the speed limit.
If less than 0, it's a % increase.
Definition at line 199 of file TrafficManager.h.
References _port, GetTM(), and carla::traffic_manager::TrafficManagerBase::SetGlobalPercentageSpeedDifference().
|
inline |
This method sets the hybrid physics mode.
Definition at line 140 of file TrafficManager.h.
References _port, GetTM(), and carla::traffic_manager::TrafficManagerBase::SetHybridPhysicsMode().
|
inline |
This method sets the hybrid physics radius.
Definition at line 148 of file TrafficManager.h.
References _port, GetTM(), and carla::traffic_manager::TrafficManagerBase::SetHybridPhysicsRadius().
|
inline |
Method to set our own imported route.
Definition at line 93 of file TrafficManager.h.
References _port, GetTM(), and carla::traffic_manager::TrafficManagerBase::SetImportedRoute().
|
inline |
Method to set % to keep on the right lane.
Definition at line 323 of file TrafficManager.h.
References _port, GetTM(), and carla::traffic_manager::TrafficManagerBase::SetKeepRightPercentage().
|
inline |
Method to set a lane offset displacement from the center line.
Positive values imply a right offset while negative ones mean a left one.
Definition at line 182 of file TrafficManager.h.
References _port, GetTM(), and carla::traffic_manager::TrafficManagerBase::SetLaneOffset().
|
inline |
Method to set boundaries for respawning vehicles.
Definition at line 132 of file TrafficManager.h.
References _port, GetTM(), and carla::traffic_manager::TrafficManagerBase::SetMaxBoundaries().
|
inline |
Method to set Open Street Map mode.
Definition at line 61 of file TrafficManager.h.
References _port, GetTM(), and carla::traffic_manager::TrafficManagerBase::SetOSMMode().
|
inline |
Method to specify the % chance of ignoring collisions with any vehicle.
Definition at line 266 of file TrafficManager.h.
References _port, GetTM(), and carla::traffic_manager::TrafficManagerBase::SetPercentageIgnoreVehicles().
|
inline |
Method to specify the % chance of ignoring collisions with any walker.
Definition at line 258 of file TrafficManager.h.
References _port, GetTM(), and carla::traffic_manager::TrafficManagerBase::SetPercentageIgnoreWalkers().
|
inline |
Method to specify the % chance of running a light.
Definition at line 282 of file TrafficManager.h.
References _port, GetTM(), and carla::traffic_manager::TrafficManagerBase::SetPercentageRunningLight().
|
inline |
Method to specify the % chance of running a sign.
Definition at line 274 of file TrafficManager.h.
References _port, GetTM(), and carla::traffic_manager::TrafficManagerBase::SetPercentageRunningSign().
|
inline |
Set a vehicle's % decrease in velocity with respect to the speed limit.
If less than 0, it's a % increase.
Definition at line 173 of file TrafficManager.h.
References _port, GetTM(), and carla::traffic_manager::TrafficManagerBase::SetPercentageSpeedDifference().
|
inline |
Method to set randomization seed.
Definition at line 347 of file TrafficManager.h.
References _port, GetTM(), carla::traffic_manager::TrafficManagerBase::SetRandomDeviceSeed(), and ShutDown().
|
inline |
Method to set % to randomly do a left lane change.
Definition at line 331 of file TrafficManager.h.
References _port, GetTM(), and carla::traffic_manager::TrafficManagerBase::SetRandomLeftLaneChangePercentage().
|
inline |
Method to set % to randomly do a right lane change.
Definition at line 339 of file TrafficManager.h.
References _port, GetTM(), and carla::traffic_manager::TrafficManagerBase::SetRandomRightLaneChangePercentage().
|
inline |
Method to set if we are automatically respawning vehicles.
Definition at line 117 of file TrafficManager.h.
References _port, GetTM(), and carla::traffic_manager::TrafficManagerBase::SetRespawnDormantVehicles().
|
inline |
Method to switch traffic manager into synchronous execution.
Definition at line 290 of file TrafficManager.h.
References _port, GetTM(), and carla::traffic_manager::TrafficManagerBase::SetSynchronousMode().
|
inline |
Method to set tick timeout for synchronous execution.
Definition at line 298 of file TrafficManager.h.
References _port, GetTM(), and carla::traffic_manager::TrafficManagerBase::SetSynchronousModeTimeOutInMiliSecond().
|
inline |
Set the automatic management of the vehicle lights.
Definition at line 216 of file TrafficManager.h.
References _port, GetTM(), and carla::traffic_manager::TrafficManagerBase::SetUpdateVehicleLights().
void carla::traffic_manager::TrafficManager::ShutDown | ( | ) |
Definition at line 69 of file TrafficManager.cpp.
References _mutex, _port, _tm_map, GetTM(), and carla::traffic_manager::TrafficManagerBase::ShutDown().
Referenced by SetRandomDeviceSeed().
|
inline |
Method to provide synchronous tick.
Definition at line 306 of file TrafficManager.h.
References _port, GetTM(), and carla::traffic_manager::TrafficManagerBase::SynchronousTick().
|
static |
Definition at line 62 of file TrafficManager.cpp.
References _mutex, and _tm_map.
Referenced by carla::client::detail::SynchronizeFrame(), and TrafficManager().
|
inline |
This method unregisters a vehicle from traffic manager.
Definition at line 164 of file TrafficManager.h.
References _port, GetTM(), and carla::traffic_manager::TrafficManagerBase::UnregisterVehicles().
Referenced by carla::client::Vehicle::SetAutopilot().
|
inline |
Method to update an already set route.
Definition at line 109 of file TrafficManager.h.
References _port, GetTM(), and carla::traffic_manager::TrafficManagerBase::UpdateImportedRoute().
|
inline |
Method to update an already set path.
Definition at line 85 of file TrafficManager.h.
References _port, GetTM(), and carla::traffic_manager::TrafficManagerBase::UpdateUploadPath().
|
staticprivate |
Definition at line 399 of file TrafficManager.h.
Referenced by GetTM(), Release(), Reset(), ShutDown(), and Tick().
|
private |
Definition at line 401 of file TrafficManager.h.
Referenced by GetActionBuffer(), GetNextAction(), IsValidPort(), Port(), RegisterVehicles(), RemoveImportedRoute(), RemoveUploadPath(), SetAutoLaneChange(), SetBoundariesRespawnDormantVehicles(), SetCollisionDetection(), SetCustomPath(), SetDesiredSpeed(), SetDistanceToLeadingVehicle(), SetForceLaneChange(), SetGlobalDistanceToLeadingVehicle(), SetGlobalLaneOffset(), SetGlobalPercentageSpeedDifference(), SetHybridPhysicsMode(), SetHybridPhysicsRadius(), SetImportedRoute(), SetKeepRightPercentage(), SetLaneOffset(), SetMaxBoundaries(), SetOSMMode(), SetPercentageIgnoreVehicles(), SetPercentageIgnoreWalkers(), SetPercentageRunningLight(), SetPercentageRunningSign(), SetPercentageSpeedDifference(), SetRandomDeviceSeed(), SetRandomLeftLaneChangePercentage(), SetRandomRightLaneChangePercentage(), SetRespawnDormantVehicles(), SetSynchronousMode(), SetSynchronousModeTimeOutInMiliSecond(), SetUpdateVehicleLights(), ShutDown(), SynchronousTick(), TrafficManager(), UnregisterVehicles(), UpdateImportedRoute(), and UpdateUploadPath().
|
staticprivate |
Definition at line 398 of file TrafficManager.h.
Referenced by CreateTrafficManagerClient(), CreateTrafficManagerServer(), GetTM(), Release(), Reset(), ShutDown(), and Tick().