<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>andreas.goelzer.de &#187; gps</title>
	<atom:link href="http://andreas.goelzer.de/tag/gps/feed" rel="self" type="application/rss+xml" />
	<link>http://andreas.goelzer.de</link>
	<description>Electronics and small programs and other stuff</description>
	<lastBuildDate>Tue, 29 Nov 2011 21:08:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>GPS plasmoid</title>
		<link>http://andreas.goelzer.de/gps-plasmoid</link>
		<comments>http://andreas.goelzer.de/gps-plasmoid#comments</comments>
		<pubDate>Thu, 09 Apr 2009 16:16:20 +0000</pubDate>
		<dc:creator>Andreas Goelzer</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[gps]]></category>
		<category><![CDATA[plasmoid]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://andreas.goelzer.de/?p=133</guid>
		<description><![CDATA[Having recently acquired a bluetooth GPS receiver for as little as 20 €, and just having switched to KDE 4, i tried to combine those two, and write a little plasmoid to show the current position on the desktop. And &#8230; <a href="http://andreas.goelzer.de/gps-plasmoid">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Having recently acquired a bluetooth <a href="http://en.wikipedia.org/wiki/Gps">GPS</a> receiver for as little as 20 €, and just having switched to <a href="http://www.kde.org/announcements/4.2/desktop.php">KDE 4</a>, i tried to combine those two, and write a little plasmoid to show the current position on the desktop.</p>
<p>And that is basically everything to say, enjoy the little applet.<br />
<span id="more-133"></span></p>
<h3>Installation</h3>
<p>Make sure <a href="http://gpsd.berlios.de/">gpsd</a> is installed and set up properly. Also make sure the python bindings are installed.<br />
In Ubuntu you would need to:</p>
<pre>sudo apt-get install gpsd python-gps
sudo dpkg-reconfigure gpsd
sudo apt-get install python-plasma python-dev</pre>
<p>After those are installed,  you can proceed to install the plasmoid with plasmapkg -i.</p>
<h3>Problems and TODOs</h3>
<p>This is all rather dirty and bloated. The correct way to do it would probably be to write a data engine for plasma, which would provide the positional data. Maybe someone will do it, especially if <a href="http://edu.kde.org/marble/">Marble</a> will one day <strike>be able to support overlays</strike> integrate <a href="http://geoclue.freedesktop.org/">GeoClue</a> or something similar.</p>
<p>Right now the data travels from the GPS device to the PC in the form of <a href="http://www.gpsinformation.org/dale/nmea.htm">NMEA sentences</a>, gets then converted into gpsd&#8217;s own format, python-gps connects to gpsd over TCP port 2947, interprets the gpsd output, hands it over to the applet, which reformats the data yet again. For something so useless that just wastes too many CPU cycles. <a href="http://andreas.goelzer.de/gps-mouse-in-python">Interpreting GPS data</a> entirely in python is not hard, but still a bit harder than with gpsd, especially if one wants to cover a lot of GPS devices. Don&#8217;t get me wrong, gpsd does its job quite well, it is just a bit overkill for this task.</p>
<p>Another improvement would be readable coordinates. Something like &#8220;10 km northwest of Zürich&#8221; or even &#8220;200 meters south of Sternen Oerlikon, Zürich&#8221; would really be much more useful.</p>
<p>Update February 2010: Version 0.16 now uses KDE&#8217;s geolocation data engine. This drops the (direct) dependency on gpsd, and allows for ip-based location &#8211; unfortunately i now can no longer get my gps to work with it, hoping for kubuntu lucid.<br />
<p><a href='photos/screenshots/gps-plasmoid/gps-plasmoid012-zoom.png'><img class='photofiles_thumb' src='thumbs/screenshots/gps-plasmoid/gps-plasmoid012-zoom.png.thumb_small.png' alt='link to photos/screenshots/gps-plasmoid/gps-plasmoid012-zoom.png' height='100' width='100' title=''/></a> <a href='photos/screenshots/gps-plasmoid/gps-plasmoid012.png'><img class='photofiles_thumb' src='thumbs/screenshots/gps-plasmoid/gps-plasmoid012.png.thumb_small.png' alt='link to photos/screenshots/gps-plasmoid/gps-plasmoid012.png' height='100' width='100' title=''/></a> <a href='photos/screenshots/gps-plasmoid/gps-plasmoid012-zoom.jpg'><img class='photofiles_thumb' src='thumbs/screenshots/gps-plasmoid/gps-plasmoid012-zoom.jpg.thumb_small.png' alt='link to photos/screenshots/gps-plasmoid/gps-plasmoid012-zoom.jpg' height='100' width='100' title=''/></a> </p><br />
<hr /><a href='http://andreas.goelzer.de/download/gps-plasmoid_0.16.plasmoid'><img src="http://andreas.goelzer.de/wp-content/plugins/kfile/fileicons/file-generic.png" width="16" height="16" alt="filetype" class="icon16" /> gps-plasmoid_0.16.plasmoid</a> (5.85 kiB, 2010-02-13)<br/><a href='http://andreas.goelzer.de/download/gps-plasmoid_0.15.plasmoid'><img src="http://andreas.goelzer.de/wp-content/plugins/kfile/fileicons/file-generic.png" width="16" height="16" alt="filetype" class="icon16" /> gps-plasmoid_0.15.plasmoid</a> (2.59 kiB, 2009-04-11)<br/><hr /></p>
]]></content:encoded>
			<wfw:commentRss>http://andreas.goelzer.de/gps-plasmoid/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>GPS Mouse in Python</title>
		<link>http://andreas.goelzer.de/gps-mouse-in-python</link>
		<comments>http://andreas.goelzer.de/gps-mouse-in-python#comments</comments>
		<pubDate>Sat, 08 Nov 2008 00:15:49 +0000</pubDate>
		<dc:creator>Andreas Goelzer</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[gps]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://andreas.goelzer.de/?p=74</guid>
		<description><![CDATA[Some months ago I aquired a cheap gps mouse (Royaltek RGM-2000, really cheap, 2 € + shipping) at ebay. My plans to use it in combination with an microcontroller and a display haven&#8217;t worked out, it is a lot of &#8230; <a href="http://andreas.goelzer.de/gps-mouse-in-python">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Some months ago I aquired a cheap gps mouse (Royaltek RGM-2000, really cheap, 2 € + shipping) at ebay. My plans to use it in combination with an microcontroller and a display haven&#8217;t worked out, it is a lot of work and the garmin units do that job fine.<br />
However, playing around with it in python lead to better results. Getting the data to <a href="http://earth.google.com/">google earth</a> works nicely, and at least <a href="http://qlandkarte.sourceforge.net/">qlandkarte</a> can read the generated gpx tracks.<br />
<span id="more-74"></span></p>
<h4>Usage</h4>
<ul>
<li>Start the Program, add a parameter for the port your nmea device is attached to (/dev/ttyUSB0 is the default</li>
<li>Start google earth or something, load the generated kml file (/tmp/posdate by default)</li>
<li>Exit the program by pressing ctrl-c, track data will be written to /tmp/track-some time.gpx</li>
</ul>
<p>Guess I should code something with <a href="http://xkcd.com/407/">extra geek value</a> now.<br />
It might be comfortable to have google earth automatically reload the file, so instead open sth. like</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;kml</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://earth.google.com/kml/2.1&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;NetworkLink<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>GPS<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;flyToView<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/flyToView<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;href<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/tmp/posdata.kml<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/href<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;refreshMode<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>onInterval<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/refreshMode<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;refreshInterval<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>10<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/refreshInterval<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/NetworkLink<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/kml<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<pre lang="python" line="1">#!/usr/bin/python
&quot;&quot;&quot;
Script to read nmea data from a GPS mouse
Copyright (C) 2008  Andreas Goelzer
 
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
 
You should have received a copy of the GNU General Public License
along with this program.  If not, see &lt;http://www.gnu.org/licenses/&gt;.
 
This program reads data from a nmea device (uses the GGA sentence),
and creates a google kml file with the current position and the path
leading there. Additionally, a gpx file is generated containing the
track data with time information.
&quot;&quot;&quot;

from serial import Serial;
from time import strftime, gmtime;
from optparse import OptionParser;


hist = &quot;&quot;;
gpx = &quot;&quot;;

kmlmask=&quot;&quot;&quot;&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;kml xmlns=&quot;http://earth.google.com/kml/2.0&quot;&gt;
&lt;Document&gt;
	&lt;Placemark&gt;
		&lt;name&gt;Your Position&lt;/name&gt;
		&lt;Point&gt;
			&lt;coordinates&gt;%s&lt;/coordinates&gt;
		&lt;/Point&gt;
	&lt;/Placemark&gt;
	&lt;Placemark&gt;
		&lt;name&gt;Previous positions&lt;/name&gt;
		&lt;description&gt;Path that lead you here&lt;/description&gt;
		&lt;LineString&gt;
			&lt;coordinates&gt;%s&lt;/coordinates&gt;
		&lt;/LineString&gt;
	&lt;/Placemark&gt;
&lt;/Document&gt;
&lt;/kml&gt;&quot;&quot;&quot;
#			&lt;altitudeMode&gt;absolute&lt;/altitudeMode&gt;

gpxmask = &quot;&quot;&quot;&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot; ?&gt;&lt;gpx xmlns=&quot;http://www.topografix.com/GPX/1/1&quot; xmlns:gpxx=&quot;http://www.garmin.com/xmlschemas/GpxExtensions/v3&quot; xmlns:gpxtpx=&quot;http://www.garmin.com/xmlschemas/TrackPointExtension/v1&quot; creator=&quot;Colorado 300&quot; version=&quot;1.1&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd http://www.garmin.com/xmlschemas/GpxExtensions/v3 http://www.garmin.com/xmlschemas/GpxExtensions/v3/GpxExtensionsv3.xsd http://www.garmin.com/xmlschemas/TrackPointExtension/v1 http://www.garmin.com/xmlschemas/TrackPointExtension/v1/TrackPointExtensionv1.xsd&quot;&gt;
&lt;trk&gt;&lt;name&gt;%s&lt;/name&gt;&lt;trkseg&gt;%s&lt;/trkseg&gt;&lt;/trk&gt;&lt;/gpx&gt;&quot;&quot;&quot;

def gpstime():
	return strftime(&quot;%Y-%m-%dT%H:%M:%SZ&quot;,gmtime());

def readlatlon(value,inverse):
	lat = float(value);
	lat2 = int(lat) / 100;
	lat = lat2 + (lat - 100 * lat2)/ 60; 
	if inverse:
		lat = -lat;
	return lat;

def calcchecksum(checkstr):
	cs = ord(checkstr[0]);
	for i in range(1,len(checkstr)):
		cs ^= ord(checkstr[i])
	return cs;


class sentencevalidator:
	&quot;Check checksum and other stuff and split to fields&quot;
	def __init__(self,line):
		if(line[0] == '$' and line[-5] == '*' and calcchecksum(line[1:-5]) ==  int(line[-4:-2],16)):
			self.valid = True;
			self.sentence = line[3:6];
			self.data = line[7:-5].split(',');
		else :
			self.valid = False;

parser = OptionParser(version=&quot;%prog 0.1&quot;);
parser.add_option(&quot;-s&quot;, &quot;--serial&quot;, dest=&quot;serial&quot;,
                  help=&quot;serial terminal of the gps unit&quot;, default='/dev/ttyUSB0', metavar=&quot;FILE&quot;);
parser.add_option(&quot;-g&quot;, &quot;--gpxfile&quot;, dest=&quot;gpxfile&quot;,
                  help=&quot;GPX output file&quot;, default=&quot;/tmp/track&quot; + gpstime() + &quot;.gpx&quot;, metavar=&quot;FILE&quot;);
parser.add_option(&quot;-k&quot;, &quot;--kmlfile&quot;, dest=&quot;kmlfile&quot;,
                  help=&quot;KML output file&quot;, default=&quot;/tmp/posdata.kml&quot;, metavar=&quot;FILE&quot;);
parser.add_option(&quot;-v&quot;, &quot;--verbose&quot;,
                  action=&quot;store_true&quot;, dest=&quot;verbose&quot;, default=False,
                  help=&quot;print debug messages&quot;);
 
(options, args) = parser.parse_args();

gps = Serial(options.serial, 4800, timeout=1);


#on sirf chips, activate all sentences
for i in range(1,5):
	cmd = &quot;PSRF103,0%d,00,05,01&quot; % i;
	realcmd=&quot;$%s*%x\r\n&quot; % (cmd,calcchecksum(cmd));
	print realcmd;
	gps.write(realcmd)

try:
	while 1:
		line = gps.readline()
		if(options.verbose): print line,
		s = sentencevalidator(line);
		if(s.valid and s.sentence == &quot;GGA&quot; and int(s.data[5]) != 0):
			lat = readlatlon(s.data[1],s.data[2]=='S');
			lon = readlatlon(s.data[3],s.data[4]=='W');
			alt = float(s.data[8]);
				
			gpx += &quot;\n&quot; + '&lt;trkpt lat=&quot;%f&quot; lon=&quot;%f&quot;&gt;&lt;ele&gt;%f&lt;/ele&gt;&lt;time&gt;%s&lt;/time&gt;&lt;/trkpt&gt;' % (lon,lat,alt,gpstime())
			
			position =  &quot;%f, %f, %f&quot; % (lon,lat,alt);
			print position
			hist += &quot;\n&quot; + position;
			f=open(&quot;/tmp/posdata.kml&quot;,'w');
			f.write(kmlmask % (position,hist));
			f.close();

except:
	0

f=open(options.gpxfile,'w');
f.write(gpxmask % (gpstime(),gpx));
f.close();

gps.close()</pre><hr /><a href='http://andreas.goelzer.de/download/readgps.py'><img src="http://andreas.goelzer.de/wp-content/plugins/kfile/fileicons/file-source-alt.png" width="16" height="16" alt="filetype" class="icon16" /> readgps.py</a> (4.46 kiB, 2008-11-08)<br/><hr />
]]></content:encoded>
			<wfw:commentRss>http://andreas.goelzer.de/gps-mouse-in-python/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 3/8 queries in 0.030 seconds using disk: basic
Object Caching 276/283 objects using disk: basic

Served from: andreas.goelzer.de @ 2012-02-05 04:46:13 -->
