CARLA
TrafficManagerBase.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 <memory>
10 #include "carla/client/Actor.h"
11 
12 namespace carla {
13 namespace traffic_manager {
14 
16 
17 /// The function of this class is to integrate all the various stages of
18 /// the traffic manager appropriately using messengers.
20 
21 public:
22  /// To start the traffic manager.
23  virtual void Start() = 0;
24 
25  /// To stop the traffic manager.
26  virtual void Stop() = 0;
27 
28  /// To release the traffic manager.
29  virtual void Release() = 0;
30 
31  /// To reset the traffic manager.
32  virtual void Reset() = 0;
33 
34  /// Protected constructor for singleton lifecycle management.
36 
37  /// Destructor.
38  virtual ~TrafficManagerBase() {};
39 
40  /// This method registers a vehicle with the traffic manager.
41  virtual void RegisterVehicles(const std::vector<ActorPtr> &actor_list) = 0;
42 
43  /// This method unregisters a vehicle from traffic manager.
44  virtual void UnregisterVehicles(const std::vector<ActorPtr> &actor_list) = 0;
45 
46  /// Set a vehicle's % decrease in velocity with respect to the speed limit.
47  /// If less than 0, it's a % increase.
48  virtual void SetPercentageSpeedDifference(const ActorPtr &actor, const float percentage) = 0;
49 
50  /// Set a global % decrease in velocity with respect to the speed limit.
51  /// If less than 0, it's a % increase.
52  virtual void SetGlobalPercentageSpeedDifference(float const percentage) = 0;
53 
54  /// Method to set collision detection rules between vehicles.
55  virtual void SetCollisionDetection(const ActorPtr &reference_actor, const ActorPtr &other_actor, const bool detect_collision) = 0;
56 
57  /// Method to force lane change on a vehicle.
58  /// Direction flag can be set to true for left and false for right.
59  virtual void SetForceLaneChange(const ActorPtr &actor, const bool direction) = 0;
60 
61  /// Enable/disable automatic lane change on a vehicle.
62  virtual void SetAutoLaneChange(const ActorPtr &actor, const bool enable) = 0;
63 
64  /// Method to specify how much distance a vehicle should maintain to
65  /// the leading vehicle.
66  virtual void SetDistanceToLeadingVehicle(const ActorPtr &actor, const float distance) = 0;
67 
68  /// Method to specify the % chance of ignoring collisions with any walker.
69  virtual void SetPercentageIgnoreWalkers(const ActorPtr &actor, const float perc) = 0;
70 
71  /// Method to specify the % chance of ignoring collisions with any vehicle.
72  virtual void SetPercentageIgnoreVehicles(const ActorPtr &actor, const float perc) = 0;
73 
74  /// Method to specify the % chance of running any traffic light.
75  virtual void SetPercentageRunningLight(const ActorPtr &actor, const float perc) = 0;
76 
77  /// Method to specify the % chance of running any traffic sign.
78  virtual void SetPercentageRunningSign(const ActorPtr &actor, const float perc) = 0;
79 
80  /// Method to switch traffic manager into synchronous execution.
81  virtual void SetSynchronousMode(bool mode) = 0;
82 
83  /// Method to set Tick timeout for synchronous execution.
84  virtual void SetSynchronousModeTimeOutInMiliSecond(double time) = 0;
85 
86  /// Method to provide synchronous tick
87  virtual bool SynchronousTick() = 0;
88 
89  /// Get carla episode information
91 
92  /// Method to set Global Distance to Leading Vehicle.
93  virtual void SetGlobalDistanceToLeadingVehicle(const float dist) = 0;
94 
95  /// Method to set probabilistic preference to keep on the right lane.
96  virtual void SetKeepRightPercentage(const ActorPtr &actor,const float percentage) = 0;
97 
98  /// Method to set hybrid physics mode.
99  virtual void SetHybridPhysicsMode(const bool mode_switch) = 0;
100 
101  /// Method to set hybrid physics radius.
102  virtual void SetHybridPhysicsRadius(const float radius) = 0;
103 
104  /// Method to set randomization seed.
105  virtual void SetRandomDeviceSeed(const uint64_t seed) = 0;
106  /// Method to set Open Street Map mode.
107  virtual void SetOSMMode(const bool mode_switch) = 0;
108 
109 protected:
110 
111 };
112 
113 } // namespace traffic_manager
114 } // namespace carla
virtual void SetHybridPhysicsMode(const bool mode_switch)=0
Method to set hybrid physics mode.
virtual void SetAutoLaneChange(const ActorPtr &actor, const bool enable)=0
Enable/disable automatic lane change on a vehicle.
virtual void Start()=0
To start the traffic manager.
virtual void SetForceLaneChange(const ActorPtr &actor, const bool direction)=0
Method to force lane change on a vehicle.
virtual bool SynchronousTick()=0
Method to provide synchronous tick.
TrafficManagerBase()
Protected constructor for singleton lifecycle management.
carla::SharedPtr< cc::Actor > ActorPtr
virtual void SetGlobalDistanceToLeadingVehicle(const float dist)=0
Method to set Global Distance to Leading Vehicle.
virtual void SetPercentageIgnoreWalkers(const ActorPtr &actor, const float perc)=0
Method to specify the % chance of ignoring collisions with any walker.
virtual void Release()=0
To release the traffic manager.
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
virtual void SetPercentageSpeedDifference(const ActorPtr &actor, const float percentage)=0
Set a vehicle&#39;s % decrease in velocity with respect to the speed limit.
virtual void UnregisterVehicles(const std::vector< ActorPtr > &actor_list)=0
This method unregisters a vehicle from traffic manager.
virtual void SetOSMMode(const bool mode_switch)=0
Method to set Open Street Map mode.
virtual void SetGlobalPercentageSpeedDifference(float const percentage)=0
Set a global % decrease in velocity with respect to the speed limit.
virtual void SetKeepRightPercentage(const ActorPtr &actor, const float percentage)=0
Method to set probabilistic preference to keep on the right lane.
The function of this class is to integrate all the various stages of the traffic manager appropriatel...
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 Stop()=0
To stop the traffic manager.
virtual void SetPercentageIgnoreVehicles(const ActorPtr &actor, const float perc)=0
Method to specify the % chance of ignoring collisions with any vehicle.
virtual void Reset()=0
To reset the traffic manager.
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 SetPercentageRunningLight(const ActorPtr &actor, const float perc)=0
Method to specify the % chance of running any traffic light.
virtual void SetHybridPhysicsRadius(const float radius)=0
Method to set hybrid physics radius.
virtual void SetRandomDeviceSeed(const uint64_t seed)=0
Method to set randomization seed.
virtual void SetSynchronousModeTimeOutInMiliSecond(double time)=0
Method to set Tick timeout for synchronous execution.
virtual void SetPercentageRunningSign(const ActorPtr &actor, const float perc)=0
Method to specify the % chance of running any traffic sign.
virtual void SetSynchronousMode(bool mode)=0
Method to switch traffic manager into synchronous execution.
virtual void RegisterVehicles(const std::vector< ActorPtr > &actor_list)=0
This method registers a vehicle with the traffic manager.
virtual carla::client::detail::EpisodeProxy & GetEpisodeProxy()=0
Get carla episode information.