CARLA
TrafficManagerRemote.h
Go to the documentation of this file.
1 // Copyright (c) 2020 Computer Vision Center (CVC) at the Universitat Autonoma
2 // de Barcelona (UAB).
3 //
4 // This work is licensed under the terms of the MIT license.
5 // For a copy, see <https://opensource.org/licenses/MIT>.
6 
7 #pragma once
8 
9 #include <condition_variable>
10 #include <mutex>
11 #include <vector>
12 
13 #include "carla/client/Actor.h"
17 
18 namespace carla {
19 namespace traffic_manager {
20 
22 
23 /// The function of this class is to integrate all the various stages of
24 /// the traffic manager appropriately using messengers.
26 
27 public:
28 
29  /// To start the TrafficManager.
30  void Start();
31 
32  /// To stop the TrafficManager.
33  void Stop();
34 
35  /// To release the traffic manager.
36  void Release();
37 
38  /// To reset the traffic manager.
39  void Reset();
40 
41  /// Constructor store remote location information.
42  TrafficManagerRemote(const std::pair<std::string, uint16_t> &_serverTM, carla::client::detail::EpisodeProxy &episodeProxy);
43 
44  /// Destructor.
45  virtual ~TrafficManagerRemote();
46 
47  /// This method registers a vehicle with the traffic manager.
48  void RegisterVehicles(const std::vector<ActorPtr> &actor_list);
49 
50  /// This method unregisters a vehicle from traffic manager.
51  void UnregisterVehicles(const std::vector<ActorPtr> &actor_list);
52 
53  /// Method to set a vehicle's % decrease in velocity with respect to the speed limit.
54  /// If less than 0, it's a % increase.
55  void SetPercentageSpeedDifference(const ActorPtr &actor, const float percentage);
56 
57  /// Method to set a global % decrease in velocity with respect to the speed limit.
58  /// If less than 0, it's a % increase.
59  void SetGlobalPercentageSpeedDifference(float const percentage);
60 
61  /// Method to set collision detection rules between vehicles.
62  void SetCollisionDetection(const ActorPtr &reference_actor, const ActorPtr &other_actor, const bool detect_collision);
63 
64  /// Method to force lane change on a vehicle.
65  /// Direction flag can be set to true for left and false for right.
66  void SetForceLaneChange(const ActorPtr &actor, const bool direction);
67 
68  /// Enable/disable automatic lane change on a vehicle.
69  void SetAutoLaneChange(const ActorPtr &actor, const bool enable);
70 
71  /// Method to specify how much distance a vehicle should maintain to
72  /// the leading vehicle.
73  void SetDistanceToLeadingVehicle(const ActorPtr &actor, const float distance);
74 
75  /// Method to specify Global Distance
76  void SetGlobalDistanceToLeadingVehicle(const float distance);
77 
78  /// Method to specify the % chance of ignoring collisions with any walker.
79  void SetPercentageIgnoreWalkers(const ActorPtr &actor, const float perc);
80 
81  /// Method to specify the % chance of ignoring collisions with any vehicle.
82  void SetPercentageIgnoreVehicles(const ActorPtr &actor, const float perc);
83 
84  /// Method to specify the % chance of running any traffic light
85  void SetPercentageRunningLight(const ActorPtr &actor, const float perc);
86 
87  /// Method to specify the % chance of running any traffic sign
88  void SetPercentageRunningSign(const ActorPtr &actor, const float perc);
89 
90  /// Method to switch traffic manager into synchronous execution.
91  void SetSynchronousMode(bool mode);
92 
93  /// Method to set Tick timeout for synchronous execution.
94  void SetSynchronousModeTimeOutInMiliSecond(double time);
95 
96  /// Method to set probabilistic preference to keep on the right lane.
97  void SetKeepRightPercentage(const ActorPtr &actor, const float percentage);
98 
99  /// Method to set hybrid physics mode.
100  void SetHybridPhysicsMode(const bool mode_switch);
101 
102  /// Method to set hybrid physics radius.
103  void SetHybridPhysicsRadius(const float radius);
104 
105  /// Method to set Open Street Map mode.
106  void SetOSMMode(const bool mode_switch);
107 
108  /// Method to provide synchronous tick
109  bool SynchronousTick();
110 
111  /// Get CARLA episode information.
113 
114  /// Method to check server is alive or not.
115  void HealthCheckRemoteTM();
116 
117  /// Method to set randomization seed.
118  void SetRandomDeviceSeed(const uint64_t seed);
119 
120 private:
121 
122  /// Remote client using the IP and port information it connects to
123  /// as remote RPC traffic manager server.
125 
126  /// CARLA client connection object.
128 
129  std::condition_variable _cv;
130 
131  std::mutex _mutex;
132 
133  bool _keep_alive = true;
134 };
135 
136 } // namespace traffic_manager
137 } // namespace carla
TrafficManagerClient client
Remote client using the IP and port information it connects to as remote RPC traffic manager server...
void SetForceLaneChange(const ActorPtr &actor, const bool direction)
Method to force lane change on a vehicle.
void SetPercentageIgnoreVehicles(const ActorPtr &actor, const float perc)
Method to specify the % chance of ignoring collisions with any vehicle.
void SetAutoLaneChange(const ActorPtr &actor, const bool enable)
Enable/disable automatic lane change on a vehicle.
void SetPercentageRunningSign(const ActorPtr &actor, const float perc)
Method to specify the % chance of running any traffic sign.
void SetHybridPhysicsMode(const bool mode_switch)
Method to set hybrid physics mode.
carla::client::detail::EpisodeProxy episodeProxyTM
CARLA client connection object.
void SetSynchronousModeTimeOutInMiliSecond(double time)
Method to set Tick timeout for synchronous execution.
void SetGlobalDistanceToLeadingVehicle(const float distance)
Method to specify Global Distance.
void Reset()
To reset the traffic manager.
carla::SharedPtr< cc::Actor > ActorPtr
void SetHybridPhysicsRadius(const float radius)
Method to set hybrid physics radius.
void UnregisterVehicles(const std::vector< ActorPtr > &actor_list)
This method unregisters a vehicle from traffic manager.
void SetSynchronousMode(bool mode)
Method to switch traffic manager into synchronous execution.
bool SynchronousTick()
Method to provide synchronous tick.
void SetCollisionDetection(const ActorPtr &reference_actor, const ActorPtr &other_actor, const bool detect_collision)
Method to set collision detection rules between vehicles.
boost::shared_ptr< T > SharedPtr
Use this SharedPtr (boost::shared_ptr) to keep compatibility with boost::python, but it would be nice...
Definition: Memory.h:20
This file contains definitions of common data structures used in traffic manager. ...
Definition: Carla.cpp:99
void RegisterVehicles(const std::vector< ActorPtr > &actor_list)
This method registers a vehicle with the traffic manager.
void SetPercentageIgnoreWalkers(const ActorPtr &actor, const float perc)
Method to specify the % chance of ignoring collisions with any walker.
void SetPercentageRunningLight(const ActorPtr &actor, const float perc)
Method to specify the % chance of running any traffic light.
void SetGlobalPercentageSpeedDifference(float const percentage)
Method to set a global % decrease in velocity with respect to the speed limit.
void SetPercentageSpeedDifference(const ActorPtr &actor, const float percentage)
Method to set a vehicle&#39;s % decrease in velocity with respect to the speed limit. ...
void Start()
To start the TrafficManager.
void SetOSMMode(const bool mode_switch)
Method to set Open Street Map mode.
The function of this class is to integrate all the various stages of the traffic manager appropriatel...
Provides communication with the rpc of TrafficManagerServer.
TrafficManagerRemote(const std::pair< std::string, uint16_t > &_serverTM, carla::client::detail::EpisodeProxy &episodeProxy)
Constructor store remote location information.
void SetDistanceToLeadingVehicle(const ActorPtr &actor, const float distance)
Method to specify how much distance a vehicle should maintain to the leading vehicle.
void Release()
To release the traffic manager.
The function of this class is to integrate all the various stages of the traffic manager appropriatel...
void SetKeepRightPercentage(const ActorPtr &actor, const float percentage)
Method to set probabilistic preference to keep on the right lane.
void HealthCheckRemoteTM()
Method to check server is alive or not.
void SetRandomDeviceSeed(const uint64_t seed)
Method to set randomization seed.
carla::client::detail::EpisodeProxy & GetEpisodeProxy()
Get CARLA episode information.