11namespace 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 auto entry = std::make_pair(actor->GetId(), enable);
85 const ActorId reference_id = reference_actor->GetId();
86 const ActorId other_id = other_actor->GetId();
88 if (detect_collision) {
90 std::shared_ptr<AtomicActorSet> actor_set =
ignore_collision.GetValue(reference_id);
91 if (actor_set->Contains(other_id)) {
92 actor_set->Remove({other_id});
97 std::shared_ptr<AtomicActorSet> actor_set =
ignore_collision.GetValue(reference_id);
98 if (!actor_set->Contains(other_id)) {
99 actor_set->Insert({other_actor});
102 std::shared_ptr<AtomicActorSet> actor_set = std::make_shared<AtomicActorSet>();
103 actor_set->Insert({other_actor});
104 auto entry = std::make_pair(reference_id, actor_set);
113 const auto entry = std::make_pair(actor->GetId(), lane_change_info);
119 const auto entry = std::make_pair(actor->GetId(), percentage);
126 const auto entry = std::make_pair(actor->GetId(), percentage);
132 const auto entry = std::make_pair(actor->GetId(), percentage);
139 const auto entry = std::make_pair(actor->GetId(), do_update);
145 const auto entry = std::make_pair(actor->GetId(), enable);
151 float new_distance = std::max(0.0f,
distance);
152 const auto entry = std::make_pair(actor->GetId(), new_distance);
171 float new_perc = cg::Math::Clamp(perc, 0.0f, 100.0f);
172 const auto entry = std::make_pair(actor->GetId(), new_perc);
178 float new_perc = cg::Math::Clamp(perc, 0.0f, 100.0f);
179 const auto entry = std::make_pair(actor->GetId(), new_perc);
185 float new_perc = cg::Math::Clamp(perc, 0.0f, 100.0f);
186 const auto entry = std::make_pair(actor->GetId(), new_perc);
192 float new_perc = cg::Math::Clamp(perc,0.0f,100.0f);
193 const auto entry = std::make_pair(actor->GetId(), new_perc);
198 float new_radius = std::max(radius, 0.0f);
207 const auto entry = std::make_pair(actor->GetId(), path);
209 const auto entry2 = std::make_pair(actor->GetId(), empty_buffer);
223 const auto entry = std::make_pair(actor_id, path);
228 const auto entry = std::make_pair(actor->GetId(), route);
230 const auto entry2 = std::make_pair(actor->GetId(), empty_buffer);
244 const auto entry = std::make_pair(actor_id, route);
273 return speed_limit * (1.0f - percentage_difference / 100.0f);
298 bool avoid_collision =
true;
302 avoid_collision =
false;
305 return avoid_collision;
318 return change_lane_info;
323 float percentage = -1.0f;
334 float percentage = -1.0f;
345 float percentage = -1.0f;
356 bool auto_lane_change_policy =
true;
362 return auto_lane_change_policy;
367 float specific_distance_margin = 0.0f;
374 return specific_distance_margin;
379 float percentage = 0.0f;
390 float percentage = 0.0f;
401 float percentage = 0.0f;
411 bool do_update =
false;
422 float percentage = 0.0f;
459 bool custom_path_bool =
false;
465 return custom_path_bool;
470 Path custom_path_import;
476 return custom_path_import;
482 bool custom_route_bool =
false;
488 return custom_route_bool;
493 Route custom_route_import;
499 return custom_route_import;
void RemoveEntry(const Key &key)
const Value & GetValue(const Key &key) const
bool Contains(const Key &key) const
void AddEntry(const std::pair< Key, Value > &entry)
float GetRandomLeftLaneChangePercentage(const ActorId &actor_id)
Method to query percentage probability of a random right lane change for a vehicle.
void SetGlobalLargeVehicleWideTurn(const bool enable)
Method to enable/disable the wide-turn manoeuvre globally for all large vehicles.
std::atomic< float > respawn_lower_bound
Minimum distance to respawn vehicles with respect to the hero vehicle.
float GetPercentageIgnoreWalkers(const ActorId &actor_id) const
Method to get % to ignore any walker.
AtomicMap< ActorId, ChangeLaneInfo > force_lane_change
Map containing force lane change commands.
ChangeLaneInfo GetForceLaneChange(const ActorId &actor_id)
Method to query lane change command for a vehicle.
AtomicMap< ActorId, bool > auto_lane_change
Map containing auto lane change commands.
bool GetLargeVehicleWideTurn(const ActorId &actor_id) const
Method to query whether the wide-turn manoeuvre is enabled for a large vehicle (per-vehicle override,...
float GetLaneOffset(const ActorId &actor_id) const
Method to query lane offset for a vehicle.
AtomicMap< ActorId, bool > upload_path
Parameter specifying if importing a custom path.
void SetLaneOffset(const ActorPtr &actor, const float offset)
Method to set a lane offset displacement from the center line.
float GetDistanceToLeadingVehicle(const ActorId &actor_id) const
Method to query distance to leading vehicle for a given vehicle.
void SetKeepSlowLanePercentage(const ActorPtr &actor, const float percentage)
Method to set % to keep on the slow lane.
void SetImportedRoute(const ActorPtr &actor, const Route route, const bool empty_buffer)
Method to set our own imported route.
bool GetCollisionDetection(const ActorId &reference_actor_id, const ActorId &other_actor_id) const
Method to query collision avoidance rule between a pair of vehicles.
void SetHybridPhysicsRadius(const float radius)
Method to set hybrid physics radius.
Route GetImportedRoute(const ActorId &actor_id) const
Method to get a custom route.
float global_lane_offset
Global lane offset.
float global_percentage_difference_from_limit
Global target velocity limit % difference.
std::atomic< bool > synchronous_mode
Synchronous mode switch.
float GetKeepSlowLanePercentage(const ActorId &actor_id)
Method to query percentage probability of keep slow lane rule for a vehicle.
double GetSynchronousModeTimeOutInMiliSecond() const
Get synchronous mode time out.
std::atomic< float > distance_margin
Distance margin.
std::chrono::duration< double, std::milli > synchronous_time_out
Synchronous mode time out variable.
std::atomic< float > hybrid_physics_radius
Hybrid physics radius.
bool GetUploadRoute(const ActorId &actor_id) const
Method to get if we are uploading a route.
AtomicMap< ActorId, bool > large_vehicle_wide_turn
Per-vehicle enable flag for the large-vehicle wide-turn manoeuvre.
void UpdateUploadPath(const ActorId &actor_id, const Path path)
Method to update an already set list of points.
bool GetOSMMode() const
Method to get Open Street Map mode.
void SetRandomLeftLaneChangePercentage(const ActorPtr &actor, const float percentage)
Method to set % to randomly do a left lane change.
void SetGlobalDistanceToLeadingVehicle(const float dist)
Method to set the distance to leading vehicle for all registered vehicles.
AtomicMap< ActorId, float > perc_random_left
Map containing % of random left lane change.
AtomicMap< ActorId, float > perc_ignore_walkers
Map containing % of ignoring walkers.
float GetHybridPhysicsRadius() const
Method to retrieve hybrid physics radius.
void UpdateImportedRoute(const ActorId &actor_id, const Route route)
Method to update an already set route.
float GetVehicleTargetVelocity(const ActorId &actor_id, const float speed_limit) const
Method to query target velocity for a vehicle.
void SetGlobalLaneOffset(float const offset)
Method to set a global lane offset displacement from the center line.
AtomicMap< ActorId, float > exact_desired_speed
Target velocity map for individual vehicles, based on a desired velocity.
AtomicMap< ActorId, bool > upload_route
Parameter specifying if importing a custom route.
bool GetUploadPath(const ActorId &actor_id) const
Method to get if we are uploading a path.
float min_lower_bound
Minimum possible distance to respawn vehicles with respect to the hero vehicle.
void SetDistanceToLeadingVehicle(const ActorPtr &actor, const float distance)
Method to specify how much distance a vehicle should maintain to the leading vehicle.
float GetUpperBoundaryRespawnDormantVehicles() const
Method to retrieve maximum distance from hero vehicle when respawning vehicles.
float GetRandomRightLaneChangePercentage(const ActorId &actor_id)
Method to query percentage probability of a random left lane change for a vehicle.
void SetForceLaneChange(const ActorPtr &actor, const bool direction)
Method to force lane change on a vehicle.
AtomicMap< ActorId, float > perc_run_traffic_light
Map containing % of running a traffic light.
float GetLowerBoundaryRespawnDormantVehicles() const
Method to retrieve minimum distance from hero vehicle when respawning vehicles.
void SetPercentageRunningSign(const ActorPtr &actor, const float perc)
Method to set % to run any traffic sign.
void SetCustomPath(const ActorPtr &actor, const Path path, const bool empty_buffer)
Method to set our own imported path.
std::atomic< bool > hybrid_physics_mode
Hybrid physics mode switch.
void RemoveImportedRoute(const ActorId &actor_id, const bool remove_path)
Method to remove a route.
bool GetAutoLaneChange(const ActorId &actor_id) const
Method to query auto lane change rule for a vehicle.
void SetPercentageIgnoreVehicles(const ActorPtr &actor, const float perc)
Method to set % to ignore any vehicle.
void SetMaxBoundaries(const float lower, const float upper)
Method to set limits for boundaries when respawning vehicles.
void SetSynchronousModeTimeOutInMiliSecond(const double time)
Set Synchronous mode time out.
void SetHybridPhysicsMode(const bool mode_switch)
Method to set hybrid physics mode.
AtomicMap< ActorId, float > perc_random_right
Map containing % of random right lane change.
float GetPercentageRunningSign(const ActorId &actor_id) const
Method to get % to run any traffic light.
void SetCollisionDetection(const ActorPtr &reference_actor, const ActorPtr &other_actor, const bool detect_collision)
Method to set collision detection rules between vehicles.
bool GetRespawnDormantVehicles() const
Method to retrieve if we are automatically respawning vehicles.
AtomicMap< ActorId, std::shared_ptr< AtomicActorSet > > ignore_collision
Map containing a set of actors to be ignored during collision detection.
AtomicMap< ActorId, float > perc_keep_slow_lane
Map containing % of keep slow lane rule.
void SetPercentageRunningLight(const ActorPtr &actor, const float perc)
Method to set % to run any traffic light.
AtomicMap< ActorId, float > perc_run_traffic_sign
Map containing % of running a traffic sign.
void SetRespawnDormantVehicles(const bool mode_switch)
Method to set if we are automatically respawning vehicles.
std::atomic< bool > osm_mode
Parameter specifying Open Street Map mode.
Path GetCustomPath(const ActorId &actor_id) const
Method to get a custom path.
void SetAutoLaneChange(const ActorPtr &actor, const bool enable)
Enable/disable automatic lane change on a vehicle.
AtomicMap< ActorId, float > distance_to_leading_vehicle
Map containing distance to leading vehicle command.
float GetPercentageIgnoreVehicles(const ActorId &actor_id) const
Method to get % to ignore any vehicle.
void SetDesiredSpeed(const ActorPtr &actor, const float value)
Set a vehicle's exact desired velocity.
void RemoveUploadPath(const ActorId &actor_id, const bool remove_path)
Method to remove a list of points.
bool GetSynchronousMode() const
Method to get synchronous mode.
void SetGlobalPercentageSpeedDifference(float const percentage)
Set a global % decrease in velocity with respect to the speed limit.
std::atomic< bool > respawn_dormant_vehicles
Automatic respawn mode switch.
AtomicMap< ActorId, float > lane_offset
Lane offset map for individual vehicles.
void SetPercentageIgnoreWalkers(const ActorPtr &actor, const float perc)
Method to set % to ignore any vehicle.
float GetPercentageRunningLight(const ActorId &actor_id) const
Method to get % to run any traffic light.
bool global_large_vehicle_wide_turn
Global enable flag for the large-vehicle wide-turn manoeuvre.
void SetBoundariesRespawnDormantVehicles(const float lower_bound, const float upper_bound)
Method to set boundaries for respawning vehicles.
bool GetUpdateVehicleLights(const ActorId &actor_id) const
Method to get if the vehicle lights should be updates automatically.
void SetRandomRightLaneChangePercentage(const ActorPtr &actor, const float percentage)
Method to set % to randomly do a right lane change.
void SetPercentageSpeedDifference(const ActorPtr &actor, const float percentage)
Set a vehicle's % decrease in velocity with respect to the speed limit.
AtomicMap< ActorId, bool > auto_update_vehicle_lights
Map containing the automatic vehicle lights update flag.
std::atomic< float > respawn_upper_bound
Maximum distance to respawn vehicles with respect to the hero vehicle.
AtomicMap< ActorId, Route > custom_route
Structure to hold all custom routes.
AtomicMap< ActorId, float > perc_ignore_vehicles
Map containing % of ignoring vehicles.
AtomicMap< ActorId, float > percentage_difference_from_speed_limit
Target velocity map for individual vehicles, based on a % diffrerence from speed limit.
void SetOSMMode(const bool mode_switch)
Method to set Open Street Map mode.
AtomicMap< ActorId, Path > custom_path
Structure to hold all custom paths.
bool GetHybridPhysicsMode() const
Method to retrieve hybrid physics mode.
void SetLargeVehicleWideTurn(const ActorPtr &actor, const bool enable)
Method to enable/disable the wide-turn manoeuvre for a single large vehicle (bus/truck).
void SetSynchronousMode(const bool mode_switch=true)
Method to set synchronous mode.
void SetUpdateVehicleLights(const ActorPtr &actor, const bool do_update)
Method to set the automatic vehicle light state update flag.
float max_upper_bound
Maximum possible distance to respawn vehicles with respect to the hero vehicle.
std::vector< uint8_t > Route
std::vector< cg::Location > Path
carla::SharedPtr< cc::Actor > ActorPtr
This file contains definitions of common data structures used in traffic manager.