Shivy won the Microsoft Code for Future hackathon!

Shivy won the Microsoft Code for Future hackathon!
Hello everyone,

A while ago, we took part in Microsoft Code for future open source hackathon as Road Busters and in this post we will share our experience with you.

In general Microsoft Code for future hackathon was all about Smart Traffic Management system for Quick Commute and carbon reduction. We had to develop a system to smartly control the traffic for quick commutation and to reduce the carbon emission using Azure service and Open Source technologies.

Existing System


Traffic control system in Indian cities is not smart.

pipeline graph
  • They don’t adapt to the dynamic situation of the continuously changing traffic.
  • Most common traffic systems use a pre-set timer which turns the traffic signal red/green after a specified delay.
  • The vehicles have to wait for a long time span even if the traffic density is very less which leads to increase in Carbon emission rate and increase the density of traffic.

Our Idea


Now to control the traffic smartly and reduce the carbon emission rate, we came up with an idea of passing the vehicles as soon as they reach the junction.

crossroad clipart

In other words, suppose a vehicle takes 2 minutes to reach crossroad B from crossroad A, then crossroad B shouldn’t turn green for vehicles that are coming from the direction of crossroad A for 2 minutes.

And in between those 2 minutes, crossroad B could be green for vehicles that are not coming from the direction of crossroad A.

In order to make it possible. We would need to know about the distance between crossroad A and crossroad B. With that we will able to find the average time a vehicle will take to reach crossroad B from crossroad A with average speed of 30 - 40 km/hr. We would also need the location of all traffic junctions.

With all that data we will able to build a system which would be able to control the traffic smartly and will reduce the carbon emission rate without any external hardware need.

In Technical Terms

pipeline graph

If we assume roads as pipelines carrying water and each junction as valve which opens/closes to control the flow of the water. We can map logic to the roads such that only X amount of vehicles are passing through given location at a given point of time.

Implementing the idea


Firstly, we collected all the traffic junction location data and an area of Ahmedabad (a city in India) from Openstreet map.

We had to be creative, because we couldn't find all traffic junction locations.Cause this project was just to showcase how our idea will smartly control the traffic and how it will reduce carbon emission rate. Thus, manually we had to add traffic junction locations at each crossroad.

Then we used that data within our own GUI built on top of javascript to help us simulate how traffic will be affected with the new implementation.

It also helped in tuning the delay values to get least possible waiting time at each junction where traffic light is present.

Just like we implemented our idea for dummy data, we can implement it into the real world scenario and reduce the emission rate of carbon.

Challenges faced while building the system


  • The biggest challenge we faced was to find and collect valid data (all the traffic lights position in a city) and somehow integrate them in UI such that cars also follow that rule. We didn’t get the data we were looking for, hence we created another tool and filled up the traffic light positions manually.
  • crossroad clipart crossroad clipart

  • The other challenge was the UI itself like how to teach cars when to move or stop when there is green light or red light. For solving this challenge, we checked the distance of each car if it's near any traffic light
    • if yes, then check if the nearest traffic light is red
      • if yes, then stop the car
      • else go ahead

Deployment


Here comes the deployment of our smart traffic simulation system. We used heroku for the deployment. As we were using Express.js server and it was a small-scale project without much processing, memory consumption.

Feel free to check out our project here.

Technologies used and why?


Python with AioHTTP

We used AioHTTP library to get the route data. We used it instead of requests for making asynchronous request, non-blocking I/O calls, and for the fast results.

Mappa library

We used Mappa library in order to work with the static map. It allow us to overlay a canvas on top of a tile map.

p5.js library

We used p5.js for creating graphic within the web page.

Leaflet.js library

We used Leaflet.js for creating markers/cars in the map.

Route finding library

We used Pyroute routing library to find the shortest path between two crossroads.

OpenStreetMap

We used OpenStreetMap for getting the map/tiles of an area of Ahmedabad city.

Overpass Turbo

Overpass turbo (overpass-turbo.eu) is a web based data mining tool for OpenStreetMap. We used it to get distance between crossroads and for getting the location of the crossroads.

Some Q/A


  • How will this project make the earth more greener?
    • We are trying to reduce the waiting time at each traffic junction without any extra hardware or software by adjusting the timers of the city to take into account the traffic amount from their adjacent junctions.
    • With less waiting time there’ll be less wastage of fuel.
  • Will it require any extra hardware like other adaptive solutions?
    • No, it won’t require any extra hardware for the first phase.
    • We can calculate value of traffic light of each junction in the city on one serve and can change them in the city accordingly.
    • For next phase, we can add microcontroller to change the values dynamically when server updates the value from its end.
  • Can it also adapt to rush hours and weekend traffic automatically?
    • At phase one it can’t, but once we add microcontroller to automatically update time from server it can handle rush hours and weekend traffic based on previously collected dataset.
  • Will it also help when there’s sudden traffic change?
    • No, it can’t help in such situation.
    • We need to add crowd detection module to detect crown at each junction and trigger traffic lights.

AM aka Ajay's Experience in his own words -

It was all in a rush when Endo called me and suggested that we should register in Microsoft’s Code for Future hackathon on 10th of March (last day of registration).

There was this idea that I had been pondering over whenever I stopped at a red light at a traffic junction; like if somehow my timings were correct along with my vehicle’s speed. I could reach home without encountering any red light or in the least amount of them.

I occasionally did find at some point the perfect timing, if I left my office by 19:00 and hit the road by 19:15 I was able to avoid most of the red lights that I encountered on other days.

With this hackathon, we got a chance to work on this and even though we didn’t exactly complete it, we know that it is possible to build a system without the need of any extra hardware or image recognition cameras to regulate traffic with existing technology if we tweak timings accordingly.

We hope you found this post interesting and helpful.

Link to Our Project

Thank you so much for reading this post.

Show Comments