make follower proceed to end of lane after following. and classify

intervals for easier reading.
This commit is contained in:
Dustin Carlino 2019-02-15 13:02:10 -08:00
parent 6b0a70268c
commit 8aee575056
2 changed files with 17 additions and 7 deletions

View File

@ -130,9 +130,22 @@ impl Interval {
impl fmt::Display for Interval {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let kind = if self.start_speed == Speed::ZERO && self.end_speed == Speed::ZERO {
"wait"
} else if self.start_speed == Speed::ZERO {
"accelerate from rest"
} else if self.end_speed == Speed::ZERO {
"decelerate to rest"
} else if self.start_speed == self.end_speed {
"freeflow"
} else {
"other"
};
write!(
f,
"{}->{} during {}->{} ({}->{})",
"[{}] {}->{} during {}->{} ({}->{})",
kind,
self.start_dist,
self.end_dist,
self.start_time,

View File

@ -43,16 +43,13 @@ impl World {
start_time: Duration::seconds(4.0),
};
follower.stop_at_end_of_lane(lane, speed_limit);
follower.maybe_follow(&mut leader);
follower.stop_at_end_of_lane(lane, speed_limit);
follower.wait(Duration::seconds(5.0));
println!("Leader:\n");
leader.dump_intervals();
println!("\nOriginal follower:\n");
follower.dump_intervals();
println!();
follower.maybe_follow(&mut leader);
println!("\nAdjusted follower:\n");
println!("\nFollower:\n");
follower.dump_intervals();
println!();