Example #1
0
    def __init__(self):

        self.imageProcessor = ImageProcessor.ImageProcessor()
        self.gps = GPS.GPS()
        self.current_angle = 90
        self.processedImage = ""
        self.turnCommand = tuple()
Example #2
0
 def __init__(self):
     self.gps = GPS.GPS()
     self.gpsData = GPS.GPSData
     self.dataBase = db.DataBase()
     self.gpsAr = []
     self.f = "/app/storage/json/gps.json"
     threading.Thread.__init__(self)
Example #3
0
def driveToNode(node):
    gps = GPS.GPS()
    location = gps.getLocation()
    currentHeading = gps.getHeading()
    targetHeading = gps.calculateHeadingFromCoords(location, node.coords)
    delta = targetHeading - currentHeading
    if delta > 180:
        delta = delta - 360
    if delta < -180:
        delta = delta + 360
    distance = Navigator.distance(location, node.coords)
    #I don't think this part will be relevant for our purposes, but it's cool math nonetheless
    radius = 12  #In inches
    distanceToTravel = math.pi * (radius**2)
    distanceToTravel = distanceToTravel * (delta / 720)
    #Could take average inches per milisecond at full throttle and calculate.
    #Problem is that this would probably vary with the charge of the battery
    if delta > 0:
        stop()
        pi.set_PWM_dutycycle(leftMotorFwd, 255)
        pi.set_PWM_dutycycle(rightMotorBkd, 255)
    else:
        stop()
        pi.set_PWM_dutycycle(leftMotorBkd, 255)
        pi.set_PWM_dutycycle(rightMotorFwd, 255)
    time.sleep(abs(delta) / 80)
    stop()
    if locked == False:
        pi.set_PWM_dutycycle(leftMotorFwd, 255)
        pi.set_PWM_dutycycle(rightMotorFwd, 255)
Example #4
0
 def aplicarFiltro(self, listaBares, directorio):
     gps = GPS()
     BaresCercanos = [
         unBar for unBar in listaBares if gps.distanciaEntre(
             self.punto, unBar.darUbicacion()) < self.distanciaMaxima
     ]
     return BaresCercanos
Example #5
0
def runGPS():
    gipped = GPS.GPS()

    while True:  # not as bad as it looks, can be killed in interface
        #display current status
        print(gipped)

        #run through one iteration of user input
        gipped = gpsUI(gipped)
Example #6
0
def checkForObstacles():
    gps = GPS.GPS()
    global locked
    while True:

        locked = gps.obstacleDetected()

        if locked == True:
            stop()
            print("STOP!")
        time.sleep(.5)
Example #7
0
def goToCoordinates(lat, lon):
    gps = GPS.GPS()
    path = Navigator.generatePath(gps.getLocation(), [lat, lon])
    Navigator.dictPrint(path)
    #print(path)
    for node in reversed(path):
        print("Next Node Reached")
        driveToNode(node)
        while Navigator.distance(gps.getLocation(), node.coords) > 5:
            time.sleep(.5)
        #When the loop exits, we have arrived at next point in path
        stop()
def voice_current(name, index):  # This is current user voice analysis module.
    print(
        "\nWhen you are ready to record, press 'r' and hit 'enter' on your keyboard. Note, you have 3 seconds to say your phrase"
    )
    print(
        "There is a 2 second delay after your keyboard input. You will be prompted when to speak."
    )
    print("The phrase you need to say is: This is (your name)")
    u_input = str("k")
    while (u_input !=
           "r"):  # we wait for the user to press "r" and hit "enter"
        print("\nPress 'r' and hit 'enter' when ready to say your phrase")
        u_input = input(
        )  # capture user input and check if it was "r" or no. If yes, go ahead if not loop until "r" pressed

    record_audio_test(
    )  # we then call the audio recording code for the current user. It saves a sample.wav file in the current directory
    mfcc_result = test_model(
        name
    )  # performs voice analysis and return true if passed and false if it did not
    # if the return value was true we get the GPS cordinates and return to the main menu
    if mfcc_result == True:
        GPS()
        main()
    # if the return value was false we allow user to try two more times before getting locked out for X# of seconds
    else:
        attempt = 2
        for a in range(attempt):  # users get 3 attempts
            print("We did not recognize you as", name, ". Try again.")
            record_audio_test()

            mfcc_result = test_model(name)
            if mfcc_result == True:  # if the result comes back as true, we head to GPS module and display coordinates
                GPS()  # return to main once complete
                main()

        print("Too many attempts. Locking you out for 10 sec.")
        time.sleep(10)  # time that user gets locked out (in sec)
        main()  # return to main once max attempts are reached
Example #9
0
    def __init__(self):
        #Get initial time offset
        self.initial_time = time.time() * 1000.0
        self.current_time = 0

        #Define timer variables
        self.previous_start_up_time = 0
        self.previous_data_read_time = 0
        self.previous_buzzer_time = 0
        self.previous_cut_time = 0
        self.previous_beep_time = 0

        #Define data read variable
        self.previous_IMU_read = 0
        self.previous_GPS_read = 0
        self.previous_BMP_read = 0

        #Buzzer variables
        self.beep = 0  #0 = idle, 1 = on

        #GPS initial conditions
        self.locked = False
        self.initialPosition = []
        self.boundary_cutdown = False

        #Initiate Peripherals
        self.buzzer = Buzzer.Buzzer(
            self.buzzer_pin1, self.buzzer_pin2, self.current_time,
            self.buzzer_start_time,
            self.altitude_threshold)  #Create Buzzer Object
        self.CutDown = CutDown.CutDown(self.current_time, self.cut_down_pin,
                                       self.cut_time)  #Create CutDown Object
        self.lsm = LSM303DLM.LSM303DLM()
        self.lsm.enableDefault()
        self.l3g = L3G4200D.L3G4200D()
        self.l3g.enableDefault()
        self.bmp = BMP085.BMP085()
        self.gps = GPS.GPS()

        #Create log files
        newpath = './log'
        if not os.path.exists(newpath):
            os.makedirs(newpath)
        self.imu_file = open(newpath + "/IMUData.txt", "w")
        self.bmp_file = open(newpath + "/BMPData.txt", "w")
        self.gps_file = open(newpath + "/GPSData.txt", "w")

        #temp variables, remove later
        self.previous_time_temp = 0
        self.count = 0
Example #10
0
"""
This plug-in creates a new actions (copy_file_name, copy_base_file_name) in
GPS (which you can bind to a key shortcut or a menu), which copies the full or
base name of the current file into the system clipboard. You can then paste it
in any application.

The current file is either the select file (if for instance the Project view
has the focus), or the name of the last editor that had the focus otherwise.
"""

import GPS
import gs_utils


@gs_utils.interactive()
def copy_file_name():
    """
    Copy the full name of the current file in the clipboard, so that it can be
    pasted elsewhere.
    """

    ctxt = GPS.current_context()
    if ctxt.file():
        f = ctxt.file().path
    elif ctxt.directory():
        f = ctxt.directory()
    else:
        b = GPS.EditorBuffer.get(open=False)
        if b:
            f = b.file().path
        help="Set logging level (use `-v` for INFO and `-vv` for `DEBUG`)",
    )

    args = parser.parse_args()

    # Set logging level
    if args.verbose is None:
        level = logging.WARNING
    elif args.verbose == 1:
        level = logging.INFO
    else:  # 2 or more
        level = logging.DEBUG
    logging.basicConfig(level=level)

    # Serial port
    logger.info("Connecting serial port %r", args.serial)
    ser = serial.Serial(args.serial, 9600, timeout=5)

    if args.test == 'sim':
        pass
    elif args.test == 'gps':
        import GPS

        logger.info('GPS tracker')
        gps = GPS.GPS(ser)

        asyncio.get_event_loop().run_until_complete(
            asyncio.wait([
                gps.parse(),
            ]))
Example #12
0
File: testDb.py Project: edzima/srv
#! /usr/bin/python
# __author__ = 'edzi'

import db
import GPS
import MPU6050
import time
import thread

#initial data to accelerometer

gps = GPS.GPS()
if gps.isConnected:
    dataBase = db.DataBase()
    gpsData = GPS.GPSData

    while True:

        gpsData = gps.readGPS()
        if gpsData:
            print gpsData.speed
            #dataBase.addGPS(( gpsData.longitude, gpsData.latitude,gpsData.altitude,gpsData.speed, 1))
Example #13
0
x_end1, y_end1 = 100., -20.0
'''
# Coords
start_coord = np.array([0., 0.])
end_coord = np.array([30., 0.])

start_coord1 = np.array([0, 0])
end_coord1 = np.array([30., 10])

start_coord2 = np.array([0, 0])
end_coord2 = np.array([30., 0])


steer = Steering(start_coord, end_coord)    # Create object
data = data_processing.Data()
GPS = GPS.GPS()
data.open_list("wheel_odometry.txt")

steer.motor.stop_motors()
# Set initial steering angle and calculate servo value





'''

    THIS LOOP IS ONLY FOR ONE COORDINATE, NOT FOR MULTIPLE

'''
Example #14
0
    def GPSThread(self):
        self.Last_Val_SOG = 0
        """
      This is where we handle the GPS Communication.
      """
        Log.WriteLine("Première exécution du thread GPS Communication")

        # Initialisation du GPS
        if SIMUL == False: MyGPS = GPS.GPS()

        while self.running:
            # Acquisitiion des données GPS
            if SIMUL == False:
                MyGPS.Communicate()
                Val_SOG = float(MyGPS.GPRMC['SOG'])
                Val_COG = float(MyGPS.GPRMC['COG'])
            else:
                Val_SOG = round(rand.random() * 16,
                                2) - 1  # Valeur de -01.00 à 14.99
                Val_COG = round(rand.random() * 360,
                                2)  # Valeur de 0.00 à 360.00
                Val_PRS = round(rand.random() * 80,
                                1) + 973  # Valeur de 973.0 à 1052.9
                Val_LAT = "51" + "°".decode('cp1252') + "01'03.7''N"
                Val_LON = "02" + "°".decode('cp1252') + "05'22.4''E"

            # Moyenne du SOG
#          Pile_SOG.pop(0)
#          Pile_SOG.append(Val_SOG)
#          Somme = 0
#          for i in range(len(Pile_SOG)):
#             Somme = Somme + Pile_SOG[i]
#          Val_SGA = Somme/len(Pile_SOG)

# Tendance du SOG
#          Val_SGG = int((Val_SOG - self.Last_Val_SOG)*100/1)
#          if Val_SGG > 100: Val_SGG = 100
#          if Val_SGG < -100: Val_SGG = -100
#          self.Last_Val_SOG = Val_SGG

# Tendance de la moyenne du SOG
#          Val_SAG = int((Val_SOG - Val_SGA)*100/1)
#          if Val_SAG > 100: Val_SAG = 100
#          if Val_SAG < -100: Val_SAG = -100

# Moyenne du COG
#          Pile_COG.pop(0)
#          Pile_COG.append(Val_COG)
#          Somme = 0
#          for i in range(len(Pile_COG)):
#             Somme = Somme + Pile_COG[i]
#          Val_CGA = Somme/len(Pile_COG)

            if SIMUL == False:
                compass = HMC5883L.hmc5883l(gauss=4.7, declination=(0, 12))
                Val_BRG = compass.degrees(compass.heading())
            else:
                Val_BRG = int(rand.random() * 360)  # Valeur de 0 à 360

            Pile_BRG.pop(0)
            Pile_BRG.append(Val_BRG)
            Somme = 0
            for i in range(len(Pile_BRG)):
                Somme = Somme + Pile_BRG[i]
            Val_BGA = Somme / len(Pile_BRG)

            # Ressources envoyées au thread GUI
            self.queue.put("SOG" + ";" +
                           str(round(Val_SOG, 2)))  # Speed Over Ground
            self.queue.put("COG" + ";" +
                           str(round(Val_COG, 2)))  # Course Over Ground

            self.queue.put(
                "BRG" + ";" + str(Val_BRG) +
                "°".decode('cp1252'))  # Bearing, Cap compas HMC5883L
            self.queue.put("BGA" + ";" + str(Val_BGA) +
                           "°".decode('cp1252'))  # Bearing Average
            self.queue.put("PRS" + ";" + str(round(Val_PRS, 1)))  # Pressure
            self.queue.put("LAT" + ";" + Val_LAT)  # Latitude
            self.queue.put("LON" + ";" + Val_LON)  # Longitude

            #self.queue.put("TMR" + ";" + time.strftime("%H:%M",time.localtime()))
            #self.queue.put("TTL" + ";" + "12:34")
            #self.queue.put("BSP" + ";" + str(round(rand.random(),2)))
            #self.queue.put("VMC" + ";" + str(round(rand.random(),2)))

            #self.queue.put("TTG" + ";" + "11:11")

            # On laisse du temps pour l'exécution des autres threads
            time.sleep(0.500)
Example #15
0
gm862 = GM862.GM862()

intialised = gm862.InitialiseSerial()
#gm862.SendCommand("ATZ")

if (intialised):
    print("Module initialised: " + str(gm862.State_Initialized))

    gsm = GSM.GSM(gm862)
    gsm.InitialiseGSM()
    """
    if(gm862.State_Registered):
        gsm.SendTextToPhone("0xxxxxxxxxx", "Registered on network")
    """
    gps = GPS.GPS(gm862)
    gps.InitialiseGPS()
    print("GPS power: " + str(gps.IsGpsOn()))
    print("GPS antenna voltage: " + str(gps.GetAntennaVoltage()))
    print("GPS antenna current: " + str(gps.GetAntennaCurrent()))

    for i in range(0, 10):
        "get GPS GGA sentence"
        gps.GetGpsData()
        sleep(2)
else:
    print("Falied to initialise")

#@TODO: need to do something to read incomming text messages if required
#AT+CMGR=<index> gets the sms. need to log index from unsolicited message
"""
        dataArray[19] = accelData['x'] - h3_x_offset
        dataArray[20] = accelData['y'] - h3_y_offset
        dataArray[21] = accelData['z'] - h3_z_offset

        # except:
        dataArray[19] = 0
        dataArray[20] = 0
        dataArray[21] = 0

    return dataArray

print("\n~~~~~~~~~~~INITIALIZING SUB-SYSTEMS~~~~~~~~~~~\n")
filehandle.write("\n~~~~~~~~~~~INITIALIZING SUB-SYSTEMS~~~~~~~~~~~\n")

try:
    GPS1 = GPS.GPS()
except:
    print("COULD NOT CONNECT TO GPS")
    filehandle.write('COULD NOT CONNECT TO GPS\n')
    Initialization_Error = True

try:
    ADC1 = ADS1x15.ADS1115()
except:
    print("COULD NOT CONNECT TO ADC")
    filehandle.write('COULD NOT CONNECT TO ADC\n')
    Initialization_Error = True

try:
    BARO1 = mpl3115a2.Barometer()
except:
Example #17
0
 def __init__(self, origen, destino):
     self.origen = origen
     self.destino = destino
     self.gps = GPS()