-
Clone the repository:
git clone https://github.com/06navdeep06/realtime-traffic-sensor.git cd realtime-traffic-sensor -
Create and activate a virtual environment (recommended):
# On Windows python -m venv venv .\venv\Scripts\activate # On macOS/Linux python3 -m venv venv source venv/bin/activate
-
Install the required packages:
pip install -r requirements.txt
For development, also install:
pip install -r requirements-dev.txt
-
Install pre-commit hooks for code quality:
pre-commit install
-
Run tests:
python -m pytest tests/
-
Run the debug script to test the simulation:
python debug_simulation.py
-
Copy the example environment file and update with your API key:
copy .env.example .env
-
Edit the
.envfile and add your TomTom API key:TOMTOM_API_KEY=your_api_key_here DEBUG=FalseNote: Make sure to add
.envto your.gitignoreto keep your API key secure.
-
Start the Streamlit dashboard:
streamlit run dashboard.py
-
Open your browser and navigate to the URL shown in the terminal (usually http://localhost:8501)
-
In the sidebar:
- Specify the city to monitor (e.g., "Patan, Nepal")
- Adjust the number of vehicles to display (10-500)
- Click "Start Real-time Traffic Monitoring"
-
For a quick test of the simulation:
python simple_simulation_test.py
-
For detailed debugging:
python debug_simulation.py
This will generate a timestamped log file with detailed simulation information.
dashboard.py: Streamlit web interface for the traffic simulationsimulation.py: Core simulation logic and vehicle managementtraffic_signal.py: Traffic signal controller with Q-learning agentrl_agent.py: Implementation of the Q-learning algorithmroad_network.py: Handles road network data and real-time traffic updatesvisualization.py: Visualization utilities for the road network and trafficdebug_simulation.py: Debugging tool for the simulation enginesimple_simulation_test.py: Basic test script for the simulationtest_*.py: Unit tests for various components