I'm write one code to my rasp+neo6m gps. I wanna get gps lat and long and compare with others points of lat and long. Is like this, when the car cross some point off lat and long one audio saying he was passed for the specified point. My code was like this:
The problem was when i cross the point with car, do not play the audio.
Code: Select all
from gps3 import agps3 import sys import os import pygame.mixer import pygame, time import json import math pygame.mixer.init(44100) gps_socket = agps3.GPSDSocket() data_stream = agps3.DataStream() gps_socket.connect() gps_socket.watch() lat1 = -12.924511667 lon1 = -38.465796667 lat2 = -12.962735 lon2 = -38.46010 for new_data in gps_socket: if new_data: data_stream.unpack(new_data) print("Longitude =" , data_stream.lon) print("Latitude =" , data_stream.lat) if "lat1" < "Latitude" < "lat2"" lon1" < "Longitude" < "lon2": music = pygame.mixer.music music.load('/home/pi/Documents/beep.mp3') music.play() print('Aloalo!') while pygame.mixer.music.get_busy(): time.sleep(1)