8namespace traffic_manager {
18 const std::vector<ActorId> &vehicle_id_list,
25 : vehicle_id_list(vehicle_id_list),
26 simulation_state(simulation_state),
27 buffer_map(buffer_map),
28 parameters(parameters),
30 output_array(output_array),
31 random_device(random_device) {}
35 bool traffic_light_hazard =
false;
53 if (is_at_traffic_light &&
54 traffic_light_state != TLS::Green &&
55 traffic_light_state != TLS::Off &&
58 if (current_junction_id != -1) {
61 traffic_light_hazard =
true;
65 else if (current_junction_id != -1) {
66 if (affected_junction_id == -1 || affected_junction_id != current_junction_id) {
73 else if (affected_junction_id != -1 &&
74 !is_at_traffic_light &&
75 traffic_light_state != TLS::Green &&
79 traffic_light_hazard =
true;
90 std::deque<ActorId> entry_deque;
95 if (std::find(entering_vehicles.begin(), entering_vehicles.end(), ego_actor_id) == entering_vehicles.end()){
97 entering_vehicles.push_back(ego_actor_id);
109 bool traffic_light_hazard =
false;
118 traffic_light_hazard =
true;
121 else if (entering_vehicles.front() == ego_actor_id) {
123 if (timestamp.
elapsed_seconds - entry_elapsed_seconds < MINIMUM_STOP_TIME) {
125 traffic_light_hazard =
true;
129 traffic_light_hazard =
true;
131 return traffic_light_hazard;
137 const auto front_point = waypoint_buffer.front();
139 auto look_ahead_junction_id = look_ahead_point->GetJunctionId();
140 auto front_junction_id = front_point->GetJunctionId();
148 if (current_junction_id != -1) {
149 if (current_junction_id == look_ahead_junction_id) {
150 return look_ahead_junction_id;
152 if (look_ahead_junction_id != -1) {
154 return look_ahead_junction_id;
156 if (current_junction_id == front_junction_id) {
158 return front_junction_id;
166 return look_ahead_junction_id;
175 auto ent_index = std::find(entering_vehicles.begin(), entering_vehicles.end(), actor_id);
176 if (ent_index != entering_vehicles.end()) {
177 entering_vehicles.erase(ent_index);
double elapsed_seconds
模拟自当前情境开始以来经过的秒数。
const Timestamp & GetTimestamp() const
WorldSnapshot GetSnapshot() const
返回当前世界的快照。 快照(Snapshot)包含了模拟世界在某一时刻的整体状态信息,例如所有参与者的位置、状态,天气情况等, 可以用于记录、对比不同时刻的世界状态或者进行一些基于特定时刻状态的分析和操...
float GetPercentageRunningSign(const ActorId &actor_id) const
获取百分比以运行任何交通灯的方法
float GetPercentageRunningLight(const ActorId &actor_id) const
获取百分比以运行任何交通灯的方法
cg::Vector3D GetVelocity(const ActorId actor_id) const
TrafficLightState GetTLS(const ActorId actor_id) const
bool IsDormant(const ActorId actor_id) const
const Parameters & parameters
void AddActorToNonSignalisedJunction(const ActorId ego_actor_id, const JunctionID junction_id)
void Update(const unsigned long index) override
更新方法。
JunctionID GetAffectedJunctionId(const ActorId ego_actor_id)
std::unordered_map< ActorId, JunctionID > vehicle_last_junction
std::unordered_map< ActorId, cc::Timestamp > vehicle_stop_time
void RemoveActor(const ActorId actor_id) override
移除参与者方法。
const std::vector< ActorId > & vehicle_id_list
std::unordered_map< JunctionID, std::deque< ActorId > > entering_vehicles_map
const BufferMap & buffer_map
void Reset() override
重置方法。
cc::Timestamp current_timestamp
bool HandleNonSignalisedJunction(const ActorId ego_actor_id, const JunctionID junction_id, cc::Timestamp timestamp)
RandomGenerator & random_device
TrafficLightStage(const std::vector< ActorId > &vehicle_id_list, const SimulationState &Simulation_state, const BufferMap &buffer_map, const Parameters ¶meters, const cc::World &world, TLFrame &output_array, RandomGenerator &random_device)
const SimulationState & simulation_state
static const float EPSILON_RELATIVE_SPEED
static const double EXIT_JUNCTION_THRESHOLD
static const double MINIMUM_STOP_TIME
static const float JUNCTION_LOOK_AHEAD
std::vector< bool > TLFrame
std::deque< std::shared_ptr< SimpleWaypoint > > Buffer
carla::road::JuncId JunctionID
std::shared_ptr< SimpleWaypoint > SimpleWaypointPtr
TargetWPInfo GetTargetWaypoint(const Buffer &waypoint_buffer, const float &target_point_distance)
carla::ActorId ActorId
参与者的智能指针类型
std::unordered_map< carla::ActorId, Buffer > BufferMap