A bachelor's thesis in Data Engineering and IT at Chalmers University of Technology. The project was a suggestion by the five members and was completed over a period of 4,5 months. For more information about the project, you are welcome to read the thesis here.
More documentation of the development process is available in the designated repository.
The authors of this thesis:
- Purpose - Here the purpose and aim of the project is explained.
- Showcase - A demonstration of some of the features of the developed simulation tool.
- RoadGenerator - As part of the development, a custom road system generator asset was built, based on Sebastian Lague's Path Creator tool. It was extended to include many features, such as intersection generation and vehicle navigation.
- Try it yourself - Instructions for how to get access to the tool.
- License - The license for this work.
The purpose of the project is to design and construct a 3D traffic simulation tool with high accessibility, that should provide detailed and accessible data. This allows the user to evaluate the performance of different road networks and traffic scenarios, and make informed decisions about urban planning and infrastructure. Data should be presented in real-time through presentation of relevant statistics. By adjusting the parameters of the simulation, the user should be able to witness the effect of their tweaking, and easily see if their changes have a positive or negative impact across relevant environmental dimensions such as congestion level or emissions.
The following section will present the different features of the simulation. However, many features are left out for an easier read.
The User Interface, or UI for short, is the means with which the user interacts with the simulator. Therefore, effort was put into making it easy to use, following common looks and practices in order to make it intuitive. This section will showcase the different parts of the UI:
- The main menu, where settings can be changed and from which the simulation is started.
- The simulation UI, which is an overlay with which the user can interact during the simulation. This contains the statistics, which are presented in the following section.

The scene selection menu, where you can choose the road system to simulate

A selected vehicle, with its current navigation path and information
During the simulation, data is collected and presented in real-time to the user through the statistics panel. Here, the user can see details for specific vehicles, or statistics for the entire road network. The fuel consumption gathers the total fuel consumed by all vehicles over time, while the congestion ratio is an indication of how congested the network is. It represents the ratio of currently congested roads, and can be used to easily identify bottlenecks or heavily trafficated roads.

Gathered statistics over total fuel consumption over time

Gathered statistics over ratio of congested roads over time

Each Road can be coloured according to the current congestion or fuel consumption
Three different cameras are available during the simulation and are presented in this section.

The freecam allows the user to freely roam around

The follow camera follows the selected vehicle

The driver camera places the user behind the wheel of a simulated vehicle, enabling further immersion
In order for the vehicles to navigate the road system, each vehicle drives as an individual agent. The agents follow the roads - more specifically the nodes generated along the roads - which can be seen in the later section titled "RoadGenerator".
Furthermore, they need to find their way through the road system, driving through intersections and planning their route. For this, a graph is generated representing the road system. The nodes are intersections, road end points and POIs and any other point the vehicles need to find. The edges are the roads between these. Using the road system graph, an A* path finding algorithm is used by each vehicle to plan their route, which can be seen in the following gif.

A generated graph representing a road system

A vehicle navigating a RoadSystem, driving to its target
A user can at any time enter the manual driving mode, where they will gain control of their own vehicle. This allows the user to drive around the road system, gaining a good understanding of what it is like to drive around the road network. This facilitates a unique opportunity to evaluate changes to the system by placing yourself in the driver's seat of a road user, offering an intuitive way to understand whether it is easy for the drivers to find their way around or not.
The manual vehicle will interact with the other vehicles in the road systems, which will queue up behind the manually driven vehicle as any other vehicle. This integrates the manual car with the traffic.

A car being driven manually, able to interact with the traffic
- Throttle:
- Controller:
Right Trigger - Keyboard:
W
- Controller:
- Reverse:
- Controller:
Left Shoulder - Keyboard:
Left Shift
- Controller:
- Brake:
- Controller:
Left Trigger - Keyboard:
S
- Controller:
- Steer:
- Controller:
Left Stick - Keyboard:
AandD
- Controller:
- Handbrake:
- Controller:
Right Shoulder|Button West - Keyboard:
Space
- Controller:
- Reset vehicle:
- Controller:
Start - Keyboard:
R
- Controller:
- Look behind:
- Controller:
D-Pad Down|Button North - Keyboard:
Down Arrow|Right Control
- Controller:
- Cycle camera:
- Controller:
Select|D-Pad Left|D-Pad Right - Keyboard:
C
- Controller:
While it is possible to manually create road systems through the developed RoadGenerator tool in the Unity Editor (only available with the project open in Unity), an integration with OpenStreetMap allows for automatic generation of road systems. The integration contains a parser that can read OSM map data and generate roads, intersections, buildings, bus stops, parkings and more according to the real world data. It also configurates the roads to mirror the real world, matching settings such as road width, speed limits and one way roads.
For this project, a map of Masthugget - a district of Gothenburg, Sweden - was exported from OSM and used to generate an entire environment which can be simulated. The following section contains some images of the generated version of Masthugget.

A comparison between the OpenStreetMap version and the generated environment

An overview of the Masthugget scene

A first person view of the generated Masthugget

Vehicles simulated in Masthugget

A view of Masthugget from the river Göta älv
An important part of the simulation is the vehicles. To tie it together, a range of realistic looking models are simulated. These are showcased in this section.

A number of different vehicle types are simulated for a realistic feel

A closer look at one of the vehicles
A few different points of interest can be added to the road systems, such as bus stops or parkings. The simulated vehicles can interact with the POIs. As an example, they can navigate to parking POIs and park as well as leave the parking. Simulated buses can follow a specified bus route, stopping at every bus stop along the route which simulates public transport.

A closeup of a generated bus stop, complete with its name tag

A bus with its displayed navigation path, visiting all its related bus stops in order

Vehicles parked at a roadside parking

Vehicles parked at a parking lot
As part of the project, an asset called RoadGenerator was developed to allow the creation of road systems. RoadGenerator contains many different features such as automatic intersection generation and an integration with OpenStreetMap to create virtual twins of real life locations to be simulated. Some of these features will be shown in the following section, while others have already been demonstrated in the previous section. Note that there are many additional features to RoadGenerator, and that this is a simplification since it is only a showcase and not documentation.
RoadGenerator is based on Sebastian Lague's Path Creator asset, which enables the creation and editing of Bézier path. A Bézier path is a chained sequence of Bézier curves, which are mathematical definitions of curves. They have many use cases and form the basis of the roads in RoadGenerator.

A Bézier Path, used to describe the path of every Road
Nodes, called RoadNodes, are generated along the Bézier curve of every Road and are used by the navigation among others. They also contain information used by many parts of the simulation, such as the vehicles and the intersection yielding algorithms.

RoadNodes generated along a Bézier path

A mesh is generated along each Bézier curve, forming the Road

At every intersecting point between Roads, an Intersection is automatically generated
There is support for two different intersection types - three and four way intersections. The type of intersection is determined automatically during the generation. Each intersection can also be configured, such as switching between traffic lights or yield signs.
The RoadGenerator asset can be used to easily manually create and edit road systems. The following is a sped up gif of a small road system being created. For larger road systems, the OSM integration is suitable as creating road networks is time consuming. This also has the benefit of replicating a real life location.

A timelapse of a RoadSystem being created by hand
There are two ways you can try the tool for yourself:
- Download and run the Build, found under Releases.
- Try the online version. Note that the Masthugget map is excluded in this version due to resource constraints.
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.





