TransitNetworkModel
A realtime model of the Auckland Public Transport Network
Install / Use
/learn @tmelliott/TransitNetworkModelREADME
Transit Network Model
Three parts, running in real time:
- particle filter for vehicle location and speed
- Kalman filter for transit road network state (speed)
- travel- and arrival-time predictions for each vehicle/stop combination in the network
1. Particle Filter
IN: GTFS realtime protobuf feed
OUT: (updated) vehicle objects with updated particle states
2. Kalman filter
IN: particle filter state estimates, road state at time now - delta
OUT: road state at time now
3. Predictions
IN: particle filter state estimates, road state estimates
OUT: ETA to remaining stops along route
Dependencies
apt-get install build-essential cmake unzip libboost-all-dev libprotobuf-dev libsqlite3-dev cxxtest sqlite3- (optional) Doxygen (for making the Documentation)
- (optional) Google protobuf compiler
protoc: https://github.com/google/protobuf/blob/master/src/README.md (install withmake protoc)
To-do
- Application to run indefinitely
- Use a
Vehicleobject concept withvector<Particle> (N)void update (gtfs::VehiclePosition, gtfs::TripUpdate): adjust the position, arrival/departure times etc, trigger particle transitionsvoid resample (N): perform particle filter weighted resample- properties
vehicle_id,timestamp,trip_id,route_id,position,stop_sequence,arrival_time,departure_time
- And the particles work in memory only
Particlevoid initialize ()void transition ()void calc_likelihood (): uses parent Vehiclevoid calc_weight ()- properties
distance,velocity,stop_index,arrival_time,departure_time,segment_index,queue_time,begin_time,likelihood,weight
- Similar concept for network route segments
Segmentvector<Path> shape: the GPS coordinates and cumulative distance of segment shapedouble speedvoid update (): perform Kalman filter update, using particle summaries (?)
- The GTFS information can either be
- loaded into an SQLite database, or
- loaded into a MEMORY table via MySQL
- Vehicle state summaries can be written to a file (?)
- Making information available (via server) - road segment speeds + arrival time predictions
- database (with no foreign key checks, and no transaction?)
(?) best way of collecting vehicle/segment data
- sequentially append speed estimates to
Segment, then periodically update and clear? - write to file? (makes keeping history easier?)
Project Structure
docs: documentation (HTML and LaTeX)gps: a library containing methods for dealing with GPS coordinatesgtfs: a library with GTFS object classes, and methods for modeling themVehicle: Class representing a physical vehicleParticle: Class representing a single vehicle state estimateSegment: Class representing a road segment
include: header files for programsprotobuf: GTFS Realtime protobuf description and classessrctransit_network_model.cpp: mostly just a wrapper forwhile (TRUE) { ... }load_gtfs.cpp: a program that imports the latest GTFS data and segments it
Related Skills
node-connect
342.5kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
85.3kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
342.5kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
342.5kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
