Smart Traffic Management System for Emergency Services
Note: Shyam recently wrote and recorded a video about his traffic management system. You can view the recording on our webinar site. -ed
When it comes to emergency response, every second counts. For emergency response vehicles, meandering through busy intersections and gridlocked streets can present serious consequences for the person in need of care. In this tutorial, we’ll build a smart traffic management system to address this type of emergency scenario. These types of smart services incorporated into city infrastructure is what truly makes a connected city “connected.”
Introduction to Smart Traffic Management System Simulation
The smart traffic management system is simulated using a map interface to visualize the movement of emergency vehicles across a predefined route. This route is defined within San Francisco city from Mount Zion Hospital to San Francisco General Hospital. Along with the route, the map also displays the traffic signals and their display status along the entire stretch:
We’ll use the Mapbox API to build our map interface. And check out the live demonstration of the smart traffic management system map and the project source code on GitHub.
High-level Architecture of Smart Traffic Management System
The system is designed to control the traffic signals along the emergency vehicle’s travel path. This is achieved remotely via a Traffic Management Server (TMS), centrally located on the cloud, powered by IBM Bluemix and all the communication between TMS with the emergency vehicle and traffic signals happen through PubNub’s Real-time Network. Below is a high level architectural view of the entire system:
The TMS periodically receives communication from the emergency vehicle to get its current location. Based on this information, the TMS decides whether to send a command to the next approaching signal (NAS). This command can direct the NAS to either turn green, or to resume normal operation (i.e., the normal predefined cycle of displaying red, amber and green). The idea is to ensure that TMS proactively commands the traffic signals en route the ambulance’s travel path to create a passage without clogging the traffic.
How TMS calculates optimal routing
There are two calculations which are employed by TMS to assist in its decision making.
- Distance calculation – Calculation of the distance between the ambulance and its next approaching signal (NAS).
- Bearing Calculation – Calculation of the bearing angle from the ambulance to the NAS
The figure below illustrates these two calculations:
The distance calculation allows the TMS to decide when to command the traffic signal to turn green so as to clear the traffic ahead at the approaching signal intersection. The bearing calculation helps the TMS to detect signal cross-over by emergency vehicle. After the vehicle crosses the signal, the TMS starts tracking the distance from next approaching signal and this process repeats until the ambulance reaches its final destination.
The algorithm used by TMS is depicted below:
The ambulance sends a START event at the beginning of its journey which allows the TMS to start tracking it. At every location update from the vehicle, TMS calculates the distance from the NAS and takes a series of steps before deciding to command the NAS. At the end of its journey, ambulance sends a STOP event ( not shown in the above figure) to indicate to the TMS that its journey is over.
Implementation details and source code
The complete source code for this demonstration is available on Github.
For the purpose of this demonstration via simulation, the system has been implemented as a client web application and an application server. The client web application is built using the Mapbox API and PubNub Javascript SDK. It simulates and visualizes the ambulance movement and switching of traffic signal lights for all the traffic signals along the pre-defined route.
The application server acts as the TMS; it is built using Python. It is deployed on IBM Bluemix cloud and utilizes the PubNub service and PubNub Python SDK for communicating with the client.
If you want to host this demonstration on your own, then refer to the README file for instructions on how to host and run the application from within your Bluemix account.
Conclusion
Considering the fact that an ambulance stuck in traffic is a common sight in many places across the world everyday, a truly smart transportation infrastructure is the need of the hour and this demonstration may pave the way to achieve that.
Although the algorithm does not take into account many of the real world scenarios, and also may not work for very complex routes (such as traffic signals along a zigzag road), it is hoped that the city and town planning authorities can take this into consideration while building smart cities for the future. Further, the existing algorithm can be made more smarter with the help of IBM Watson, such that it can learn historic traffic patterns to predict exceptional traffic scenarios and figure out effective ways to deal with it. Check out the Watson Service Catalog for more details.
Learn More
I’ve recently done a video recording of the traffic management system. You can watch the recording to learn more.