11 namespace traffic_manager {
45 float new_percentage =
std::min(100.0f, percentage);
53 const auto entry = std::make_pair(actor->GetId(), offset);
59 float new_value = std::max(0.0f, value);
67 float new_percentage =
std::min(100.0f, percentage);
76 const ActorId reference_id = reference_actor->GetId();
77 const ActorId other_id = other_actor->GetId();
79 if (detect_collision) {
81 std::shared_ptr<AtomicActorSet> actor_set =
ignore_collision.GetValue(reference_id);
82 if (actor_set->Contains(other_id)) {
83 actor_set->Remove({other_id});
88 std::shared_ptr<AtomicActorSet> actor_set =
ignore_collision.GetValue(reference_id);
89 if (!actor_set->Contains(other_id)) {
90 actor_set->Insert({other_actor});
93 std::shared_ptr<AtomicActorSet> actor_set = std::make_shared<AtomicActorSet>();
94 actor_set->Insert({other_actor});
95 auto entry = std::make_pair(reference_id, actor_set);
104 const auto entry = std::make_pair(actor->GetId(), lane_change_info);
110 const auto entry = std::make_pair(actor->GetId(), percentage);
116 const auto entry = std::make_pair(actor->GetId(), percentage);
122 const auto entry = std::make_pair(actor->GetId(), percentage);
129 const auto entry = std::make_pair(actor->GetId(), do_update);
135 const auto entry = std::make_pair(actor->GetId(), enable);
141 float new_distance = std::max(0.0f, distance);
142 const auto entry = std::make_pair(actor->GetId(), new_distance);
162 const auto entry = std::make_pair(actor->GetId(), new_perc);
169 const auto entry = std::make_pair(actor->GetId(), new_perc);
176 const auto entry = std::make_pair(actor->GetId(), new_perc);
183 const auto entry = std::make_pair(actor->GetId(), new_perc);
188 float new_radius = std::max(radius, 0.0f);
197 const auto entry = std::make_pair(actor->GetId(), path);
199 const auto entry2 = std::make_pair(actor->GetId(), empty_buffer);
213 const auto entry = std::make_pair(actor_id, path);
218 const auto entry = std::make_pair(actor->GetId(), route);
220 const auto entry2 = std::make_pair(actor->GetId(), empty_buffer);
234 const auto entry = std::make_pair(actor_id, route);
263 return speed_limit * (1.0f - percentage_difference / 100.0f);
278 bool avoid_collision =
true;
282 avoid_collision =
false;
285 return avoid_collision;
298 return change_lane_info;
303 float percentage = -1.0f;
314 float percentage = -1.0f;
325 float percentage = -1.0f;
336 bool auto_lane_change_policy =
true;
342 return auto_lane_change_policy;
347 float specific_distance_margin = 0.0f;
354 return specific_distance_margin;
359 float percentage = 0.0f;
370 float percentage = 0.0f;
381 float percentage = 0.0f;
391 bool do_update =
false;
402 float percentage = 0.0f;
439 bool custom_path_bool =
false;
445 return custom_path_bool;
450 Path custom_path_import;
456 return custom_path_import;
462 bool custom_route_bool =
false;
468 return custom_route_bool;
473 Route custom_route_import;
479 return custom_route_import;
float GetPercentageRunningLight(const ActorId &actor_id) const
Method to get % to run any traffic light.
void RemoveEntry(const Key &key)
void SetUpdateVehicleLights(const ActorPtr &actor, const bool do_update)
Method to set the automatic vehicle light state update flag.
float GetRandomRightLaneChangePercentage(const ActorId &actor_id)
Method to query percentage probability of a random left lane change for a vehicle.
bool GetCollisionDetection(const ActorId &reference_actor_id, const ActorId &other_actor_id) const
Method to query collision avoidance rule between a pair of vehicles.
AtomicMap< ActorId, float > perc_run_traffic_sign
Map containing % of running a traffic sign.
std::atomic< float > respawn_lower_bound
Minimum distance to respawn vehicles with respect to the hero vehicle.
bool GetUpdateVehicleLights(const ActorId &actor_id) const
Method to get if the vehicle lights should be updates automatically.
AtomicMap< ActorId, bool > upload_route
Parameter specifying if importing a custom route.
float GetVehicleTargetVelocity(const ActorId &actor_id, const float speed_limit) const
Method to query target velocity for a vehicle.
float min_lower_bound
Minimum possible distance to respawn vehicles with respect to the hero vehicle.
void SetCustomPath(const ActorPtr &actor, const Path path, const bool empty_buffer)
Method to set our own imported path.
const Value & GetValue(const Key &key) const
Route GetImportedRoute(const ActorId &actor_id) const
Method to get a custom route.
float GetLaneOffset(const ActorId &actor_id) const
Method to query lane offset for a vehicle.
std::atomic< float > hybrid_physics_radius
Hybrid physics radius.
void SetGlobalDistanceToLeadingVehicle(const float dist)
Method to set the distance to leading vehicle for all registered vehicles.
void SetDistanceToLeadingVehicle(const ActorPtr &actor, const float distance)
Method to specify how much distance a vehicle should maintain to the leading vehicle.
bool GetUploadRoute(const ActorId &actor_id) const
Method to get if we are uploading a route.
AtomicMap< ActorId, float > exact_desired_speed
Target velocity map for individual vehicles, based on a desired velocity.
carla::SharedPtr< cc::Actor > ActorPtr
AtomicMap< ActorId, float > perc_random_left
Map containing % of random left lane change.
bool GetOSMMode() const
Method to get Open Street Map mode.
std::atomic< bool > osm_mode
Parameter specifying Open Street Map mode.
bool Contains(const Key &key) const
void SetAutoLaneChange(const ActorPtr &actor, const bool enable)
Enable/disable automatic lane change on a vehicle.
std::vector< cg::Location > Path
static T Clamp(T a, T min=T(0), T max=T(1))
AtomicMap< ActorId, bool > auto_lane_change
Map containing auto lane change commands.
bool GetAutoLaneChange(const ActorId &actor_id) const
Method to query auto lane change rule for a vehicle.
This file contains definitions of common data structures used in traffic manager. ...
std::chrono::duration< double, std::milli > synchronous_time_out
Synchronous mode time out variable.
void SetKeepRightPercentage(const ActorPtr &actor, const float percentage)
Method to set % to keep on the right lane.
AtomicMap< ActorId, float > perc_run_traffic_light
Map containing % of running a traffic light.
void SetForceLaneChange(const ActorPtr &actor, const bool direction)
Method to force lane change on a vehicle.
AtomicMap< ActorId, ChangeLaneInfo > force_lane_change
Map containing force lane change commands.
void SetMaxBoundaries(const float lower, const float upper)
Method to set limits for boundaries when respawning vehicles.
float max_upper_bound
Maximum possible distance to respawn vehicles with respect to the hero vehicle.
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)
Set a vehicle's % decrease in velocity with respect to the speed limit.
bool GetUploadPath(const ActorId &actor_id) const
Method to get if we are uploading a path.
AtomicMap< ActorId, float > perc_keep_right
Map containing % of keep right rule.
void UpdateUploadPath(const ActorId &actor_id, const Path path)
Method to update an already set list of points.
AtomicMap< ActorId, Route > custom_route
Structure to hold all custom routes.
bool GetRespawnDormantVehicles() const
Method to retrieve if we are automatically respawning vehicles.
std::atomic< float > distance_margin
Distance margin.
float GetKeepRightPercentage(const ActorId &actor_id)
Method to query percentage probability of keep right rule for a vehicle.
AtomicMap< ActorId, float > percentage_difference_from_speed_limit
Target velocity map for individual vehicles, based on a % diffrerence from speed limit.
void UpdateImportedRoute(const ActorId &actor_id, const Route route)
Method to update an already set route.
void SetCollisionDetection(const ActorPtr &reference_actor, const ActorPtr &other_actor, const bool detect_collision)
Method to set collision detection rules between vehicles.
AtomicMap< ActorId, bool > auto_update_vehicle_lights
Map containing the automatic vehicle lights update flag.
AtomicMap< ActorId, bool > upload_path
Parameter specifying if importing a custom path.
AtomicMap< ActorId, Path > custom_path
Structure to hold all custom paths.
double min(double v1, double v2)
bool GetHybridPhysicsMode() const
Method to retrieve hybrid physics mode.
std::atomic< bool > hybrid_physics_mode
Hybrid physics mode switch.
AtomicMap< ActorId, float > distance_to_leading_vehicle
Map containing distance to leading vehicle command.
std::vector< uint8_t > Route
float GetHybridPhysicsRadius() const
Method to retrieve hybrid physics radius.
bool GetSynchronousMode() const
Method to get synchronous mode.
void SetPercentageIgnoreVehicles(const ActorPtr &actor, const float perc)
Method to set % to ignore any vehicle.
AtomicMap< ActorId, float > perc_random_right
Map containing % of random right lane change.
float GetPercentageIgnoreVehicles(const ActorId &actor_id) const
Method to get % to ignore any vehicle.
float GetDistanceToLeadingVehicle(const ActorId &actor_id) const
Method to query distance to leading vehicle for a given vehicle.
void SetGlobalPercentageSpeedDifference(float const percentage)
Set a global % decrease in velocity with respect to the speed limit.
float GetPercentageRunningSign(const ActorId &actor_id) const
Method to get % to run any traffic light.
AtomicMap< ActorId, float > perc_ignore_walkers
Map containing % of ignoring walkers.
float GetUpperBoundaryRespawnDormantVehicles() const
Method to retrieve maximum distance from hero vehicle when respawning vehicles.
void SetLaneOffset(const ActorPtr &actor, const float offset)
Method to set a lane offset displacement from the center line.
void SetPercentageIgnoreWalkers(const ActorPtr &actor, const float perc)
Method to set % to ignore any vehicle.
void AddEntry(const std::pair< Key, Value > &entry)
void SetGlobalLaneOffset(float const offset)
Method to set a global lane offset displacement from the center line.
void RemoveImportedRoute(const ActorId &actor_id, const bool remove_path)
Method to remove a route.
float GetLowerBoundaryRespawnDormantVehicles() const
Method to retrieve minimum distance from hero vehicle when respawning vehicles.
float global_lane_offset
Global lane offset.
void SetBoundariesRespawnDormantVehicles(const float lower_bound, const float upper_bound)
Method to set boundaries for respawning vehicles.
float GetPercentageIgnoreWalkers(const ActorId &actor_id) const
Method to get % to ignore any walker.
void RemoveUploadPath(const ActorId &actor_id, const bool remove_path)
Method to remove a list of points.
std::atomic< bool > synchronous_mode
Synchronous mode switch.
void SetRespawnDormantVehicles(const bool mode_switch)
Method to set if we are automatically respawning vehicles.
void SetSynchronousMode(const bool mode_switch=true)
Method to set synchronous mode.
void SetHybridPhysicsRadius(const float radius)
Method to set hybrid physics radius.
AtomicMap< ActorId, std::shared_ptr< AtomicActorSet > > ignore_collision
Map containing a set of actors to be ignored during collision detection.
void SetPercentageRunningLight(const ActorPtr &actor, const float perc)
Method to set % to run any traffic light.
float global_percentage_difference_from_limit
Global target velocity limit % difference.
void SetPercentageRunningSign(const ActorPtr &actor, const float perc)
Method to set % to run any traffic sign.
float GetRandomLeftLaneChangePercentage(const ActorId &actor_id)
Method to query percentage probability of a random right lane change for a vehicle.
double GetSynchronousModeTimeOutInMiliSecond() const
Get synchronous mode time out.
AtomicMap< ActorId, float > perc_ignore_vehicles
Map containing % of ignoring vehicles.
AtomicMap< ActorId, float > lane_offset
Lane offset map for individual vehicles.
void SetRandomRightLaneChangePercentage(const ActorPtr &actor, const float percentage)
Method to set % to randomly do a right lane change.
void SetSynchronousModeTimeOutInMiliSecond(const double time)
Set Synchronous mode time out.
ChangeLaneInfo GetForceLaneChange(const ActorId &actor_id)
Method to query lane change command for a vehicle.
void SetHybridPhysicsMode(const bool mode_switch)
Method to set hybrid physics mode.
void SetOSMMode(const bool mode_switch)
Method to set Open Street Map mode.
void SetImportedRoute(const ActorPtr &actor, const Route route, const bool empty_buffer)
Method to set our own imported route.
std::atomic< bool > respawn_dormant_vehicles
Automatic respawn mode switch.
Path GetCustomPath(const ActorId &actor_id) const
Method to get a custom path.
std::atomic< float > respawn_upper_bound
Maximum distance to respawn vehicles with respect to the hero vehicle.
void SetDesiredSpeed(const ActorPtr &actor, const float value)
Set a vehicle's exact desired velocity.