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