|
This diagram shows the major modules of the Traffic Simulator and their relationships.
Many of the design decisions came directly from the High Level Design Document developed by the managers. The heirarchy of classes storing the data is very similar to the one envisioned by the managers.
The Simulator contains zero or more Roads, which have a start and an end point. A Road aggregates one or more Road Segments in a vector. Each of these Road Segments stores its own start and end points, plus characteristics of the Road (i.e. speed limit). A Road Segment contains one or more Lanes, which know the direction they are headed in, as well as their width. Lanes contain a vector of Vehicles. Vehicles contain a Driver Model and a color. All the aforementioned classes also contain a unique ID number. At each time step the Simulator calls update on each of its Roads. The Roads, in turn, call update on each of their Road Segments. Updates thus propagate downward to the Vehicles. It should also be mentioned that Intersections are a subclass of Road that add the ability to have traffic control (in the form of stop signs or stop lights).
Vehicle behavior is determined by the Driver Model. Somewhat unintuitively, the Driver Model also stores properties about the car, such as its length. Since all the information about the car except color is stored in the Driver Model, it may turn out to be simpler to combine the two classes.
Only Road Segments and Vehicles should ever need to draw themselves. Roads (including Intersections) and Lanes are merely used to organize the Road Segments and Vehicles, respectively. Lanes and Roads have no visual representation separate from Road Segments.
This collaboration diagram shows what happens when the Traffic Simulator Executable is first run.
This diagram depicts what occurs between the modules during one iteration of the simulation loop.
This diagram depicts what occurs when the user interacts with the system. The user first pauses the system, and then retrieves statistics pertaining to a particular car. The sequence for retrieving car statistics can also be applied to modifying statistics of a particular car. Furthermore, the sequence for saving the simulation mirrors that of pausing. If the user wishes to rewind the simulation, the sequence follows a combination of the pause command -- notifying the simulation of the timestep to return to, as well as updating the state of all the vehicles and roads, which is similarly depicted in the diagram above.
This diagram shows what happens when a vehicle changes lanes.
This diagram depicts the process of moving from one road segment to another, which involves the vehicle getting a pointer to the next lane.
This diagram shows how a Driver determines its path through an intersection. Note that this will allow for pathfinding to be added later, as the Driver determines which path to take, based on the options.
This activity diagram shows the general flow of the program and user interaction.
The software is to be designed in five levels of incremental features.
| Module Evolution | ||||
|
|
Milestone 2 |
Milestone 3 |
Milestone 4 |
Milestone 5 |
| Simulator - This module controls the behind-the-scenes activity of the simulation. It determines what the appropriate timestep is for the simulation, tells every element in the simulation (vehicles, roads) to update, and informs them when they should repaint themselves. | Basic Infrastructure | Incidental | Streamlining | Reversability and time warp |
| GUI - As the features of the project of a whole are added, so too will associated controls of the GUI be added. | - Panel for Graphics Display - Simple drawing capabilities - Basic user controls |
Advanced GUI | Incidental | Incidental |
| Vehicle - The vehicle module contains code used to draw the vehicle, the IDM Driver Model implementation, and the Mobil implementation. The IDM Driver Model contains the basic IDM behavior and attribute variables for a driver type. The Mobil implementation contains lane changing behavior. |
- Vehicle capabilities, position, velocity, acceleration
- Basic vehicle properties (visual appearance and ability to paint) - Multiple vehicle types |
Decision making to handle obstacles, MOBIL lane changing, and intersections | Decision making to handle advanced multilanes and traffic signals | Weighted paths and desired destinations; Individual driver properties |
| Road - A road knows its collection of road segments, along with information pertinent to drawing their locations. | Location and appearance | Multiple lanes, intersections, and sinks | Advanced multiple lanes (merging and branching) and traffic signals | Overpasses, onramps |
| RoadSegment - A road segment knows its collection of lane segments, along with information pertinent to drawing their locations. Similar to lanes, it will know its collection of vehicles, along with information pertinent to drawing their locations. A road segment also has a speed limit, and an ID number. | Location, appearance, and speed limit | Multiple lanes and intersections | Advanced multiple lanes | Construction, accidents |
| Lane - A lane also contains direction information. | Location and appearance | Multiple lanes and intersections | Advanced multiple lanes | Construction, accidents |