-
-
Notifications
You must be signed in to change notification settings - Fork 355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Delay highlighting #363
Delay highlighting #363
Conversation
Bike also works, but is treated as a car, so the avg speed is flagged as very slow (Needs fix)
Now uses min of (speed limit and vehicle max speed) for the maximum speed check Added trip blocked time query Lots of work on tool tips Icons are broke
Color assertion?
Added new custom TextSpan size function
# Conflicts: # game/src/colors.rs # game/src/info/trip.rs # geom/src/speed.rs # sim/src/analytics.rs # sim/src/events.rs # sim/src/lib.rs # sim/src/mechanics/driving.rs # sim/src/mechanics/walking.rs # sim/src/sim/queries.rs # sim/src/trips.rs # widgetry/src/text.rs
Doesn't quite match the existing "changes"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an awesome feature! I left lots of style comments; if you're pressed for time, feel free to focus on the other ones, and I can take care of the other things later.
@@ -2,24 +2,25 @@ use std::collections::BTreeMap; | |||
|
|||
use maplit::btreemap; | |||
|
|||
use geom::{ArrowCap, Distance, Duration, Percent, PolyLine, Polygon, Pt2D, Time}; | |||
use map_model::{Map, Path, PathStep}; | |||
use geom::{ArrowCap, Distance, Duration, Percent, Polygon, PolyLine, Pt2D, Time}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, the diff here reorders Polygon
and PolyLine
. cargo +nightly fmt
undoes this. I'll poke around for an option to make it act like CLion, but we might be stuck cleaning this up from time to time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's a tad annoying, and personally I prefer Polygon
first, because it's alphabetical. But I'm not sure why cargo +nightly fmt
does this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think cargo fmt
considers PolyLine as two words, split at the camel — So "Poly Line" comes before "Polygon"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The split makes sense. I'm less opinionated about what this looks like and more interested in automating consistency (thanks to a few years working with gofmt
). For now, I vote we continue to apply cargo +nightly fmt
. If we can find an option or other CLI tool to align more with CLion, that's fine too as long as it's not hard for everyone to run
@@ -248,7 +248,25 @@ impl DrivingSimState { | |||
transit: &mut TransitSimState, | |||
) -> bool { | |||
match car.state { | |||
CarState::Crossing(_, _) => { | |||
CarState::Crossing(time_int, dist_int) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, this is tricky. Crossing
to Queued
happens before the car reaches the end of the lane; they might even still be moving, stuck behind a slower vehicle. https://dabreegster.github.io/abstreet/trafficsim/discrete_event.html#cars gives more detail about this.
The delay at an intersection starts being counted here, at car.state = CarState::Queued { blocked_since: now }
. Maybe we can just show delays at intersections and leave it a bit unspecified why the delay happened -- because of congestion upstream in the target lane, because of slow signal timing, because of a long queue of vehicles, because of a single slow vehicle in front of faster ones, etc.
But for this PR, I think it's fine to keep measuring it this way; we'll iterate on it next.
sim/src/mechanics/driving.rs
Outdated
.max_speed | ||
.unwrap_or(Speed::meters_per_second(100.0)), | ||
); | ||
let speed_percent: u8 = ((avg_speed / max_speed) * 100.0) as u8; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should do this calculation in analytics.rs
instead. Here, just fire an Event::AgentCrossedLane(trip, lane, avg_speed, max_speed)
or something. The purpose of Event
is to decouple the simulation details here from whatever choices we make later in Analytics
about how to group/filter/process for data analysis/visualization.
sim/src/mechanics/driving.rs
Outdated
@@ -357,6 +375,14 @@ impl DrivingSimState { | |||
// Don't schedule a retry here. | |||
return false; | |||
} | |||
if let Some((trip, _)) = car.trip_and_person { | |||
let delay = (now - blocked_since).inner_seconds() as u8; | |||
// Maybe alter the minimum delay time to be recorded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same, the event should always be sent with the Duration
, and the filtering + transformation to u8
can happen later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, nice work! I pulled it down to give it a go, but I'm not yet familiar enough with the codebase to immediately understand how to see this feature in action. Can you provide instructions on how to access it?
One thing I did notice, was some undesirable spacing between the trip timeline and the mode indicator which seems new to this branch:
after (as of 6c54cad):
To clarify - this is the trip info panel that you see after clicking on an agent.
let phase_width = box_width * percent_duration; | ||
if idx == phases.len() - 1 { | ||
if let Some(p) = progress_along_path { | ||
icons.push(Widget::draw_batch( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Build break, I think this has to be icons_geom
now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I think just declaring let mut icons = Vec::new()
up by the others should fix it. icons_geom
is for the tooltips.
I regenerated the prebaked analytics data. montlake stayed the same size, and lakeslice increased from 61MB to 64MB -- that's a totally fine amount, nice! After we merge, I'll immediately followup with the uploaded data. This pretty much LGTM, minus the build break. And if you can, run |
Thanks for the PR! Going to merge this now, and follow up with the new prebaked data, some cleanups, and a fix for the timeline indicator icon. |
- cargo +nightly fmt - upload new prebaked data
Initial build for issue 170
Now highlights intersections and lanes for cars, bikes and walking. That have spent over the threshold (30s) time waiting.
This is highlighted on the map, and colour coordinated for the severity of the delay
In addition it is also shown as hotspots on the timeline bar, with more information available when hovered upon.
Also contains some "fixes" for Canocilsing imports @dabreegster
Including: