Expand description
The sim crate runs a traffic simulation on top of the map_model. See also https://a-b-street.github.io/docs/tech/trafficsim/index.html.
The simulation is very roughly layered into two pieces: the low-level βmechanicsβ of simulating individual agents over time, and higher-level systems like TripManager and TransitSimState that glue together individual goals executed by the agents.
Helpful terminology:
- sov = single occupancy vehicle, a car with just a driver and no passengers. (Car passengers are not currently modelled)
Re-exportsΒ§
pub use self::prebake::PrebakeSummary;
ModulesΒ§
- analytics π
- events π
- make π
- Everything needed to setup a simulation.
- mechanics π
- pandemic π
- An experimental SEIR model by https://github.com/omalaspinas/ glued to the traffic simulation. Transmission may occur when people spend time in shared spaces like buildings, bus stops, and buses.
- prebake
- recorder π
- render π
- Intermediate structures so that sim and game crates donβt have a cyclic dependency.
- router π
- For vehicles only, not pedestrians. Follows a Path from map_model, but can opportunistically lane-change to avoid a slow lane, can can handle re-planning to look for available parking.
- scheduler π
- sim π
- transit π
- trips π
StructsΒ§
- Agent
Properties - Analytics
- As a simulation runs, different pieces emit Events. The Analytics object listens to these, organizing and storing some information from them. The UI queries Analytics to draw time-series and display statistics.
- Border
Spawn Over Time - CarID
- Commuters
Vehicles Counts - The number of active vehicles and commuters, broken into different categories.
- Create
Car π - Create
Pedestrian π - Distance
Interval π - Draw
CarInput - Draw
PedCrowd Input - Draw
Pedestrian Input - Parked
Car - PedestrianID
- Person
- PersonID
- Scenario
Generator - Sidewalk
Spot π - Sim
- The Sim ties together all the pieces of the simulation. Its main property is the current time.
- SimFlags
- SimFlags specifies a simulation to setup. After parsing from structopt, you must call
initialize
. - SimOptions
- Options controlling the traffic simulation.
- Sliding
Window - A sliding window, used to count something over time
- Spawn
Over Time - Time
Interval π - TripID
- Trip
Info - Trip
Phase - Unzoomed
Agent - Vehicle
- Vehicle
Spec
EnumsΒ§
- AgentID
- Agent
Type - Alert
Handler - Alert
Location - CarStatus
- Delay
Cause - Why is an agent delayed? If there are multiple reasons, arbitrarily pick one β ie, somebody could be blocked by two conflicting turns.
- Driving
Goal π - Intent
- Shows an agentβs current inner intention or thoughts.
- Parking
Spot - PedCrowd
Location - Person
State - Problem
- Problem
Type - SidewalkPOI π
- Point of interest, that is
- Trip
Phase Type - Trip
Result - Vehicle
Type
ConstantsΒ§
- BIKE_
LENGTH π - BUS_
LENGTH π - FOLLOWING_
DISTANCE π - At all speeds (including at rest), cars must be at least this far apart, measured from front of one car to the back of the other.
- LIGHT_
RAIL_ πLENGTH - MAX_
CAR_ πLENGTH - MIN_
CAR_ πLENGTH - SPAWN_
DIST π - When spawning at borders, start the front of the vehicle this far along and gradually appear. Getting too close to EPSILON_DIST can lead to get_draw_car having no geometry at all.
TraitsΒ§
FunctionsΒ§
- count_
parked_ cars_ per_ bldg - fork_
rng - Need to explain this trick β basically keeps consistency between two different simulations when each one might make slightly different sequences of calls to the RNG.
- pedestrian_
body_ radius - rand_
dist