вторник, 23 апреля 2013 г.

GlobalSat GH-625M Sports Tracker, Endomondo and Linux

Pareto distribution says that probably only 20 % of variants for your choice can suit your needs up to 80 %, the rest 80% is only able do this for 20%. I investigated characteristics a number of sport tracking devices and found that only few models from Polar (triathlon series) and Garmin (910 XT) can track both your geo position while you are on working in addition to heart rate, and do some measurements underwater. But this devices are certainly from the top of pricing while I'm quite new to sport enabled lifestyle and not even sure that I nee all this and not ready to pay the highest price. In addition to my doubts there are Bluetooth Heart Rate Monitors that allows you do all things with your smartphone and Endomondo application that can be cheaper than top all-in-one device even if you buy swimming-only sport watch in addition. Then I went to DealExtreme to search for probable cheaper solutions but have found the same big number of useless HRM devices and only one that does GPS, HRM and allows to sync all this data with PC. This device is GH-625M.
It's quite cool and looks much better in real life that on marketing fotos.

The first issue was the driver on CD while my optical device is disabled for a long period as of unability to work with once changed SATA motherboard. I downloaded a number of software from websites lanched Windows XP in VirtualBox and started trying all this to be able to download data from device and convert it to .gpx format to load to endomondo that helps be motivated with sport activities for a number of monthes. Neither usage of desktop only software nor other services doesn't look competitive for me (again Pareto rule, uh ?)  due to different reasons. I tried Sport Tracks, Training Gym Pro and number of offline and online converters but nothing from them gave me the file I needed to import track properly. So I tried one unoffical script that according to description was able to load data from device in a number of formats, you can download it here:
Btw, it looks crossplatform, so you can try it even if you are not linux geek. This script also does not provide files that contain hrm data compatible to endo's import, but this software allows to define data export templates and I implemented tcx format data export template with hrm data provided.
If you new to this you should download the recent version, unpack and remove the following line from templates.py:
from compiler.consts import SC_LOCAL, SC_GLOBAL, SC_FREE, SC_CELL
as described here: 
http://lizziespants.blogspot.ru/2010/11/gh-625-gps-on-linux.html
if all ok after plugin device to usb and confirming "Conect to PC?" dialog you will be able to manipulate device data records with commands like this one:
gh600_console.py c -o ./export -f gpx
If you getting errors you probably have to set permissions on /dev/ttyUSB0 device file and uncomment sugnificant line in config.ini of script folder.
This will generate you gpx track xml files to export folder, but to do valid exports you should add the following lines to exportTemplates/formats.ini file:

  
  
  <% for track in tracks %>
    
      
       
       
       
      
     <% for trackpoint in track.trackpoints %>
        
   <% endfor %>
      
      
      <% if hasattr(track, 'laps') %>
      
      <% for lap in track.laps %>
      
       $lap.distance
       $lap.calories
      
      <% endfor %>
      
      <% endif %>
    
    
  <% endfor %>
  

we should also add the preparser that will calculate average heart beat value and define maxmimum put file named tcx.py in pre subfolder of exportTemplates with the followin code:
def pre(track):
 track.hrMax = 0
 track.hrSum = 0
 track.hrAvg = 0
 for trackpoint in track.trackpoints:
  track.hrSum += trackpoint.heartrate
  if (trackpoint.heartrate > track.hrMax):
   track.hrMax = trackpoint.heartrate
 if (len(track.trackpoints) > 0 and track.hrSum > 0):
  track.hrAvg = track.hrSum / len(track.trackpoints)

Pay attention to identation as this is python. After all you will be able use command with option -f tcx to generate files formatted as required. As we have *nix power we will add udev rule for device, create file /etc/udev/rules.d/99-gpsd.rules with the following lines:
# GH-625M
SYSFS{idVendor}=="067b", SYSFS{idProduct}=="2303", SYMLINK="ttyUSB%n", GROUP="users", MODE="0666" RUN+="gsimportdata"
This will set necessary permissions when device is just connected and run /usr/bin/gsimportdata script that is also must be created by you with the following lines:
#!/bin/bash
env > /tmp/env.out
DISPLAY=:0.0
/usr/bin/notify-send -t 1 "Tracking device found" "Downloading the data started"
python /media/STORE2/globalsat/gh600_console.py c -o /media/STORE2/globalsat/export -f tcx
/usr/bin/notify-send -t 1 "Tracking device found" "Downloading the data finished"
This will show you OSD notification and launch export process automagically and no noisy buttons and dialogs:)
Nice online converter: http://www.gpsies.com/convert.do

Комментариев нет: