correct slight overshooting. investigate a bus reaching a stop with

non-zero speed
This commit is contained in:
Dustin Carlino 2019-02-03 18:18:10 -08:00
parent 7b045146da
commit 2f812e6265
4 changed files with 29 additions and 3 deletions

View File

@ -20,6 +20,7 @@
- http://www.seattle.gov/seattle-pedestrian-advisory-board
- Socrata
- http://transportationcamp.org/
- https://www.seattle.gov/transportation/projects-and-programs/programs/neighborhood-street-fund / https://www.seattle.gov/neighborhoods/programs-and-services/your-voice-your-choice
## Similar projects

View File

@ -375,7 +375,16 @@ impl Car {
Some(Intent::StopAt(lane, dist)) => {
if self.on == Traversable::Lane(lane) {
if self.dist_along > dist {
panic!("{} overshot! Wanted to stop at {} along {}, but at {}. Speed is {}. This last step, they chose {}, with their max being {}, and consequently traveled {}", self.id, dist, lane, self.dist_along, self.speed, accel, self.vehicle.max_deaccel, dist_traveled);
// But be generous, maybe.
if self.dist_along - dist <= EPSILON_DIST && self.speed.is_zero(TIMESTEP) {
error!(
"{} overshot just a little bit on {}, so being generous.",
self.id, lane
);
self.dist_along = dist;
} else {
panic!("{} overshot! Wanted to stop at {} along {}, but at {}. Speed is {}. This last step, they chose {}, with their max being {}, and consequently traveled {}", self.id, dist, lane, self.dist_along, self.speed, accel, self.vehicle.max_deaccel, dist_traveled);
}
}
if self.dist_along == dist && !self.speed.is_zero(TIMESTEP) {
panic!("{} stopped right where they want to, but with a final speed of {}. This last step, they chose {}, with their max being {}", self.id, self.speed, accel, self.vehicle.max_deaccel);

View File

@ -308,7 +308,7 @@ pub fn results_of_accel_for_one_tick(
assert_ge!(dist, Distance::ZERO);
let new_speed = initial_speed + (accel * actual_time);
// Deal with floating point imprecision.
if new_speed < Speed::ZERO && new_speed.is_zero(TIMESTEP) {
if new_speed.is_zero(TIMESTEP) {
(dist, Speed::ZERO)
} else {
assert_ge!(new_speed, Speed::ZERO);

View File

@ -4,7 +4,7 @@ use crate::spawn::Spawner;
use crate::trips::TripManager;
use crate::view::AgentView;
use crate::walking::WalkingSimState;
use crate::{CarID, PedestrianID, Tick};
use crate::{CarID, PedestrianID, Tick, TIMESTEP};
use abstutil::{deserialize_btreemap, serialize_btreemap};
use geom::{Distance, Duration};
use map_model::{BusRoute, BusRouteID, BusStop, LaneID, Map, Path, PathRequest, Pathfinder};
@ -141,6 +141,12 @@ impl TransitSimState {
let stop = &route.stops[stop_idx];
assert_eq!(stop.driving_pos.lane(), view.on.as_lane());
if stop.driving_pos.dist_along() == view.dist_along {
if !view.speed.is_zero(TIMESTEP) {
panic!(
"{} arrived at stop {}, but speed is {}",
car, stop.id, view.speed
);
}
// TODO constant for stop time
self.buses.get_mut(&car).unwrap().state =
BusState::AtStop(stop_idx, time + Duration::seconds(10.0));
@ -157,6 +163,16 @@ impl TransitSimState {
BusState::AtStop(stop_idx, wait_until) => {
let stop = &route.stops[stop_idx];
assert_eq!(stop.driving_pos.lane(), view.on.as_lane());
if stop.driving_pos.dist_along() != view.dist_along {
panic!(
"{} stopped at {}, but dist_along is {}, not {}. Speed is {}",
car,
stop.id,
view.dist_along,
stop.driving_pos.dist_along(),
view.speed
);
}
assert_eq!(stop.driving_pos.dist_along(), view.dist_along);
if time == wait_until {