CARLA
 
载入中...
搜索中...
未找到
TrafficManagerBase.h
浏览该文件的文档.
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"
12
13namespace carla {
14namespace traffic_manager {
15
17using Path = std::vector<cg::Location>;
18using Route = std::vector<uint8_t>;
20using Action = std::pair<RoadOption, WaypointPtr>;
21using ActionBuffer = std::vector<Action>;
22
23
24/// The function of this class is to integrate all the various stages of
25/// the traffic manager appropriately using messengers.
27
28public:
29 /// To start the traffic manager.
30 virtual void Start() = 0;
31
32 /// To stop the traffic manager.
33 virtual void Stop() = 0;
34
35 /// To release the traffic manager.
36 virtual void Release() = 0;
37
38 /// To reset the traffic manager.
39 virtual void Reset() = 0;
40
41 /// Protected constructor for singleton lifecycle management.
43
44 /// Destructor.
45 virtual ~TrafficManagerBase() {};
46
47 /// This method registers a vehicle with the traffic manager.
48 virtual void RegisterVehicles(const std::vector<ActorPtr> &actor_list) = 0;
49
50 /// This method unregisters a vehicle from traffic manager.
51 virtual void UnregisterVehicles(const std::vector<ActorPtr> &actor_list) = 0;
52
53 /// Set a vehicle's % decrease in velocity with respect to the speed limit.
54 /// If less than 0, it's a % increase.
55 virtual void SetPercentageSpeedDifference(const ActorPtr &actor, const float percentage) = 0;
56
57 /// Method to set a lane offset displacement from the center line.
58 /// Positive values imply a right offset while negative ones mean a left one.
59 virtual void SetLaneOffset(const ActorPtr &actor, const float offset) = 0;
60
61 /// Set a vehicle's exact desired velocity.
62 virtual void SetDesiredSpeed(const ActorPtr &actor, const float value) = 0;
63
64 /// Set a global % decrease in velocity with respect to the speed limit.
65 /// If less than 0, it's a % increase.
66 virtual void SetGlobalPercentageSpeedDifference(float const percentage) = 0;
67
68 /// Method to set a global lane offset displacement from the center line.
69 /// Positive values imply a right offset while negative ones mean a left one.
70 virtual void SetGlobalLaneOffset(float const offset) = 0;
71
72 /// Method to set the automatic management of the vehicle lights
73 virtual void SetUpdateVehicleLights(const ActorPtr &actor, const bool do_update) = 0;
74
75 /// Method to set collision detection rules between vehicles.
76 virtual void SetCollisionDetection(const ActorPtr &reference_actor, const ActorPtr &other_actor, const bool detect_collision) = 0;
77
78 /// Method to force lane change on a vehicle.
79 /// Direction flag can be set to true for left and false for right.
80 virtual void SetForceLaneChange(const ActorPtr &actor, const bool direction) = 0;
81
82 /// Enable/disable automatic lane change on a vehicle.
83 virtual void SetAutoLaneChange(const ActorPtr &actor, const bool enable) = 0;
84
85 /// Method to specify how much distance a vehicle should maintain to
86 /// the leading vehicle.
87 virtual void SetDistanceToLeadingVehicle(const ActorPtr &actor, const float distance) = 0;
88
89 /// Method to specify the % chance of ignoring collisions with any walker.
90 virtual void SetPercentageIgnoreWalkers(const ActorPtr &actor, const float perc) = 0;
91
92 /// Method to specify the % chance of ignoring collisions with any vehicle.
93 virtual void SetPercentageIgnoreVehicles(const ActorPtr &actor, const float perc) = 0;
94
95 /// Method to specify the % chance of running any traffic light.
96 virtual void SetPercentageRunningLight(const ActorPtr &actor, const float perc) = 0;
97
98 /// Method to specify the % chance of running any traffic sign.
99 virtual void SetPercentageRunningSign(const ActorPtr &actor, const float perc) = 0;
100
101 /// Method to switch traffic manager into synchronous execution.
102 virtual void SetSynchronousMode(bool mode) = 0;
103
104 /// Method to set Tick timeout for synchronous execution.
105 virtual void SetSynchronousModeTimeOutInMiliSecond(double time) = 0;
106
107 /// Method to provide synchronous tick
108 virtual bool SynchronousTick() = 0;
109
110 /// Get carla episode information
112
113 /// Method to set Global Distance to Leading Vehicle.
114 virtual void SetGlobalDistanceToLeadingVehicle(const float dist) = 0;
115
116 /// Method to set % to keep on the right lane.
117 virtual void SetKeepRightPercentage(const ActorPtr &actor,const float percentage) = 0;
118
119 /// Method to set % to randomly do a left lane change.
120 virtual void SetRandomLeftLaneChangePercentage(const ActorPtr &actor, const float percentage) = 0;
121
122 /// Method to set % to randomly do a right lane change.
123 virtual void SetRandomRightLaneChangePercentage(const ActorPtr &actor, const float percentage) = 0;
124
125 /// Method to set hybrid physics mode.
126 virtual void SetHybridPhysicsMode(const bool mode_switch) = 0;
127
128 /// Method to set hybrid physics radius.
129 virtual void SetHybridPhysicsRadius(const float radius) = 0;
130
131 /// Method to set randomization seed.
132 virtual void SetRandomDeviceSeed(const uint64_t seed) = 0;
133
134 /// Method to set Open Street Map mode.
135 virtual void SetOSMMode(const bool mode_switch) = 0;
136
137 /// Method to set our own imported path.
138 virtual void SetCustomPath(const ActorPtr &actor, const Path path, const bool empty_buffer) = 0;
139
140 /// Method to remove a path.
141 virtual void RemoveUploadPath(const ActorId &actor_id, const bool remove_path) = 0;
142
143 /// Method to update an already set path.
144 virtual void UpdateUploadPath(const ActorId &actor_id, const Path path) = 0;
145
146 /// Method to set our own imported route.
147 virtual void SetImportedRoute(const ActorPtr &actor, const Route route, const bool empty_buffer) = 0;
148
149 /// Method to remove a route.
150 virtual void RemoveImportedRoute(const ActorId &actor_id, const bool remove_path) = 0;
151
152 /// Method to update an already set route.
153 virtual void UpdateImportedRoute(const ActorId &actor_id, const Route route) = 0;
154
155 /// Method to set automatic respawn of dormant vehicles.
156 virtual void SetRespawnDormantVehicles(const bool mode_switch) = 0;
157
158 /// Method to set boundaries for respawning vehicles.
159 virtual void SetBoundariesRespawnDormantVehicles(const float lower_bound, const float upper_bound) = 0;
160
161 /// Method to set limits for boundaries when respawning vehicles.
162 virtual void SetMaxBoundaries(const float lower, const float upper) = 0;
163
164 /// Method to get the vehicle's next action.
165 virtual Action GetNextAction(const ActorId &actor_id) = 0;
166
167 /// Method to get the vehicle's action buffer.
168 virtual ActionBuffer GetActionBuffer(const ActorId &actor_id) = 0;
169
170 virtual void ShutDown() = 0;
171
172protected:
173
174};
175
176} // namespace traffic_manager
177} // namespace carla
The function of this class is to integrate all the various stages of the traffic manager appropriatel...
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 SetBoundariesRespawnDormantVehicles(const float lower_bound, const float upper_bound)=0
Method to set boundaries for respawning vehicles.
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 carla::client::detail::EpisodeProxy & GetEpisodeProxy()=0
Get carla episode information
virtual void Release()=0
To release the traffic manager.
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 SetMaxBoundaries(const float lower, const float upper)=0
Method to set limits for boundaries when respawning vehicles.
TrafficManagerBase()
Protected constructor for singleton lifecycle management.
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 void Reset()=0
To reset the traffic manager.
virtual void SetKeepRightPercentage(const ActorPtr &actor, const float percentage)=0
Method to set % to keep on the right lane.
virtual void SetSynchronousMode(bool mode)=0
Method to switch traffic manager into synchronous execution.
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 SetRespawnDormantVehicles(const bool mode_switch)=0
Method to set automatic respawn of dormant vehicles.
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 Stop()=0
To stop the traffic manager.
virtual void Start()=0
To start the traffic manager.
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.
carla::SharedPtr< cc::Actor > ActorPtr
carla::SharedPtr< cc::Waypoint > WaypointPtr
Definition InMemoryMap.h:45
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.
Definition Carla.cpp:133
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