Gps_data_logger

In this project, I developed a real-time GPS data logger. This multi-threaded application allows connecting to a GPSD server, retrieve real-time location data and save it to a local SQLite database. In addition, the stored data can be exported in both Keyhole Markup Language (KML) and GPS Exchange Format (GPX) formats.
Alternatives To Gps_data_logger
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Traccar3,995
20 hours ago417apache-2.0Java
Traccar GPS Tracking System
X Track3,670
7 months ago14gpl-3.0C
A GPS bicycle speedometer that supports offline maps and track recording
Traccar Web644
3 days ago49gpl-3.0JavaScript
Traccar GPS Tracking System
Traccar Client Android556
a month ago180apache-2.0Kotlin
Traccar Client for Android
Pizero_bikecomputer449
2 months agogpl-3.0Python
An open source bike computer based on Raspberry Pi Zero (W, WH, 2W) with GPS and ANT+. Including offline map and navigation.
Mad Location Manager447
5 months ago45mitJava
Mad Location Manager is a library for GPS and Accelerometer data "fusion" with Kalman filter
Hckalmanfilter212
33 years ago5January 26, 201815mitSwift
HCKalmanFilter is Swift implementation of Kalman filter algorithm intended to solve problem with GPS tracking
Traccar Manager Android191
a month ago42apache-2.0Kotlin
Traccar Manager for Android
Traccar Client Ios182
a month ago48apache-2.0Swift
Traccar Client for iOS
Corelocationcli176
4 months agoJune 25, 20174mitSwift
Command line program to print location information from CoreLocation
Alternatives To Gps_data_logger
Select To Compare


Alternative Project Comparisons
Readme

Project Description

The availability and affordability of GPS receivers enables the access to relatively accurate positionning data. In this project, I developed a real-time GPS data logger. This multi-threaded application allows connecting to a GPSD server, retrieve real-time location data and save it to a local SQLite database. In addition, the stored data can be exported in both Keyhole Markup Language (KML) and GPS Exchange Format (GPX) formats.

Application Overview

Features

  • Retrieval of location data from a background GPSD server.
  • Storage of retrieved data to a local SQLite database (if the database does not exist, it is automatically created).
  • Export of location data in both KML and GPX formats.
  • Concurrent execution.
  • Automatic GPSD configuration.
  • Fully-configurable application.
  • Automatic database creation and configuration.

Multithreading

To improve its performance, the application uses three distinct threads to handle the different tasks:

Thread Task Remarks
Main thread The main application thread. It manages the application configuration as well as the starting and stopping of the other threads.
Monitor thread This thead retrieves the location data at regular time intervals and saves it to a synchronized shared queue. Started and stopped before the Recorder thread
Recorder thread This threads retrieves the location data from the shared queue and stores it to the SQLite database at regular time intervals. Started and stopped after the Monitor thread

In addition to these threads, the application (especially the Monitor thread) requires an external process (i.e., GPSD server) in order to retrieve location data. If the GPSD process is not already running (and launched with the appropriate parameters), the Monitor thread stops and the application exits.

Application Execution Timeline The application launches two distinct threads to seperately handle location data retrieval and storage.

Configuration Parameters

The application can be configured by altering the JSON file in the config folder. The available parameters are the following:

Parameter Description Default Value
gpsd_ip_address The GPSD server IP address (or hostname) 127.0.0.1
gpsd_port The GPSD server TCP port 2947
start_gpsd A flag indicating if the application should automatically start the GPSD server (This is useful especially if the GPSD service startup is set to manual) true
default_device The default port to which the USB GPS device is attached "/dev/ttyACM0"
enable_new_session A flag indicating that every time the application starts, it creates a new session true
database_filename The SQLite database filename and path gps_logger.db
database The name of the SQLite database gps_logger
session_tablename The name of the session datatable session
location_tablename The name of the location datatable location
monitor_delay The time interval of the monitor thread, in seconds 0.5
recorder_batch_size The maximum number of data records stored simultaneously in the database 100
recorder_interval The time interval of the recorder thread, in seconds 5

Location Information

The location data stored in the database consists of the following fields:

Field Description Unit/Format
latitude Latitude in degrees deg.
longitude Longitude in degrees deg.
altitude Altitude in meters m
heading Course over ground, in degrees from true north degrees
climb Vertical speed : climb (positive) or sink (negative) rate, in meters per second m/s
speed Ground speed, in meters per second m/s
mode Indicates the status of the GPS reception (0: None, 1: No-fix, 2: 2D-Fix, 3: 3D-Fix)
utc_time Full date/time string in ISO8601 format (UTC). '%Y-%m-%dT%H:%M:%S.%fZ'
db_timestamp Full date/time string of record storage to the database, according to local timezone. '%Y-%m-%d %H:%M:%S'

The application's database schema is illustrated below:

Database schema
The GPS Data Logger database schema.

Prerequisites

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Software Requirements

For both Ubuntu and Raspbian, the following tools should be installed:

  • gpsd : the GPSD service
  • gpsd-clients : a client package for GPSD including cgps and xgps
  • python-gps : a GPSD library for Python
[email protected]:~ $ sudo apt-get install gpsd gpsd-clients python-gps

Other optional software tools for visualizing, dumping and converting GPS data can also be installed. For example, one can install:

  • foxtrotgps : a tool for real-time GPS navigation, track logging and trip planning
  • gpsbabel : a tool for GPS data conversion

Hardware Requirements

Any GPS device that is compatible with the official GPSD release can be used in conjunction with this code. In this project, I used the Stratux Vk-162 Remote Mount USB GPS and it worked as intended.

Stratux Vk-162 Remote Mount USB GPS
Stratux Vk-162 Remote Mount USB GPS. (Photo credit: www.amazon.com)

Application Deployment

Prior to running this project, the GPSD service should be properly configured, up and running.

GPSD Configuration

The GPSD service can be typically parametrized as follows:

gpsd [-b ] [-D debuglevel] [-F control-socket] [-f framing] [-G ] [-h ] [-l ] [-n ] [-N ] [-P pidfile] [-r ] [-S listener-port] [-s speed] [-V ] [ [source-name] ...]

I use this minimalist command to configure and run the GPSD service:

[email protected]:~ $ sudo gpsd -D 4 -F /var/run/gpsd.sock -P /var/run/gpsd.pid -N -n /dev/ttyACM0

For more information about the GPSD configuration, please refer to the official documentation.

To check that the GPSD is up and running, one can use the command:

[email protected]:~ $ cgps

cgps Screenshot
Running cgps command is expected to show the current device's location.

Dependencies

The GPS Data Logger requires the installation of two Python packages:

  1. gpsd-py3: a Python GPSD client
  2. simplekml: a Python package for the generation of KML/KMZ files

To install the required dependencies, the following command can be used:

[email protected]:~ $ pip install -r requirements.txt

Running the Application

To run the application, the following steps are recommended:

  1. Run the GPSD service with the appropriate parameters, if not already running,
  2. Install the required dependencies,
  3. Alter the parameters in the config.json file as desired, then
  4. Run the command:
[email protected]:~ $ python3 app.py

To stop the application, the key combination CTRL + C can be used.

Built With

Tested With

License

This project is licensed under the MIT License - see the LICENSE file for details.

Popular Gps Projects
Popular Gps Tracking Projects
Popular Hardware Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Python
Gps
Gps Tracking