Last active
December 26, 2019 23:36
-
-
Save pierre-ernst/3c8b6fba9270125696c2afcdecfd600f to your computer and use it in GitHub Desktop.
Garmin FoodPod sensor (FPS) calibration tool. Generates CSV data allowing to compare GPS/FPS distance measurements. Based on original idea from https://fellrnr.com/wiki/Garmin_Foot_Pod_Calibration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
xmlns:tcdb="http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2" | |
xmlns:ext="http://www.garmin.com/xmlschemas/ActivityExtension/v2" | |
version="1.0" | |
> | |
<!-- | |
Garmin FoodPod sensor (FPS) calibration tool. | |
Generates CSV data allowing to compare GPS/FPS distance measurements | |
Input = TCX file from Garmin running activity | |
new calibration factor = Actual distance / sensor distance * previous calibration factor | |
based on original idea from https://fellrnr.com/wiki/Garmin_Foot_Pod_Calibration | |
--> | |
<xsl:output method="text" indent="no"/> | |
<xsl:strip-space elements="*"/> | |
<xsl:template match="/"> | |
<xsl:text>"Interval", "GPS distance(m)", "FPS distance(m)", "Cadence(spm)", "Stride Length(m)" </xsl:text> | |
<xsl:for-each | |
select="/tcdb:TrainingCenterDatabase/tcdb:Activities/tcdb:Activity/tcdb:Lap/tcdb:Track/tcdb:Trackpoint"> | |
<xsl:if test="./tcdb:Extensions/ext:TPX/ext:Speed > 0 and ./tcdb:Extensions/ext:TPX/ext:RunCadence > 0"> | |
<xsl:variable name="currentDistance" select="./tcdb:DistanceMeters"/> | |
<xsl:variable name="previousDistance" | |
select="preceding-sibling::tcdb:Trackpoint[1]/tcdb:DistanceMeters"/> | |
<xsl:variable name="currentTimestamp"> | |
<xsl:call-template name="toSecondsInDay"> | |
<xsl:with-param name="date" select="./tcdb:Time"/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:variable name="previousTimestamp"> | |
<xsl:call-template name="toSecondsInDay"> | |
<xsl:with-param name="date" select="preceding-sibling::tcdb:Trackpoint[1]/tcdb:Time"/> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:variable name="gpsDistance" select="$currentDistance - $previousDistance"/> | |
<xsl:variable name="fpsDistance" | |
select="./tcdb:Extensions/ext:TPX/ext:Speed * ( $currentTimestamp - $previousTimestamp) "/> | |
<xsl:variable name="fpsCadence" select="2 * ./tcdb:Extensions/ext:TPX/ext:RunCadence"/> | |
<xsl:variable name="strideLength" select="./tcdb:Extensions/ext:TPX/ext:Speed div $fpsCadence * 60"/> | |
<xsl:if test="string(number($gpsDistance)) != 'NaN' and string(number($fpsDistance)) != 'NaN'"> | |
<xsl:value-of | |
select="concat(position(),', ',$gpsDistance,', ',$fpsDistance,', ',$fpsCadence,', ',$strideLength)"/> | |
<xsl:text> </xsl:text> | |
</xsl:if> | |
</xsl:if> | |
</xsl:for-each> | |
</xsl:template> | |
<xsl:template name="toSecondsInDay"> | |
<xsl:param name="date"/> | |
<!-- e.g. 2019-12-21T14:51:36.000Z --> | |
<xsl:variable name="h" select="substring($date, 12, 2)"/> | |
<xsl:variable name="m" select="substring($date, 15, 2)"/> | |
<xsl:variable name="s" select="substring($date, 18, 2)"/> | |
<xsl:value-of select="$s + 60*$m + 60*60*$h"/> | |
</xsl:template> | |
</xsl:stylesheet> |
Author
pierre-ernst
commented
Dec 26, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment