unstick a poor pedestrian who couldn't cross a SharedSidewalkCorner in

the signal time. be reasonably loud when a turn is impossible to finish
in the cycle duration.
This commit is contained in:
Dustin Carlino 2019-08-12 11:51:39 -07:00
parent a37b3fe58c
commit 51cfd49a43
2 changed files with 14 additions and 10 deletions

View File

@ -62,7 +62,6 @@ fn warp_point(line: &str, primary: &PerMapUI) -> Option<(ID, Pt2D)> {
if let Some(r) = primary.map.maybe_get_r(id) {
ID::Lane(r.children_forwards[0].0)
} else {
println!("{} doesn't exist", id);
return None;
}
}
@ -76,7 +75,6 @@ fn warp_point(line: &str, primary: &PerMapUI) -> Option<(ID, Pt2D)> {
if let Some(id) = primary.sim.lookup_car_id(idx) {
ID::Car(id)
} else {
println!("Car {} doesn't exist", idx);
return None;
}
}
@ -85,7 +83,6 @@ fn warp_point(line: &str, primary: &PerMapUI) -> Option<(ID, Pt2D)> {
if let Some(id) = primary.map.lookup_turn_by_idx(idx) {
ID::Turn(id)
} else {
println!("{} isn't a known TurnID", line);
return None;
}
}
@ -99,7 +96,6 @@ fn warp_point(line: &str, primary: &PerMapUI) -> Option<(ID, Pt2D)> {
{
ID::Intersection(i.id)
} else {
println!("{} isn't known", stable_id);
return None;
}
}
@ -113,12 +109,10 @@ fn warp_point(line: &str, primary: &PerMapUI) -> Option<(ID, Pt2D)> {
{
ID::Lane(r.children_forwards[0].0)
} else {
println!("{} isn't known", stable_id);
return None;
}
}
_ => {
println!("{} isn't a valid ID; Should be [libepct][0-9]+", line);
return None;
}
},
@ -130,7 +124,6 @@ fn warp_point(line: &str, primary: &PerMapUI) -> Option<(ID, Pt2D)> {
println!("Warping to {:?}", id);
Some((id, pt))
} else {
println!("{:?} doesn't exist", id);
None
}
}

View File

@ -5,7 +5,7 @@ use abstutil::{deserialize_btreemap, serialize_btreemap};
use geom::Duration;
use map_model::{
ControlStopSign, ControlTrafficSignal, IntersectionID, IntersectionType, LaneID, Map, TurnID,
TurnPriority,
TurnPriority, TurnType,
};
use serde_derive::{Deserialize, Serialize};
use std::collections::{BTreeMap, BTreeSet, HashSet};
@ -292,6 +292,13 @@ impl State {
maybe_car_and_target_queue: Option<(&mut Queue, &Car)>,
map: &Map,
) -> bool {
let turn = map.get_t(new_req.turn);
// SharedSidewalkCorner doesn't conflict with anything -- fastpath!
if turn.turn_type == TurnType::SharedSidewalkCorner {
return true;
}
let (_, cycle, remaining_cycle_time) = signal.current_cycle_and_remaining_time(time);
// Can't go at all this cycle.
@ -305,7 +312,6 @@ impl State {
}
// A yield loses to a conflicting Priority turn.
let turn = map.get_t(new_req.turn);
if cycle.get_priority(new_req.turn) == TurnPriority::Yield {
if self.waiting.keys().any(|r| {
turn.conflicts_with(map.get_t(r.turn))
@ -323,7 +329,12 @@ impl State {
// it wrong, that's fine -- block the box a bit.
let time_to_cross = turn.geom.length() / speed;
if time_to_cross > remaining_cycle_time {
return false;
// Actually, we might have bigger problems...
if time_to_cross > cycle.duration {
println!("OYYY! {:?} is impossible to fit into cycle duration of {}. Allowing, but fix the policy!", new_req, cycle.duration);
} else {
return false;
}
}
// Don't block the box