mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-27 16:36:02 +03:00
make the turn-conflict detector factor in blockages due to agents at the
front of an at-capacity queue
This commit is contained in:
parent
c0b5ead639
commit
4634205448
@ -340,10 +340,7 @@ impl DrivingSimState {
|
|||||||
now,
|
now,
|
||||||
map,
|
map,
|
||||||
scheduler,
|
scheduler,
|
||||||
Some((
|
Some((&car, &mut self.queues)),
|
||||||
self.queues.get_mut(&Traversable::Lane(t.dst)).unwrap(),
|
|
||||||
&car,
|
|
||||||
)),
|
|
||||||
) {
|
) {
|
||||||
// Don't schedule a retry here.
|
// Don't schedule a retry here.
|
||||||
return false;
|
return false;
|
||||||
|
@ -4,8 +4,8 @@ use crate::{AgentID, AlertLocation, CarID, Command, Event, Scheduler, Speed};
|
|||||||
use abstutil::{deserialize_btreemap, retain_btreeset, serialize_btreemap};
|
use abstutil::{deserialize_btreemap, retain_btreeset, serialize_btreemap};
|
||||||
use geom::{Duration, Time};
|
use geom::{Duration, Time};
|
||||||
use map_model::{
|
use map_model::{
|
||||||
ControlStopSign, ControlTrafficSignal, IntersectionID, LaneID, Map, RoadID, TurnID,
|
ControlStopSign, ControlTrafficSignal, IntersectionID, LaneID, Map, RoadID, Traversable,
|
||||||
TurnPriority, TurnType,
|
TurnID, TurnPriority, TurnType,
|
||||||
};
|
};
|
||||||
use serde_derive::{Deserialize, Serialize};
|
use serde_derive::{Deserialize, Serialize};
|
||||||
use std::collections::{BTreeMap, BTreeSet, HashSet};
|
use std::collections::{BTreeMap, BTreeSet, HashSet};
|
||||||
@ -217,7 +217,7 @@ impl IntersectionSimState {
|
|||||||
now: Time,
|
now: Time,
|
||||||
map: &Map,
|
map: &Map,
|
||||||
scheduler: &mut Scheduler,
|
scheduler: &mut Scheduler,
|
||||||
maybe_car_and_target_queue: Option<(&mut Queue, &Car)>,
|
maybe_car_and_queues: Option<(&Car, &mut BTreeMap<Traversable, Queue>)>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let req = Request { agent, turn };
|
let req = Request { agent, turn };
|
||||||
self.state
|
self.state
|
||||||
@ -241,7 +241,9 @@ impl IntersectionSimState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Don't block the box
|
// Don't block the box
|
||||||
if let Some((queue, car)) = maybe_car_and_target_queue {
|
if let Some((car, queues)) = maybe_car_and_queues {
|
||||||
|
assert_eq!(agent, AgentID::Car(car.vehicle.id));
|
||||||
|
let queue = queues.get_mut(&Traversable::Lane(turn.dst)).unwrap();
|
||||||
// TODO Disable this policy for a particular intersection where a traffic signal is
|
// TODO Disable this policy for a particular intersection where a traffic signal is
|
||||||
// surrounded by a tiny lane with almost no capacity. Generalization later, make
|
// surrounded by a tiny lane with almost no capacity. Generalization later, make
|
||||||
// progress for now.
|
// progress for now.
|
||||||
@ -249,6 +251,28 @@ impl IntersectionSimState {
|
|||||||
car,
|
car,
|
||||||
!self.dont_block_the_box || map.get_i(turn.parent).orig_id.osm_node_id == 53211694,
|
!self.dont_block_the_box || map.get_i(turn.parent).orig_id.osm_node_id == 53211694,
|
||||||
) {
|
) {
|
||||||
|
if self.break_turn_conflict_cycles {
|
||||||
|
// TODO Should we run the detector here?
|
||||||
|
if let Some(c) = queue.laggy_head {
|
||||||
|
self.blocked_by.insert((car.vehicle.id, c));
|
||||||
|
} else if let Some(c) = queue.cars.get(0) {
|
||||||
|
self.blocked_by.insert((car.vehicle.id, *c));
|
||||||
|
} else {
|
||||||
|
// Nobody's in the target lane, but there's somebody already in the
|
||||||
|
// intersection headed there, taking up all of the space.
|
||||||
|
self.blocked_by.insert((
|
||||||
|
car.vehicle.id,
|
||||||
|
self.state[&turn.parent]
|
||||||
|
.accepted
|
||||||
|
.iter()
|
||||||
|
.find(|r| r.turn.dst == turn.dst)
|
||||||
|
.unwrap()
|
||||||
|
.agent
|
||||||
|
.as_car(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user