CARLA
TrafficLightStage.h
Go to the documentation of this file.
1 
2 #pragma once
3 
9 
10 namespace carla {
11 namespace traffic_manager {
12 
13 /// This class has functionality for responding to traffic lights
14 /// and managing entry into non-signalized junctions.
16 private:
17  const std::vector<ActorId> &vehicle_id_list;
21  const cc::World &world;
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 containing the vehicles exiting a specific junction.
28  std::unordered_map<JunctionID, std::deque<ActorId>> exiting_vehicles_map;
29  /// Map linking the vehicles with their current junction. Used for easy access to the previous two maps.
30  std::unordered_map<ActorId, JunctionID> vehicle_last_junction;
31  /// Map containing the timestamp at which the actor first stopped at a stop sign.
32  std::unordered_map<ActorId, cc::Timestamp> vehicle_stop_time;
36 
37  /// This controls all vehicle's interactions at non signalized junctions. Priorities are done by order of arrival
38  /// and no two vehicle will enter the junction at the same time. Only once it is exiting can the next one enter.
39  /// Additionally, all vehicles will always brake at the stop sign for a set amount of time.
40  bool HandleNonSignalisedJunction(const ActorId ego_actor_id, const Junction junction,
41  const Buffer &waypoint_buffer, cc::Timestamp timestamp);
42 
43  /// Initialized the vehicle to the non-signalized junction maps
44  void AddActorToNonSignalisedJunction(const ActorId ego_actor_id, const Junction junction);
45 
46 public:
47  TrafficLightStage(const std::vector<ActorId> &vehicle_id_list,
48  const SimulationState &Simulation_state,
49  const BufferMap &buffer_map,
50  const Parameters &parameters,
51  const cc::World &world,
52  TLFrame &output_array,
53  RandomGenerator &random_device);
54 
55  void Update(const unsigned long index) override;
56 
57  void RemoveActor(const ActorId actor_id) override;
58 
59  void Reset() override;
60 };
61 
62 } // namespace traffic_manager
63 } // namespace carla
void AddActorToNonSignalisedJunction(const ActorId ego_actor_id, const Junction junction)
Initialized the vehicle to the non-signalized junction maps.
std::vector< bool > TLFrame
This class holds the state of all the vehicles in the simlation.
This file contains definitions of common data structures used in traffic manager. ...
Definition: Carla.cpp:133
std::deque< std::shared_ptr< SimpleWaypoint > > Buffer
void RemoveActor(const ActorId actor_id) override
std::unordered_map< carla::ActorId, Buffer > BufferMap
void Update(const unsigned long index) override
const std::vector< ActorId > & vehicle_id_list
carla::ActorId ActorId
std::unordered_map< JunctionID, std::deque< ActorId > > exiting_vehicles_map
Map containing the vehicles exiting a specific junction.
std::unordered_map< JunctionID, std::deque< ActorId > > entering_vehicles_map
Variables used to handle non signalized junctions.
This class has functionality for responding to traffic lights and managing entry into non-signalized ...
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)
Stage type interface.
Definition: Stage.h:12
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...
bool HandleNonSignalisedJunction(const ActorId ego_actor_id, const Junction junction, const Buffer &waypoint_buffer, cc::Timestamp timestamp)
This controls all vehicle&#39;s interactions at non signalized junctions.
std::unordered_map< ActorId, cc::Timestamp > vehicle_stop_time
Map containing the timestamp at which the actor first stopped at a stop sign.
carla::SharedPtr< carla::client::Junction > Junction