This is the fourth project from Udacity's C++ Nanodegree Program. It covers concurrency, especially threads, tasks, futures, mutexes, locks and message queues in the coding language C++.
- Implement the logic for traffic lights.
- Add a message queue to prevent data races, deadlocks and improve performance and responsibility of the program
The project is divided into different files. All header files can be found in the include
folder.
src/graphics.cpp
(and header file): Logic for visualization of the traffic simulationsrc/intersection.cpp
(and header file): Class for the intersection objects with the corresponding functions and logicsrc/street.cpp
(and header file): Class for the streets connecting intersectionssrc/TrafficLight.cpp
(and header file): Class for the traffic light objects with the corresponding functions and logicsrc/TrafficObject.cpp
(and header file): Parent class for TrafficLight, street, intersection and Vehiclesrc/TrafficSimulator_Final.cpp
: Main logic of the traffic simulationsrc/Vehicle.cpp
(and header file): Class for the vehicle objects with the corresponding functions and logic- other helper, build and installation files
- cmake >= 2.8
- make >= 4.1 (Linux, Mac), 3.81 (Windows)
- OpenCV >= 4.1
- gcc/g++ >= 5.4
- Clone this repository.
- Install dependencies.
- Make a build directory in the top level directory:
mkdir build && cd build
- Compile:
cmake .. && make
- Run it:
./traffic_simulation
.
Here you can see an example result: