Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SETRS - Trajectory-Aware Traffic Signal Preemption

SETRS is an emergency corridor orchestration prototype for Bengaluru road networks. It combines SUMO + TraCI simulation, a FastAPI backend, a control-room dashboard, and a citizen alert app to demonstrate how ambulance movement, hospital assignment, route control, and signal preemption can be coordinated end to end.

The current repo contains:

  • a SUMO-backed emergency traffic control simulation
  • a FastAPI backend for routing, corridor logic, and traffic state
  • a React/Vite dashboard for operators
  • a React Native Expo app for corridor-based citizen alerts

What It Demonstrates

SETRS focuses on one core problem: reducing ambulance delay through proactive traffic signal control and route-aware corridor management.

The system demonstrates:

  • precomputed emergency corridor logic
  • ordered signal preemption along a known route
  • hospital assignment from a simulated hospital pool
  • route and corridor visualization in a control-room dashboard
  • citizen-side corridor alerting in a mobile app prototype

Core Idea

Instead of reacting only to the nearest junction, SETRS computes the ambulance route in advance, extracts upcoming traffic signals, estimates approach timing, and coordinates the next part of the corridor before the ambulance arrives.

At a high level:

  1. Select or receive an incident origin
  2. Assign a hospital from the available pool
  3. Compute a route and corridor
  4. Track ambulance progress along that route
  5. Transition upcoming signals through prepare, preempt, and restore states
  6. Surface the system state in the dashboard and mobile client

Architecture

Ambulance departure
        |
        v
Route extraction + signal sequence build
        |
        v
Per-step ETA evaluation
        |
        v
Signal strategy selection
        |
        v
PREPARE -> ALL_RED -> GREEN -> RESTORE

The implementation separates:

  • computation and control logic in the backend
  • playback and operator visualization in the dashboard
  • citizen impact flow in the mobile alert client

Validated Results

Experiments were run on the Bengaluru SUMO network with fixed configurations and reproducible scenarios.

Corridor C1 - Silk Board to St John's Hospital

Scenario Vehicles Baseline Smart (Adaptive) Improvement Stops
Low 20 1,510 s 1,134 s -24.9% 11 -> 3
Medium 60 1,924 s 1,435 s -25.4% 19 -> 12
High 120 5,928 s 4,860 s -18.0% 61 -> 62

Aggressive mode under high load:

Baseline Aggressive Improvement vs Adaptive
5,928 s 4,021 s -32.2% +14.2 pp

Corridor C2 - Silk Board to HSR Layout to Koramangala

Scenario Vehicles Baseline Smart (Adaptive) Improvement
Low 20 559 s 559 s 0.0%
Medium 60 686 s 735 s -7.1%
High 120 1,196 s 926 s +22.6%

Aggressive mode under high load:

Baseline Aggressive Improvement
1,196 s 1,053 s -12.0%

Interpretation

The results are intentionally honest:

  • gains are strongest under real congestion
  • short corridors do not always benefit under low or medium demand
  • aggressive mode helps more on longer, heavily congested corridors

This is expected behavior for signal control. The system does not invent gains where queue pressure is low.

Results Artifacts

The repository includes:

  • per-scenario CSV outputs in results
  • combined JSON summaries
  • chart images for presentation
  • a preemption demo GIF

Key files:

  • all_results.json
  • results_C1.json
  • results_C2.json
  • chart_improvement.png
  • chart_timeline.png

Repository Layout

setrs/
  backend/                FastAPI APIs, routing, corridor, simulation logic
  dashboard/              React + Vite operator dashboard
  ambulance-alert-app/    React Native Expo mobile app
  sumo/                   SUMO configs, routes, cached corridor inputs
  results/                Experiment outputs, charts, and demo artifacts

Backend

The FastAPI backend provides:

  • route generation
  • corridor and progress logic
  • signal extraction
  • simulated traffic state
  • hospital assignment
  • active emergency feed for the mobile app

Important files:

  • main.py
  • mapbox_directions.py
  • corridor_engine.py
  • hospital_catalog.py
  • signal_catalog.py

Backend Routes

Representative endpoints:

  • GET /route
  • GET /route/progress
  • GET /route/traffic
  • GET /active-emergency
  • WS /ws/live

Hospital Pool

The simulated hospital pool currently includes 6 hospitals:

  • St John's Hospital
  • Apollo Spectra Hospital
  • Manipal Hospital Koramangala Clinic
  • NIMHANS Hospital
  • Jayadeva Hospital
  • Sagar Hospitals Jayanagar

The dashboard shows 3 at a time:

  • 1 assigned hospital
  • 2 alternatives

Dashboard

The dashboard is a React + Vite control-room interface for:

  • route visualization
  • signal state presentation
  • ambulance progress
  • hospital assignment visibility
  • traffic/corridor status

Local development:

cd setrs/dashboard
npm install
npm run dev

Notes:

  • local development uses the Vite /api proxy
  • hosted deployment uses VITE_API_BASE_URL

See the dashboard-specific documentation:

  • dashboard/README.md

Mobile App

The Expo-based mobile app is a thin citizen alert client. It is scoped intentionally to one purpose:

Notify only users physically inside the active ambulance corridor.

It currently includes:

  • location fetch
  • corridor membership check
  • distance-based alert levels
  • simple live map
  • app-side polling of /active-emergency

See:

  • ambulance-alert-app/README.md

How to Run

Prerequisites

  • Python 3.10+
  • SUMO 1.18+
  • Node.js + npm

Backend dependencies are listed in:

  • backend/requirements.txt

Full Experiment Run

cd setrs/backend
python -u run_experiment.py

Generate Charts

cd setrs/backend
python generate_charts.py

Dashboard

cd setrs/dashboard
npm install
npm run dev

Mobile App

Terminal 1:

cd setrs/backend
python -m uvicorn main:app --host 0.0.0.0 --port 8000

Terminal 2:

cd setrs/ambulance-alert-app
set EXPO_PUBLIC_API_BASE_URL=http://YOUR_LAPTOP_IP:8000
npm start

Use your real LAN IP, not 127.0.0.1, when testing on a phone via Expo Go.

Hosting

Recommended hosted setup:

  • Backend: Railway
  • Dashboard: Netlify

Railway Backend

Deploy backend to Railway.

Included deploy files:

  • railway.json
  • Procfile
  • runtime.txt

Required environment variable:

MAPBOX_TOKEN=your_mapbox_token

Netlify Dashboard

Deploy dashboard to Netlify.

Included deploy files:

  • netlify.toml
  • .env.example

Required environment variable:

VITE_API_BASE_URL=https://your-railway-backend.up.railway.app

Behavior:

  • without VITE_API_BASE_URL, the dashboard uses local /api proxying
  • with VITE_API_BASE_URL, it calls the hosted backend directly

Limitations

This repo is demo-grade and prototype-grade, not production-ready.

Current limitations:

  • hospital availability is simulated, not live-integrated
  • signal control is simulated, not connected to real ATCS/BATCS infrastructure
  • notification delivery is prototype-level, not production push infrastructure
  • multi-ambulance arbitration is limited
  • some flows are deterministic playback for demo stability

Positioning

The strongest accurate framing is:

SETRS is a credible emergency corridor orchestration prototype that combines routing, signal preemption, hospital assignment, and citizen alerting in a single demonstrable system.

  • live hospital registry integration
  • real city signal control deployment
  • production-grade push notification infrastructure

Contributors

This project was developed as a collaborative team effort.

Core contributors:

Next Steps

The most natural next upgrades are:

  • real hospital data integration
  • production push notifications
  • multi-ambulance conflict handling
  • real traffic-control integration
  • more robust hosted deployment and environment separation

About

A trajectory-aware emergency corridor orchestration prototype for smart cities. Integrates SUMO simulation, FastAPI, and React to automate traffic signal preemption and reduce ambulance response times.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages