Giter Site home page Giter Site logo

garmin-fit's Introduction

Garmin FIT Conversion Perl Library and Scripts

This repository is a collection of Garmin FIT Perl library and scripts for converting Garmin FIT files to other formats.
Currently the following conversions are supported:

Source Destination Extension
Garmin FIT GPX v1.1 .gpx
Garmin FIT SigmaSport log file .slf

Main library for reading and parsing Garmin FIT file is a modified/updated version of Garmin::FIT library by Kiyokazu Suto. If you want to update Garmin::FIT library to the latest protocol/profile, use documentation from the official FIT SDK from thisisant.com Web site.

Currently supported FIT protocol and profile in this version of library is:

FIT Protocol FIT Profile
2.2 20.08

Some of the messages and fields used in this implementation are not described in the latest official FIT SDK documentation and are therefore experimental/unsupported. This implementation was tested on FIT files from Garmin Edge device only. It works in both Windows and Unix environments. Support for 64-bit integers is not tested at all.

Conversion scripts need to be run from the command line (there's no GUI).

Prerequisites

You'll need the following Perl prerequisites:

  • POSIX::strftime::GNU
  • Data::UUID
  • Config::Simple

You can install them with ppm on Windows (if you are using ActivePerl) or with cpan:

$ cpan install POSIX::strftime::GNU  
$ cpan install Data::UUID  
$ cpan install Config::Simple

Conversion

Getting the FIT files

You have to copy FIT files from your Garmin (or other) device to your computer. You'll need the activity FIT files only. On Garmin Edge devices these files are stored in \Garmin\Activity subdirectory. You can also do it via Garmin Connect Export option.

Config (ini) file

All conversion scripts can optionaly use config file in Windows ini format, which must be named as the script name with extension .ini and must reside in the current working directory. If the config file is not found, some reasonable defaults are applied.

Config file example (fit2slf.ini):

[default]
;SigmaSport: cycling, mountainbike, racing_bycicle (road bike), running, ...
sport = mountainbike
training_type = Riding
bike = bike1

[personal]
name = John Smith
gender = male
age = 40
height = 183
weight = 75

[bike1]
name = Ibis Ripley 29 LS
type = MTB
weight = 12.3
wheel_size = 2326

Units used in config file and in scripts are metric (kg, cm, mm, ...).

Detailed syntax and parameters used in ini file is described in Config (ini) File Syntax.

FIT to GPX (GPS Exchange Format)

Use fit2gpx.pl with optional config file fit2gpx.ini:

$ fit2gpx.pl input.fit

This produces file input.gpx in the current directory. If the file input.gpx already exists, it will not be overwritten. To force overwrite, use:

$ fit2gpx.pl -y input.fit

By default a GPX file compatible with Garmin's Track Point Extension Format v1 is produced. If you want to produce a GPX file compatible with a Cluetrust GPX Extension Format, use the following:

$ fit2gpx.pl -c input.fit

Difference between them is in the syntax how heart rate, cadence, temperature & power data is stored in the file. In both cases a Cluetrust extension <gpxdata:lap> will be added to the end of file, where the following average/min/max values are stored:

startPoint, endPoint, startTime, elapsedTime, calories, distance, avg_speed, max_speed, min_altitude, avg_altitude, max_altitude, total_ascent, total_descent, distance_uphill, distance_downhill, avg_incline_uphill, avg_incline_downhill, avg_rise_rate_uphill, avg_rise_rate_downhill, min_heart_rate, max_heart_rate, min_percent_hrmax, avg_percent_hrmax, max_percent_hrmax, time_under_target_zone, time_in_target_zone, time_over_target_zone, avg_power, avg_power_KJ, avg_power_W_per_Kg, max_power, avg_cadence, max_cadence, min_temperature, avg_temperature, max_temperature, total_cycles, total_records

FIT to SLF (SigmaSport log file)

Use fit2slf.pl with optional config file fit2slf.ini:

$ fit2slf.pl input.fit

This produces file input.slf in the current directory. If the file input.slf already exists, it will not be overwritten. To force overwrite, use:

$ fit2slf.pl -y input.fit

A lot of calculation of average/min/max values is done in addition to the data found in FIT file. Specifically, power is calculated according to the formulas described in J.C. Martin's paper Validation of a Mathematical Model for Road Cycling Power from 1998. You can change some of the parameters used for power calculation in ini file (see Config (ini) File Syntax).

Resulting input.slf can be directly imported in SigmaSport Data Center, which is a perfect software for offline evaluation of cycling statistics and training sessions.

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.