Beispiel #1
0
    def readGPS(self, readingType, callType):
        # read gps until it gets valid data
        #while True:
        gpsData = GPS.read()
        #if gpsData['fix']:
        #	break

        # we will update the bearing independent of the coordinates on the assumption that the gps will read the
        # coordinates more accurately while stationary, and the bearing more accurateley while moving
        if (readingType == 'LatLong'):
            if (callType == 'current'):
                self.currentLat = gpsData['latitude']
                self.currentLat = gpsData['longitude']
                #telemetry.dataList['currentLat'] = gpsData['latitude']
                #telemetry.dataList['currentLong'] = gpsData['longitude']
            elif (callType == 'intial'):
                self.startLat = gpsData['latitude']
                self.startLong = gpsData['longitude']
                #telemetry.dataList['startLat'] = gpsData['latitude']
                #telemetry.dataList['startLong'] = gpsData['longitude']
            elif (callType == 'water'):
                self.waterLat = gpsData['latitude']
                self.waterLong = gpsData['longitude']
                #telemetry.dataList['waterLat'] = gpsData['latitude']
                #telemetry.dataList['waterLong'] = gpsData['longitude']
        elif (readingType == 'bearing'):
            self.bearing == gpsData['bearing']
Beispiel #2
0
    def waterDetected(self):
        self.stopMovement()

        with open('stats.txt', 'r') as txt:
            # read a list of lines into data
            data = txt.readlines()
        txt.close()

        gpsReading = GPS.read()
        # now change the line wishing to write to (see constants for defined line numbers)
        data[WATER_FOUND] = "True\n"

        if gpsReading['fix']:
            data[CURRENT_LAT] = gpsReading['latitude']
            data[CURRENT_LONG] = gpsReading['longitude']
            data[WATER_LAT] = gpsReading['latitude']
            data[WATER_LONG] = gpsReading['longitude']
        else:
            data[CURRENT_LAT] = 'No GPS Fix\n'
            data[CURRENT_LONG] = 'No GPS Fix\n'
            data[WATER_LAT] = 'No GPS Fix\n'
            data[WATER_LONG] = 'No GPS Fix\n'

        # and write everything back
        with open('stats.txt', 'w') as file:
            txt.writelines(data)
        txt.close()
Beispiel #3
0
def _get_gps():
    #get latitude/longitude from the read() function imported from gpsReader.py
    gpsData = gpsReader.read()

    #returns a json object (a kind of dictionary) with a key called 'data' with
    #a corresponding value that's a snippet of HTML code containing our gpsData
    #formatted by the template in response.html
    return jsonify({'data': render_template('response.html', gpsData=gpsData)})
Beispiel #4
0
def resetTelemFile():
    with open('stats.txt', 'r') as txt:
        # read a list of lines into data
        data = txt.readlines()
    txt.close()

    # now change the lines wishing to write to (see constants for defined line numbers)
    data[WATER_FOUND] = "False\n"
    gpsReading = gps.read()

    if gpsReading['fix']:
        data[CURRENT_LAT] = str(gpsReading['latitude']) + '\n'
        data[CURRENT_LONG] = str(gpsReading['longitude']) + '\n'
    else:
        data[CURRENT_LAT] = "No GPS Fix"
        data[CURRENT_LONG] = "No GPS Fix"
    date[WATER_LAT] = "Not Yet Found\n"
    data[WATER_LONG] = "Not Yet Found\n"

    # and write everything back
    with open('stats.txt', 'w') as file:
        txt.writelines(data)
    txt.close()