This project simulates a vehicle journey from a start destination to an end destination, where a crash detection system is integrated. It includes:
- Geolocation to get the coordinates of the start and end locations.
- Route finding to calculate the coordinates along the route.
- A moving vehicle simulation that sends updates of the vehicle's position every 2 seconds.
- A crash detection mechanism where a crash sensor triggers a crash event.
- A notification system that sends a message to a family member upon a crash, providing the last known coordinates.
The system comprises the following agents:
- Geolocation Agent: Converts addresses to geographic coordinates.
- Route Finder Agent: Determines the route and coordinates between two locations.
- Simulation Agent: Simulates the vehicle moving along the route, sending coordinates periodically.
- Crash Detection Agent: Detects a crash and logs the latest coordinates.
- Crash Sensor: Simulates a crash event that triggers the Crash Detection Agent.
- Notification Agent: Sends a notification to a designated family member with the latest vehicle coordinates in case of a crash.
![System Architecture](./automotive example architecture.png)
git clone https://github.com/kshipra-fetch/crash-detection-simulation.git
cd crash-detection-simulation
Ensure you have Python 3.8+ installed. Then install the required packages:
pip install uagents flask requests
pip install 'flask[async]'
There are multiple agents that need to be run in separate terminals.
The agent uses the OpenCage API key to geocode addresses. You can check OpenCage API website.
python geolocation.py
The agent uses the Open Street Map to find the route between two geocode locations.
python route-finder.py
python simulator.py
python crash-detection-agent.py
python crash-sensor.py
The agent uses the ClickSend API to send out text messages. You can check the ClickSend API website.
python notify-agent.py
In another terminal, run the Flask application:
python app.py
This will start the web interface for the crash simulation.
- Open your browser and navigate to
http://127.0.0.1:5000
. - Enter the start and end destinations in the form and click "Find Route".
- The agents will calculate the route and begin simulating the vehicle moving along the route.
- You can trigger a crash event by clicking the "Simulate Crash" button. This will send the crash information to the Crash Detection Agent.
- The Crash Detection Agent will notify a family member with the last known coordinates via the Notification Agent.
The diagram above shows the data flow between the user, agents, and family member during the crash detection simulation.