## Inspiration

On average, three in five people will be involved in a crash due to impaired driving in their lifetime (National Center for Statistics and Analysis, 2017). Driving while intoxicated is a major problem in the United States, and we wanted to build an app that would help keep people safe. One problem people often run into is estimating (or overestimating) their own ability to drive. Our app warns people who may be in danger of risking others as they begin driving, and warns other drivers using the app about potentially hazardous drivers around them.

## What it does

The Ford OpenXC system allows one to obtain real-time digital information about the car operation, such as the speed, steering wheel angle, and GPS location. Our app gets this information from the car via Bluetooth, and determines directly via the car's motions whether the driver is too impaired to drive. This information allows us to spot unsafe driving behavior quantitatively instead of relying on metrics such as counting drinks, which may be inaccurate, and blood alcohol content (BAC), which does not directly correspond to a person's level of impairment. An additional feature is that any driver who is using the application will be notified about other nearby drivers who are potentially impaired.

## How we built it

We created an Android app that collects real-time data from the OpenXC system using Bluetooth. It transmits data on the speed, steering wheel angle, and GPS location to a central server using TCP (in reality, this would be sent over the 4G network), which is responsible for running mathematical tests to determine the person's level of impairment. The server is written in Python, and it searches for the red flags of periodic weaving, swerving, and turning at high speed. To detect weaving, we count the number of times that the steering wheel angle exceeds a particular value relative to the curvature of the road (e.g. if the driver is swaying from side to side on a straight road). The curvature data is obtained from OpenStreetMap. To detect swerving and making turns at high speed, we look at the number of turns taken over a certain speed. Due to the limited OpenXC data we had during the hackathon, appropriate threshold values for these statistics must be determined experimentally. Lastly, if the server determines that a driver is impaired, it will send them a notification and alert to stop driving, and it will notify other nearby drivers who have the app as well.

## Challenges we ran into

Developing a drunk/unsafe driving classifier was difficult. There were no datasets that captured the data we needed to train machine learning model so we had to develop our own methods. We also struggled with testing our application. Ford's OpenXC enabler is apparently incompatible with all emulators on Android studio. We also lacked an Android phone with a working USB connection, so all testing had to be done by building the app running it on an Android and debugging by guesswork.

## Accomplishments that we're proud of

We were able to develop classifier for drunk/unsafe driving with extremely limited data. We found traits or actions characteristic of drunk driver and were able to quantitatively evaluate them. We were also able to setup a server for storing and analyzing the data sent from the app to quickly and accurately warn nearby drivers about dangerous or unsafe driving. Code for web socket connections between phones and the server have also been written. We learned a lot about Android application development and set up the framework for future development.

## What we learned

Firstly, we familiarized ourselves with Fordâ€™s OpenXC platform and data. From there, we further developed both our software and data analysis skills. Our team members learned about Android app development, Java web sockets, and TCP protocol. We also learned how to manipulate geospatial data using Overpass, Open Street Map API, and QGIS.

## What's next for D. W. I.

Moving forward, we plan to set more rigorously defined standards for dangerous versus safe driving. With larger amounts of properly labeled data, we also plan to incorporate machine learning methods to classify behavior.

## Built With

Share this project: