21using constants::Networking::TM_DEFAULT_PORT;
23using ActorPtr = carla::SharedPtr<carla::client::Actor>;
33 uint16_t port = TM_DEFAULT_PORT);
48 static void Reset(uint64_t episode_id);
51 static void RequestReset(uint64_t episode_id, std::function<
void()> on_done);
61 return (
_port > 1023);
67 if (tm_ptr !=
nullptr) {
75 if (tm_ptr !=
nullptr) {
83 if (tm_ptr !=
nullptr) {
91 if (tm_ptr !=
nullptr) {
99 if (tm_ptr !=
nullptr) {
107 if (tm_ptr !=
nullptr) {
115 if (tm_ptr !=
nullptr) {
123 if(tm_ptr !=
nullptr){
131 if(tm_ptr !=
nullptr){
139 if(tm_ptr !=
nullptr){
147 if(tm_ptr !=
nullptr){
156 if(tm_ptr !=
nullptr){
165 if(tm_ptr !=
nullptr){
173 if(tm_ptr !=
nullptr){
182 if(tm_ptr !=
nullptr){
191 if(tm_ptr !=
nullptr){
199 if(tm_ptr !=
nullptr){
207 if(tm_ptr !=
nullptr){
215 if(tm_ptr !=
nullptr){
223 if(tm_ptr !=
nullptr){
232 if(tm_ptr !=
nullptr){
240 if(tm_ptr !=
nullptr){
249 if(tm_ptr !=
nullptr){
257 if(tm_ptr !=
nullptr){
265 if(tm_ptr !=
nullptr){
273 if(tm_ptr !=
nullptr){
281 if(tm_ptr !=
nullptr){
289 std::scoped_lock<std::mutex> lock(
_mutex);
292 it->second->SetSynchronousMode(mode);
299 if(tm_ptr !=
nullptr){
307 if(tm_ptr !=
nullptr){
316 if(tm_ptr !=
nullptr){
324 if(tm_ptr !=
nullptr){
332 if(tm_ptr !=
nullptr){
340 if(tm_ptr !=
nullptr){
348 if(tm_ptr !=
nullptr){
359 if (tm_ptr !=
nullptr) {
370 if (tm_ptr !=
nullptr) {
372 return action_buffer;
374 return action_buffer;
389 std::scoped_lock<std::mutex> lock(
_mutex);
397 static std::map<uint16_t, TrafficManagerBase*>
_tm_map;
The function of this class is to integrate all the various stages of the traffic manager appropriatel...
virtual void SetKeepSlowLanePercentage(const ActorPtr &actor, const float percentage)=0
Method to set % to keep on the slow lane.
virtual void SetRandomDeviceSeed(const uint64_t seed)=0
Method to set randomization seed.
virtual void SetRandomLeftLaneChangePercentage(const ActorPtr &actor, const float percentage)=0
Method to set % to randomly do a left lane change.
virtual void SetPercentageIgnoreWalkers(const ActorPtr &actor, const float perc)=0
Method to specify the % chance of ignoring collisions with any walker.
virtual void SetPercentageRunningSign(const ActorPtr &actor, const float perc)=0
Method to specify the % chance of running any traffic sign.
virtual void SetPercentageSpeedDifference(const ActorPtr &actor, const float percentage)=0
Set a vehicle's % decrease in velocity with respect to the speed limit.
virtual void UpdateImportedRoute(const ActorId &actor_id, const Route route)=0
Method to update an already set route.
virtual bool SynchronousTick()=0
Method to provide synchronous tick.
virtual void SetGlobalLaneOffset(float const offset)=0
Method to set a global lane offset displacement from the center line.
virtual void SetAutoLaneChange(const ActorPtr &actor, const bool enable)=0
Enable/disable automatic lane change on a vehicle.
virtual void SetCollisionDetection(const ActorPtr &reference_actor, const ActorPtr &other_actor, const bool detect_collision)=0
Method to set collision detection rules between vehicles.
virtual void RegisterVehicles(const std::vector< ActorPtr > &actor_list)=0
This method registers a vehicle with the traffic manager.
virtual void SetOSMMode(const bool mode_switch)=0
Method to set Open Street Map mode.
virtual void SetPercentageIgnoreVehicles(const ActorPtr &actor, const float perc)=0
Method to specify the % chance of ignoring collisions with any vehicle.
virtual Action GetNextAction(const ActorId &actor_id)=0
Method to get the vehicle's next action.
virtual void SetHybridPhysicsRadius(const float radius)=0
Method to set hybrid physics radius.
virtual void SetForceLaneChange(const ActorPtr &actor, const bool direction)=0
Method to force lane change on a vehicle.
virtual ActionBuffer GetActionBuffer(const ActorId &actor_id)=0
Method to get the vehicle's action buffer.
virtual void SetLaneOffset(const ActorPtr &actor, const float offset)=0
Method to set a lane offset displacement from the center line.
virtual void SetRandomRightLaneChangePercentage(const ActorPtr &actor, const float percentage)=0
Method to set % to randomly do a right lane change.
virtual void SetSynchronousModeTimeOutInMiliSecond(double time)=0
Method to set Tick timeout for synchronous execution.
virtual void SetLargeVehicleWideTurn(const ActorPtr &actor, const bool enable)=0
Method to enable/disable the wide-turn manoeuvre for a single large vehicle.
virtual void RemoveImportedRoute(const ActorId &actor_id, const bool remove_path)=0
Method to remove a route.
virtual void SetHybridPhysicsMode(const bool mode_switch)=0
Method to set hybrid physics mode.
virtual void SetCustomPath(const ActorPtr &actor, const Path path, const bool empty_buffer)=0
Method to set our own imported path.
virtual void RemoveUploadPath(const ActorId &actor_id, const bool remove_path)=0
Method to remove a path.
virtual void SetDesiredSpeed(const ActorPtr &actor, const float value)=0
Set a vehicle's exact desired velocity.
virtual void SetGlobalLargeVehicleWideTurn(const bool enable)=0
Method to enable/disable the wide-turn manoeuvre globally for large vehicles.
virtual void SetUpdateVehicleLights(const ActorPtr &actor, const bool do_update)=0
Method to set the automatic management of the vehicle lights.
virtual void SetPercentageRunningLight(const ActorPtr &actor, const float perc)=0
Method to specify the % chance of running any traffic light.
virtual void UnregisterVehicles(const std::vector< ActorPtr > &actor_list)=0
This method unregisters a vehicle from traffic manager.
virtual void SetDistanceToLeadingVehicle(const ActorPtr &actor, const float distance)=0
Method to specify how much distance a vehicle should maintain to the leading vehicle.
virtual void SetGlobalDistanceToLeadingVehicle(const float dist)=0
Method to set Global Distance to Leading Vehicle.
virtual void UpdateUploadPath(const ActorId &actor_id, const Path path)=0
Method to update an already set path.
virtual void SetImportedRoute(const ActorPtr &actor, const Route route, const bool empty_buffer)=0
Method to set our own imported route.
virtual void SetGlobalPercentageSpeedDifference(float const percentage)=0
Set a global % decrease in velocity with respect to the speed limit.
static std::map< uint16_t, TrafficManagerBase * > _tm_map
static void RequestReset(uint64_t episode_id, std::function< void()> on_done)
Non-blocking: reset all TMs once per episode on the reset thread, then call on_done.
void SetRandomLeftLaneChangePercentage(const ActorPtr &actor, const float percentage)
Method to set % to randomly do a left lane change.
Action GetNextAction(const ActorId &actor_id)
Method to get the next action.
void SetCollisionDetection(const ActorPtr &reference_actor, const ActorPtr &other_actor, const bool detect_collision)
Method to set collision detection rules between vehicles.
void SetImportedRoute(const ActorPtr &actor, const Route route, const bool empty_buffer)
Method to set our own imported route.
TrafficManager(carla::client::detail::EpisodeProxy episode_proxy, uint16_t port=TM_DEFAULT_PORT)
Public constructor for singleton life cycle management.
void SetPercentageRunningSign(const ActorPtr &actor, const float perc)
Method to specify the % chance of running a sign.
bool SynchronousTick()
Method to provide synchronous tick.
void SetLaneOffset(const ActorPtr &actor, const float offset)
Method to set a lane offset displacement from the center line.
void RemoveImportedRoute(const ActorId &actor_id, const bool remove_path)
Method to remove a route.
void UnregisterVehicles(const std::vector< ActorPtr > &actor_list)
This method unregisters a vehicle from traffic manager.
void SetGlobalLaneOffset(float const offset)
Method to set a global lane offset displacement from the center line.
void SetGlobalPercentageSpeedDifference(float const percentage)
Set a global % decrease in velocity with respect to the speed limit.
void SetHybridPhysicsMode(const bool mode_switch)
This method sets the hybrid physics mode.
void UpdateImportedRoute(const ActorId &actor_id, const Route route)
Method to update an already set route.
TrafficManager(TrafficManager &&)=default
void SetSynchronousMode(bool mode)
Method to switch traffic manager into synchronous execution.
void SetPercentageIgnoreWalkers(const ActorPtr &actor, const float perc)
Method to specify the % chance of ignoring collisions with any walker.
void RemoveUploadPath(const ActorId &actor_id, const bool remove_path)
Method to remove a path.
TrafficManager & operator=(TrafficManager &&)=default
void SetPercentageRunningLight(const ActorPtr &actor, const float perc)
Method to specify the % chance of running a light.
TrafficManagerBase * GetTM(uint16_t port) const
void SetCustomPath(const ActorPtr &actor, const Path path, const bool empty_buffer)
Method to set our own imported path.
void SetUpdateVehicleLights(const ActorPtr &actor, const bool do_update)
Set the automatic management of the vehicle lights.
void SetRandomDeviceSeed(const uint64_t seed)
Method to set randomization seed.
void SetGlobalDistanceToLeadingVehicle(const float distance)
Method to Set Global distance to Leading vehicle.
void SetPercentageIgnoreVehicles(const ActorPtr &actor, const float perc)
Method to specify the % chance of ignoring collisions with any vehicle.
void SetGlobalLargeVehicleWideTurn(const bool enable)
Method to enable/disable the wide-turn manoeuvre globally for large vehicles.
void SetDistanceToLeadingVehicle(const ActorPtr &actor, const float distance)
Method to specify how much distance a vehicle should maintain to the leading vehicle.
void SetKeepSlowLanePercentage(const ActorPtr &actor, const float percentage)
Method to set % to keep on the slow lane.
void SetAutoLaneChange(const ActorPtr &actor, const bool enable)
Enable/disable automatic lane change on a vehicle.
ActionBuffer GetActionBuffer(const ActorId &actor_id)
Method to get the action buffer.
TrafficManager(const TrafficManager &other)
void SetHybridPhysicsRadius(const float radius)
This method sets the hybrid physics radius.
void UpdateUploadPath(const ActorId &actor_id, const Path path)
Method to update an already set path.
void SetLargeVehicleWideTurn(const ActorPtr &actor, const bool enable)
Method to enable/disable the wide-turn manoeuvre for a single large vehicle.
void SetForceLaneChange(const ActorPtr &actor, const bool direction)
Method to force lane change on a vehicle.
void SetPercentageSpeedDifference(const ActorPtr &actor, const float percentage)
Set a vehicle's % decrease in velocity with respect to the speed limit.
void CreateTrafficManagerServer(carla::client::detail::EpisodeProxy episode_proxy, uint16_t port)
void RegisterVehicles(const std::vector< ActorPtr > &actor_list)
This method registers a vehicle with the traffic manager.
bool CreateTrafficManagerClient(carla::client::detail::EpisodeProxy episode_proxy, uint16_t port)
TrafficManager & operator=(const TrafficManager &)=default
static void Reset(uint64_t episode_id)
void SetDesiredSpeed(const ActorPtr &actor, const float value)
Set a vehicle's exact desired velocity.
void SetOSMMode(const bool mode_switch)
Method to set Open Street Map mode.
void SetSynchronousModeTimeOutInMiliSecond(double time)
Method to set tick timeout for synchronous execution.
void SetRandomRightLaneChangePercentage(const ActorPtr &actor, const float percentage)
Method to set % to randomly do a right lane change.
EpisodeProxyImpl< EpisodeProxyPointerType::Strong > EpisodeProxy
carla::SharedPtr< cc::Actor > ActorPtr
std::vector< uint8_t > Route
std::vector< cg::Location > Path
std::vector< Action > ActionBuffer
std::pair< RoadOption, WaypointPtr > Action
This file contains definitions of common data structures used in traffic manager.