Hi *,

So I got Google Earth working on my netbook at last -- it's still
slow, but somewhat usable. Anyway, having screwed up entering
altosui's GPS coords into my phone, and thus having to spend a good
minutes looking for my rocket instead of seconds, it occurred to me
that having a marker on google maps/earth would have clued me in
better. And then I thought it'd be even cooler if I could watch Google
Earth plotting my rocket's trajectory from telemetry data while it was
in flight.

It looks like that's possible. Attached are a quick and dirty python
script and netlink kml file. If you run the python script against a
kml file exported from altosui, then point google earth at the netlink
file you'll get to watch a replay of your rocket flight. Pretty cool,
I think!

All the script does it keeps a counter of (virtual) seconds since
launch, and copies all the coordinates from the kml file up to that
time into altos-live-data.kml (it also adds a pin at ground level
corresponding with the latest coordinate telling you what time stamp
it's up to). The altos-link.kml file just tells Google Earth to look
at altos-live-data.kml and refresh it every second. Command line
invocation looks something like:

$ googleearth `pwd`/altos-link.kml &
$ python ./livekml.py 2010-10-17-serial-224-flight-010.kml

Cheers,
aj

-- 
Anthony Towns <[email protected]>
import re, time, sys

re_time = re.compile('.*alt.*time[ \t]+([0-9.]+)[ \t]')

def kmlupto(kmlfile, time):
    f = open(kmlfile)
    out = open("altos-live-data.kml", "w")
    last_coord = None
    for ln in f.readlines():
        if ln.startswith("</Document"):
            if last_coord is not None:
                out.write("<Placemark><name>T+%d SECONDS</name>\n" % time)
                out.write("<Point><coordinates>%s</coordinates></Point>" %
                          last_coord)
                out.write("</Placemark>\n")
        td = re_time.match(ln)
        if td is not None:
            if float(td.group(1)) > time:
                continue
            last_coord = ln
        out.write(ln)
    out.close()
    f.close()

kmlfile = sys.argv[1]
starttime = time.time()
cnt = 0
while True:
    x = time.time()
    time.sleep(max(0, cnt-x+starttime))
    print "Time: %d" % (cnt)
    kmlupto(kmlfile, cnt)
    cnt += 1

Attachment: altos-link.kml
Description: application/vnd.google-earth.kml

_______________________________________________
altusmetrum mailing list
[email protected]
http://lists.gag.com/mailman/listinfo/altusmetrum

Reply via email to