Skip to content

Commit f38468f

Browse files
committed
Added 2016 folder, reorganized 2015 contest folder
1 parent d5728e1 commit f38468f

File tree

5 files changed

+172
-9
lines changed

5 files changed

+172
-9
lines changed

Fall-2015/Final.py 2015/Final.py

File renamed without changes.
File renamed without changes.

Fall-2015/motor.py 2015/motor.py

File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
#! /usr/bin/env python
2+
3+
##########################################################################################
4+
# GPS_Visualization_Gmaps.py
5+
#
6+
# Modified from script to post-process GPS data from Anaconda trials
7+
#
8+
# Plots data on Google Maps using pygmaps
9+
#
10+
# Data loaded from csv file with columns that are:
11+
# Time, Date, Fix, Fix Quality, Num Sats, Latitude DDMM.mmmm, Longitude DDMM.mmmm, Speed, Heading, Alt
12+
#
13+
# NOTE: Plotting is set up for output, not viewing on screen.
14+
# So, it will likely be ugly on screen. The saved PDFs should look
15+
# better.
16+
#
17+
# Created: 04/11/14
18+
# - Joshua Vaughan
19+
20+
# - http://www.ucs.louisiana.edu/~jev9637
21+
#
22+
# Modified:
23+
# * 09/12/15 - JEV - [email protected]
24+
# - conversion to Python 3
25+
# - begin conversion away from Anaconda data
26+
#
27+
##########################################################################################
28+
29+
30+
import numpy as np
31+
from matplotlib.pyplot import *
32+
from scipy import signal
33+
34+
import tkinter as tk
35+
from tkinter.filedialog import askopenfilename, askdirectory
36+
37+
import csv
38+
import datetime
39+
40+
import pygmaps
41+
42+
# Define what kind of output you want
43+
save_for_web = False
44+
produce_pymap = True
45+
is_pyNMEA = False
46+
47+
48+
try:
49+
root = tk.Tk()
50+
root.withdraw()
51+
52+
file_path = askopenfilename()
53+
54+
# # Process the time into a "trial time"
55+
# trialTime_array = np.zeros(len(trialTime))
56+
#
57+
# for index in range(len(trialTime)):
58+
# trialTime_parsed = datetime.datetime.strptime(trialTime[index],"%H:%M:%S.%f")
59+
# trialTime_seconds = (trialTime_parsed.minute*60. + trialTime_parsed.second) + trialTime_parsed.microsecond/(10.**6)
60+
# trialTime_array[index] = trialTime_seconds
61+
#
62+
# trialTime_array = trialTime_array - trialTime_array[0]
63+
64+
# Grab the rest of the data as numpy arrays
65+
# Probably slower but more convenient
66+
data = np.genfromtxt(file_path, delimiter=',', skip_header = 1)
67+
68+
# Parse the data (inelegantly for now)
69+
# time = data[:,0]
70+
if is_pyNMEA:
71+
# set up pyNMEA parsing
72+
pass
73+
else:
74+
date = data[:,0]
75+
76+
latitude = data[:,1]
77+
longitude = data[:,2]
78+
speed = data[:,7]
79+
heading = data[:,8]
80+
81+
# altitude = data[:,9]
82+
fix_quality = data[:,13]
83+
num_sats = data[:,14]
84+
85+
if save_for_web:
86+
#----- Save data for export to http://www.gpsvisualizer.com ----------------------------
87+
header = ['Trackpoint','Latitude','Longitude','speed','course']
88+
89+
trackpoint = (np.arange(1,len(latitude)+1)).reshape(len(latitude),1)
90+
latitude = latitude.reshape(len(latitude),1)
91+
longitude = longitude.reshape(len(latitude),1)
92+
speed = speed.reshape(len(latitude),1)
93+
heading = heading.reshape(len(latitude),1)
94+
95+
map_data = np.hstack((trackpoint, latitude, longitude, speed, heading))
96+
97+
with open('gps_data.csv','w') as f:
98+
f_csv = csv.writer(f)
99+
f_csv.writerow(header)
100+
for row in map_data:
101+
for el in row:
102+
f.write(repr(el)+', ')
103+
f.write('\n')
104+
105+
np.savetxt('map_data.csv', map_data, delimiter = ',', comments='', header = 'trackpoint,latitude,longitude,speed,course')
106+
107+
if produce_pymap:
108+
########## CONSTRUCTOR: pygmaps.maps(latitude, longitude, zoom) ##############################
109+
# DESC: initialize a map with latitude and longitude of center point
110+
# and map zoom level "15"
111+
# PARAMETER1: latitude (float) latittude of map center point
112+
# PARAMETER2: longitude (float) latittude of map center point
113+
# PARAMETER3: zoom (int) map zoom level 0~20
114+
# RETURN: the instant of pygmaps
115+
#========================================================================================
116+
mymap = pygmaps.gmaps.maps(latitude[0], longitude[0], 15)
117+
118+
lat_shaped = latitude.reshape(len(latitude),1)
119+
long_shaped = longitude.reshape(len(latitude),1)
120+
121+
#----- Draw the trial on a Google map ---------------------------------------------------
122+
path = np.hstack((lat_shaped,long_shaped)).tolist()
123+
124+
red = 255
125+
blue = 0
126+
green = 0
127+
128+
color = '#%02X%02X%02X' % (red,green,blue)
129+
mymap.add_path(path, color)
130+
131+
# ########## FUNCTION: addpoint(latitude, longitude, [color])#############################
132+
# # DESC: add a point into a map and dispaly it, color is optional default is red
133+
# # PARAMETER1: latitude (float) latitude of the point
134+
# # PARAMETER2: longitude (float) longitude of the point
135+
# # PARAMETER3: color (string) color of the point showed in map, using HTML color code
136+
# # HTML COLOR CODE: http://www.computerhope.com/htmcolor.htm
137+
# # e.g. red "#FF0000", Blue "#0000FF", Green "#00FF00"
138+
# # RETURN: no return
139+
# #========================================================================================
140+
# mymap.addpoint(29.722168, -91.208519, 'Swiftships')
141+
142+
143+
########## FUNCTION: draw(file)######################################################
144+
# DESC: create the html map file (.html)
145+
# PARAMETER1: file (string) the map path and file
146+
# RETURN: no return, generate html file in specified directory
147+
#========================================================================================
148+
149+
# define filename - assumes that original datafile was .csv
150+
# TODO: make this more robust
151+
map_filename = file_path.replace('csv','html')
152+
mymap.draw(map_filename)
153+
154+
except (KeyboardInterrupt, SystemExit): # when you press ctrl+c
155+
pass
156+
157+
158+
159+
160+
161+
162+
163+

GPS_visualization/poyboard_log.csv

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
(0, 0, 0),(22, 21, 22.0), (30.21021, -92.02254), (30.21022, -92.02257), 303.0602, 301.5501, 1.510101, 37.75057
1+
(22, 21, 22.0), (30.21021, -92.02254), (30.21022, -92.02257), 303.0602, 301.5501, 1.510101, 37.75057
22
(22, 21, 26.0), (30.21022, -92.02257), (30.21023, -92.02258), 270.0, 302.6246, 32.6246, 36.63803
33
(22, 21, 31.0), (30.21023, -92.02258), (30.21022, -92.02262), 247.9518, 307.15, 59.19818, 34.59551
44
(22, 21, 39.0), (30.21022, -92.02262), (30.21021, -92.02268), 260.8697, 315.232, 54.36237, 30.63033
55
(22, 21, 45.0), (30.21021, -92.02268), (30.2102, -92.02273), 265.275, 322.4698, 57.19482, 27.87095
66
(22, 21, 51.0), (30.2102, -92.02273), (30.21023, -92.02275), 323.4715, 322.6032, 0.8683777, 24.86348
7-
(22, 21, 54.0), (30.21023, -92.02275), (30.21023, -92.02277), 274.1366, 327.4764, 53.3398223.04159
8-
(22, 22, 2.0), (30.21023, -92.02277), (30.21023, -92.02281), 272.7604, 336.0145, 63.2540920.82261
9-
(22, 22, 6.0), (30.21023, -92.02281), (30.21024, -92.02284), 295.741, 340.1972, 44.4562119.37931
10-
(22, 22, 14.0), (30.21024, -92.02284), (30.21026, -92.02288), 302.4742, 348.5063, 46.032116.28836
11-
(22, 22, 17.0), (30.21026, -92.02288), (30.21026, -92.0229), 295.741, 355.0608, 59.3198315.25105
12-
(22, 22, 22.0), (30.21026, -92.0229), (30.21028, -92.02292), 288.6498, 10.72534, 82.0755313.92486
13-
(22, 22, 28.0), (30.21028, -92.02292), (30.21031, -92.02294), 348.5063, 17.15216, 28.6458411.13115
14-
(22, 22, 34.0), (30.21031, -92.02294), (30.21034, -92.02292), 9.805939, 21.01086, 11.204937.324474
7+
(22, 21, 54.0), (30.21023, -92.02275), (30.21023, -92.02277), 274.1366, 327.4764, 53.33982, 23.04159
8+
(22, 22, 2.0), (30.21023, -92.02277), (30.21023, -92.02281), 272.7604, 336.0145, 63.25409, 20.82261
9+
(22, 22, 6.0), (30.21023, -92.02281), (30.21024, -92.02284), 295.741, 340.1972, 44.45621, 19.37931
10+
(22, 22, 14.0), (30.21024, -92.02284), (30.21026, -92.02288), 302.4742, 348.5063, 46.0321, 16.28836
11+
(22, 22, 17.0), (30.21026, -92.02288), (30.21026, -92.0229), 295.741, 355.0608, 59.31983, 15.25105
12+
(22, 22, 22.0), (30.21026, -92.0229), (30.21028, -92.02292), 288.6498, 10.72534, 82.07553, 13.92486
13+
(22, 22, 28.0), (30.21028, -92.02292), (30.21031, -92.02294), 348.5063, 17.15216, 28.64584, 11.13115
14+
(22, 22, 34.0), (30.21031, -92.02294), (30.21034, -92.02292), 9.805939, 21.01086, 11.2049, 37.324474

0 commit comments

Comments
 (0)