CARLA
 
载入中...
搜索中...
未找到
TrafficLightStage.h
浏览该文件的文档.
1
2#pragma once
3
9
10namespace carla {
11namespace traffic_manager {
12
13/// This class has functionality for responding to traffic lights
14/// and managing entry into non-signalized junctions.
16private:
17 const std::vector<ActorId> &vehicle_id_list;
22
23 /// Variables used to handle non signalized junctions
24
25 /// Map containing the vehicles entering a specific junction, ordered by time of arrival.
26 std::unordered_map<JunctionID, std::deque<ActorId>> entering_vehicles_map;
27 /// Map linking the vehicles with their current junction. Used for easy access to the previous two maps.
28 std::unordered_map<ActorId, JunctionID> vehicle_last_junction;
29 /// Map containing the timestamp at which the actor first stopped at a stop sign.
30 std::unordered_map<ActorId, cc::Timestamp> vehicle_stop_time;
34
35 /// This controls all vehicle's interactions at non signalized junctions. Priorities are done by order of arrival
36 /// and no two vehicle will enter the junction at the same time. Only once it is exiting can the next one enter.
37 /// Additionally, all vehicles will always brake at the stop sign for a set amount of time.
38 bool HandleNonSignalisedJunction(const ActorId ego_actor_id, const JunctionID junction_id,
39 cc::Timestamp timestamp);
40
41 /// Initialized the vehicle to the non-signalized junction maps
42 void AddActorToNonSignalisedJunction(const ActorId ego_actor_id, const JunctionID junction_id);
43
44 /// Get current affected junction id for the vehicle
45 JunctionID GetAffectedJunctionId(const ActorId ego_actor_id);
46
47public:
48 TrafficLightStage(const std::vector<ActorId> &vehicle_id_list,
49 const SimulationState &Simulation_state,
50 const BufferMap &buffer_map,
52 const cc::World &world,
55
56 void Update(const unsigned long index) override;
57
58 void RemoveActor(const ActorId actor_id) override;
59
60 void Reset() override;
61};
62
63} // namespace traffic_manager
64} // namespace carla
This class holds the state of all the vehicles in the simlation.
Stage type interface.
Definition Stage.h:12
This class has functionality for responding to traffic lights and managing entry into non-signalized ...
void AddActorToNonSignalisedJunction(const ActorId ego_actor_id, const JunctionID junction_id)
Initialized the vehicle to the non-signalized junction maps
void Update(const unsigned long index) override
JunctionID GetAffectedJunctionId(const ActorId ego_actor_id)
Get current affected junction id for the vehicle
std::unordered_map< ActorId, JunctionID > vehicle_last_junction
Map linking the vehicles with their current junction. Used for easy access to the previous two maps.
std::unordered_map< ActorId, cc::Timestamp > vehicle_stop_time
Map containing the timestamp at which the actor first stopped at a stop sign.
void RemoveActor(const ActorId actor_id) override
const std::vector< ActorId > & vehicle_id_list
std::unordered_map< JunctionID, std::deque< ActorId > > entering_vehicles_map
Variables used to handle non signalized junctions
bool HandleNonSignalisedJunction(const ActorId ego_actor_id, const JunctionID junction_id, cc::Timestamp timestamp)
This controls all vehicle's interactions at non signalized junctions.
TrafficLightStage(const std::vector< ActorId > &vehicle_id_list, const SimulationState &Simulation_state, const BufferMap &buffer_map, const Parameters &parameters, const cc::World &world, TLFrame &output_array, RandomGenerator &random_device)
std::vector< bool > TLFrame
carla::road::JuncId JunctionID
std::unordered_map< carla::ActorId, Buffer > BufferMap
This file contains definitions of common data structures used in traffic manager.
Definition Carla.cpp:133