CARLA
 
载入中...
搜索中...
未找到
ALSM.h
浏览该文件的文档.
1
2#pragma once
3
4#include <memory>
5
9#include "carla/Memory.h"
10
22
23namespace carla {
24namespace traffic_manager {
25
26using namespace constants::HybridMode;
27using namespace constants::VehicleRemoval;
28
29namespace chr = std::chrono;
30namespace cg = carla::geom;
31namespace cc = carla::client;
32
34using ActorMap = std::unordered_map<ActorId, ActorPtr>;
35using IdleTimeMap = std::unordered_map<ActorId, double>;
36using LocalMapPtr = std::shared_ptr<InMemoryMap>;
37
38/// ALSM: Agent Lifecycle and State Managerment
39/// This class has functionality to update the local cache of kinematic states
40/// and manage memory and cleanup for varying number of vehicles in the simulation.
41class ALSM {
42
43private:
45 // Structure containing vehicles in the simulator not registered with the traffic manager.
48 // Structure keeping track of duration of vehicles stuck in a location.
50 // Structure containing vehicles with attribute role_name with value hero.
53 // Array of vehicles marked by stages for removal.
54 std::vector<ActorId>& marked_for_removal;
64 // Time elapsed since last vehicle destruction due to being idle for too long.
67 std::unordered_map<ActorId, bool> has_physics_enabled;
68
69 // Updates the duration for which a registered vehicle is stuck at a location.
70 void UpdateIdleTime(std::pair<ActorId, double>& max_idle_time, const ActorId& actor_id);
71
72 // Method to determine if a vehicle is stuck at a place for too long.
73 bool IsVehicleStuck(const ActorId& actor_id);
74
75 // Method to identify actors newly spawned in the simulation since last tick.
76 void IdentifyNewActors(const ActorList &actor_list);
77
78 using DestroyeddActors = std::pair<ActorIdSet, ActorIdSet>;
79 // Method to identify actors deleted in the last frame.
80 // Arrays of registered and unregistered actors are returned separately.
82
83 using IdleInfo = std::pair<ActorId, double>;
84 void UpdateRegisteredActorsData(const bool hybrid_physics_mode, IdleInfo &max_idle_time);
85
86 void UpdateData(const bool hybrid_physics_mode, const Actor &vehicle,
87 const bool hero_actor_present, const float physics_radius_square);
88
90
91public:
95 std::vector<ActorId>& marked_for_removal,
97 const cc::World &world,
105
106 void Update();
107
108 // Removes an actor from traffic manager and performs clean up of associated data
109 // from various stages tracking the said vehicle.
110 void RemoveActor(const ActorId actor_id, const bool registered_actor);
111
112 void Reset();
113};
114
115} // namespace traffic_manager
116} // namespace carla
ALSM: Agent Lifecycle and State Managerment This class has functionality to update the local cache of...
Definition ALSM.h:41
ALSM(AtomicActorSet &registered_vehicles, BufferMap &buffer_map, TrackTraffic &track_traffic, std::vector< ActorId > &marked_for_removal, const Parameters &parameters, const cc::World &world, const LocalMapPtr &local_map, SimulationState &simulation_state, LocalizationStage &localization_stage, CollisionStage &collision_stage, TrafficLightStage &traffic_light_stage, MotionPlanStage &motion_plan_stage, VehicleLightStage &vehicle_light_stage)
Definition ALSM.cpp:17
const cc::World & world
Definition ALSM.h:56
void IdentifyNewActors(const ActorList &actor_list)
Definition ALSM.cpp:115
void RemoveActor(const ActorId actor_id, const bool registered_actor)
Definition ALSM.cpp:367
AtomicActorSet & registered_vehicles
Definition ALSM.h:44
LocalizationStage & localization_stage
Definition ALSM.h:59
const LocalMapPtr & local_map
Definition ALSM.h:57
std::unordered_map< ActorId, bool > has_physics_enabled
Definition ALSM.h:67
VehicleLightStage & vehicle_light_stage
Definition ALSM.h:63
std::pair< ActorId, double > IdleInfo
Definition ALSM.h:83
bool IsVehicleStuck(const ActorId &actor_id)
Definition ALSM.cpp:354
MotionPlanStage & motion_plan_stage
Definition ALSM.h:62
IdleTimeMap idle_time
Definition ALSM.h:49
std::pair< ActorIdSet, ActorIdSet > DestroyeddActors
Definition ALSM.h:78
CollisionStage & collision_stage
Definition ALSM.h:60
void UpdateData(const bool hybrid_physics_mode, const Actor &vehicle, const bool hero_actor_present, const float physics_radius_square)
Definition ALSM.cpp:196
ActorMap unregistered_actors
Definition ALSM.h:46
cc::Timestamp current_timestamp
Definition ALSM.h:66
const Parameters & parameters
Definition ALSM.h:55
std::vector< ActorId > & marked_for_removal
Definition ALSM.h:54
SimulationState & simulation_state
Definition ALSM.h:58
void UpdateRegisteredActorsData(const bool hybrid_physics_mode, IdleInfo &max_idle_time)
Definition ALSM.cpp:169
BufferMap & buffer_map
Definition ALSM.h:47
TrafficLightStage & traffic_light_stage
Definition ALSM.h:61
void UpdateIdleTime(std::pair< ActorId, double > &max_idle_time, const ActorId &actor_id)
Definition ALSM.cpp:340
TrackTraffic & track_traffic
Definition ALSM.h:52
DestroyeddActors IdentifyDestroyedActors(const ActorList &actor_list)
Definition ALSM.cpp:137
double elapsed_last_actor_destruction
Definition ALSM.h:65
This class has functionality to detect potential collision with a nearby actor.
This class has functionality to maintain a horizon of waypoints ahead of the vehicle for it to follow...
This class holds the state of all the vehicles in the simlation.
This class has functionality for responding to traffic lights and managing entry into non-signalized ...
This class has functionality for turning on/off the vehicle lights according to the current vehicle s...
carla::SharedPtr< cc::Actor > Actor
carla::SharedPtr< cc::ActorList > ActorList
Definition ALSM.h:33
std::shared_ptr< InMemoryMap > LocalMapPtr
Definition ALSM.h:36
std::unordered_map< ActorId, double > IdleTimeMap
Definition ALSM.h:35
std::unordered_map< ActorId, ActorPtr > ActorMap
Definition ALSM.h:34
std::unordered_map< carla::ActorId, Buffer > BufferMap
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