Giter Site home page Giter Site logo

c3toctrack's Introduction

c3toctrack

Tracker Infrastructure for the c3toc trains at #cccamp23. See c3toc.de and api.c3toc.de.

Hardware

The trackers have been built using Lilygo T-Beam modules, which combine an ESP32 with a Neo 6M GPS receiver, a Lora radio, and a 18650 LiIon battery holder, with power controller to allow running off the battery and charge it. The module is about 50€ and comes with a small GPS antenna that is not very good; you can easily replace it with a better one. Note that there are many clones of this board that use slightly different hardware or pinouts, so some experimentation might be needed. The Lora radio is not currently used, but it would be easy to (also) transmit the data via LoraWan, for example to The Things Network. With a brand-name 18650, the tracker ran for up to 36 hours at Camp.

JSON API

The python script mqtt2json.py generates four JSON files: tracks.json, tracks.geojson, trains.json, and trains.geojson.

tracks.json

The file is updated on every start of the script, and contains information about the track segments that make up the entire system. The contents are converted from data/trainlines.gpx, which in turn are exported using JOSM from docs/trainlines.osm.

There are two main objects in that JSON, tracks and waypoints.

Tracks

Tracks is a dict of track segments, with the track segments' name as the key. Each segment has a number of geo coordinates under the key points, which include three key entries:

  • lat & lon, the geo position of this point
  • trackmarker, the milestone location of that point, in meters.
  • waypoint, an optional waypoint (see below)

Waypoints

In addition to being attached to a point, the separate waypoints dict also contains all waypoints. The key is the trackmarker (again in meters). Each waypoint has these properties

  • type: one of:
    • Bf: Bahnhof, or station,
    • Bü: Bahnübergang, or level crossing,
    • Hp: Haltepunkt, or stop
    • W: Weiche, or switch/turnout
  • trackmarker: the linear position on the track, in meters
  • name: the name of the waypoint
  • ds100: the DS100 (official list) designation for the stop or station

trains.json

There is one property `trains', which contains one property per train, named after the train. Each train has these properties:

  • lat and lon GPS position
  • dir: direction of travel in degrees; 0 is north, 90 is east.
  • sat: number of satellites reported by the receiver, can be used to gauge accuracy of the fix
  • speed: in km/h
  • trackmarker: in meters, relative to the track.
  • trackname: name of the track segment the train is on.
  • next_stop: details of the next stop the train will reach, with these properties:
    • eta: time in UTC when the train will arrive at this stop
    • name
    • trackmarker
    • type

GeoJson

Both tracks and trains are also available in GeoJson format.

The features have additional properties according to simplestyle.

You can look at the tracks GeoJSON on MapBox' geojson.io

Setting Up

POETRY_VIRTUALENVS_IN_PROJECT=true poetry install

Running the API gateway

poetry run python mqtt2json.py mqtthostname username password

Running unit tests

poetry run py.test

c3toctrack's People

Contributors

stblassitude avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

supersat

c3toctrack's Issues

Add direction to trains.json

It would be good to have a direction/course field (in degrees) in trains.json because it looks weird if a train icon is facing the wrong way on the map :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.