Getting Lat, lng from GPS at the occurrance of an event

Home Forums Forums General discussion Getting Lat, lng from GPS at the occurrance of an event

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #17375
    gius22
    Participant

    Hi, I am new here and in programming.

    I have a RPI zero connected to a beitan bn220 gps moodule on /dev/serial0,  with Rsapberry pi OS (32bit), Bullseye, gpsd installed.

    My question is not related to a specific gps module.

    I would like to get Lat and Lng at a specific moment when an event occurs, e.g. "pushing " a button and then write these waypoint Lat and Lng on a file. I can manage the "switch" part.

    I would need help for this (in pseudo code):

    if an event occurs

    get Lat, Lng from nmea string; #this is the important part

    write data on a file;

    I read your  guide:

    Using python with a GPS receiver on a Raspberry Pi

    I am trying to modifying the code in "Manually parsing NMEA sentences" (almost the same as in "Using  pynmea2 to parse NMEA sentences")  accordingly as for my purpose. The important part:

     

    ser = serial.Serial(port, baudrate = 9600, timeout = 0.5) #my gps module baudrate is 9600; what means "timeout = 0.5"? Does it stop  the data stream for 0.5 s?

    while True: # I suppose here I have to put the occurrance of an event

    data = ser.readline()
    parseGPS(data)

    And in  def parseGPS(data) do I have to change the print part with "write to a file"?

    Sorry for such a long question.

    Thank you for any help,

    Giuseppe

    #17645
    djmaxwell
    Participant

    First, the timeout value is how long your read will block waiting for the data.

    Moving on to the other part of your question, the GGA messages come at a fixed rate from the GPS.  This defaults to 1Hz, but many modules allow you to increase that. You want to be continually reading the data and potentially storing at least some amount of history.

    If you are wanting to get the position at a specific time, you have a few options, depending on your velocity and accuracy needs.

    1) The simplest approach would be to take the most recent GPS position as the requested position

    2) Dead reckon to the requested time. This would use your data history to calculate where you will be at the requested time.

    3) Wait for the next position message and interpolate between the two positions to the requested time.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Blip, blop, bloop...