diff options
author | Anton Babushkin <anton.babushkin@me.com> | 2014-07-10 14:11:25 +0200 |
---|---|---|
committer | Anton Babushkin <anton.babushkin@me.com> | 2014-07-10 14:11:25 +0200 |
commit | fc1669b0969890456f9151dd9719af87df62e69c (patch) | |
tree | ceee6fa9a7642b4ef2b63921299c006987add5a8 /mavlink/share/pyshared/pymavlink/examples/wptogpx.py | |
parent | 9b2d444cc56eaaedcf271f200b93dcca94623209 (diff) | |
parent | 58cae259e40a3dcab132f42348d57767fca600a1 (diff) | |
download | px4-firmware-fc1669b0969890456f9151dd9719af87df62e69c.tar.gz px4-firmware-fc1669b0969890456f9151dd9719af87df62e69c.tar.bz2 px4-firmware-fc1669b0969890456f9151dd9719af87df62e69c.zip |
Merge branch master into dataman_state_nav_rewrite
Diffstat (limited to 'mavlink/share/pyshared/pymavlink/examples/wptogpx.py')
-rw-r--r-- | mavlink/share/pyshared/pymavlink/examples/wptogpx.py | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/mavlink/share/pyshared/pymavlink/examples/wptogpx.py b/mavlink/share/pyshared/pymavlink/examples/wptogpx.py deleted file mode 100644 index 306f20af2..000000000 --- a/mavlink/share/pyshared/pymavlink/examples/wptogpx.py +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/env python - -''' -example program to extract GPS data from a waypoint file, and create a GPX -file, for loading into google earth -''' - -import sys, struct, time, os - -# allow import from the parent directory, where mavlink.py is -sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)), '..')) - -from optparse import OptionParser -parser = OptionParser("wptogpx.py [options]") -(opts, args) = parser.parse_args() - -import mavutil, mavwp - -if len(args) < 1: - print("Usage: wptogpx.py <WPFILE>") - sys.exit(1) - -def wp_to_gpx(infilename, outfilename): - '''convert a wp file to a GPX file''' - - wp = mavwp.MAVWPLoader() - wp.load(infilename) - outf = open(outfilename, mode='w') - - def process_wp(w, i): - t = time.localtime(i) - outf.write('''<wpt lat="%s" lon="%s"> - <ele>%s</ele> - <cmt>WP %u</cmt> -</wpt> -''' % (w.x, w.y, w.z, i)) - - def add_header(): - outf.write('''<?xml version="1.0" encoding="UTF-8"?> -<gpx - version="1.0" - creator="pymavlink" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns="http://www.topografix.com/GPX/1/0" - xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd"> -''') - - def add_footer(): - outf.write(''' -</gpx> -''') - - add_header() - - count = 0 - for i in range(wp.count()): - w = wp.wp(i) - if w.frame == 3: - w.z += wp.wp(0).z - if w.command == 16: - process_wp(w, i) - count += 1 - add_footer() - print("Created %s with %u points" % (outfilename, count)) - - -for infilename in args: - outfilename = infilename + '.gpx' - wp_to_gpx(infilename, outfilename) |