2 # -*- coding: iso-8859-15 -*-
7 from geodesy import utm
8 from gps_follow_waypoints import GPSGotoCoords
10 DEFAULT_GPSD_HOSTNAME="wildthumper"
11 DEFAULT_GPSD_PORT="2948"
14 def __init__(self, hostname=DEFAULT_GPSD_HOSTNAME, port=DEFAULT_GPSD_PORT):
15 self.gpsd = gps.gps(host=hostname, port=port)
16 self.gpsd.stream(gps.WATCH_ENABLE | gps.WATCH_NEWSTYLE)
17 self.follower = GPSGotoCoords()
21 for report in self.gpsd:
22 if report['class'] == "TPV":
23 if report['mode'] == 0:
24 print "No data from gpsd"
26 coords_cur = utm.fromLatLong(report.lat, report.lon)
27 coords_cur = [coords_cur.northing, coords_cur.easting]
29 # Check difference to last goal
30 if np.linalg.norm(np.array(coords_cur) - np.array(coords_last)) > 3:
31 print "Setting new goal"
33 thread.start_new_thread(self.follower.next_pos, (report.lat, report.lon))
34 coords_last = coords_cur
36 if __name__ == "__main__":