Skip to content

06navdeep06/realtime-traffic-sensor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI-Powered Traffic Management System

  1. Clone the repository:

    git clone https://github.com/06navdeep06/realtime-traffic-sensor.git
    cd realtime-traffic-sensor
  2. 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
  3. Install the required packages:

    pip install -r requirements.txt

    For development, also install:

    pip install -r requirements-dev.txt

Development Setup

  1. Install pre-commit hooks for code quality:

    pre-commit install
  2. Run tests:

    python -m pytest tests/
  3. Run the debug script to test the simulation:

    python debug_simulation.py

Environment Setup

  1. Copy the example environment file and update with your API key:

    copy .env.example .env
  2. Edit the .env file and add your TomTom API key:

    TOMTOM_API_KEY=your_api_key_here
    DEBUG=False
    

    Note: Make sure to add .env to your .gitignore to keep your API key secure.

Running the Application

Web Dashboard

  1. Start the Streamlit dashboard:

    streamlit run dashboard.py
  2. Open your browser and navigate to the URL shown in the terminal (usually http://localhost:8501)

  3. 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"

Running Simulations

  1. For a quick test of the simulation:

    python simple_simulation_test.py
  2. For detailed debugging:

    python debug_simulation.py

    This will generate a timestamped log file with detailed simulation information.

Project Structure

  • dashboard.py: Streamlit web interface for the traffic simulation
  • simulation.py: Core simulation logic and vehicle management
  • traffic_signal.py: Traffic signal controller with Q-learning agent
  • rl_agent.py: Implementation of the Q-learning algorithm
  • road_network.py: Handles road network data and real-time traffic updates
  • visualization.py: Visualization utilities for the road network and traffic
  • debug_simulation.py: Debugging tool for the simulation engine
  • simple_simulation_test.py: Basic test script for the simulation
  • test_*.py: Unit tests for various components

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages