nsweeting
Posts: 10
Joined: Sun Dec 23, 2012 3:56 pm

Pi Navigation Station

Tue Feb 11, 2014 5:03 pm

Hi there,

I'm putting this code out there in hopes that someone else can make use of it, continue it, etc. Being in school right now means I simply don't have time to keep it up - for the time being at least. I haven't done much with it for a while... and I hope my last git commit was a working version.

Anyways - being involved with the boat world, this was my attempt at a low power navigation platform. Anybody interested in GPS systems would find it useful though. It basically takes GPS data and visualizes it using Pygame. It is a work in progress, but it does do a number of things already. My overall hope was to implement a basic mapping system which included AIS (Automatic Identification System) - mapping the location of other boats within your area, and giving info about them. I also wanted to implement full NMEA sentence reading - giving info for engine data, etc. A lot more work is needed to reach that, but the backbone structure in this program is ready to get to that level.

I would love to see someone involved with boats take on the AIS implementation. There are a number of python AIS projects that could be used - https://github.com/nsweeting/ais-logger being one of them.

It is fairly well commented, so it should be somewhat easy to understand. I'd be willing to help anyone that needs it though.

Make sure to check the config file to setup any differences in your system. And get required files - Pygame, Pyserial - listed on about page.

Project page: https://github.com/nsweeting/navstat

Cheers

User avatar
CopterRichie
Posts: 131
Joined: Tue Mar 26, 2013 3:14 am
Location: Los Angeles CA.

Re: Pi Navigation Station

Fri Feb 14, 2014 5:25 pm

Question please, will navstat play well with gpsd?

Reason for my question, considering the Pi uses ntp when connected to the internet, I am using gpsd to set the time when the Pi is not connected to the internet. I have not tried to run the NAVSTAT.py yet but have looked at the code and it appears, it access the gps unit directly.

nsweeting
Posts: 10
Joined: Sun Dec 23, 2012 3:56 pm

Re: Pi Navigation Station

Fri Feb 14, 2014 6:29 pm

Originally I was using GPSd to access the GPS data, but decided to remove its use as I wanted to try and access the data directly. So short answer is no. I had a separate script running that would boot on launch to set the RPi system time and date to the outputted GPS time and date directly through the serial connection. Unfortunately, I don't have access to the script right now. But will post it when I do.

For this reason, the navstat program actually displayed the RPi system date and time (as it was already correct) instead of the GPS date. I actually think this should be fixed. The time and date should always be accessed from the GPS UTC data provided. It would't be hard to fix, as navstat already provides it. Everything else - for example, tracking GPX files use the GPS UTC.

The UTC is easy to access within navstat - it is already corrected to be in proper format as well.

The date/time format outputted by the gps is in:
$GPRMC,225446,A,4916.45,N,12311.12,W,000.5,054.7,191194,020.3,E*68
225446 = Time
191194 = Date

Navstat will take the gps format and correct it to be proper UTC format:
1994-11-19T22:54:46Z

It is held within lib/nmea.py - line 33
self.data_gps['utc']

You would have to extract the date and time from the above UTC format and change the date using:
something like... (I havent had a chance to try..may not work) (EDIT: in fact it wont. Sorry - was grabbing data from different sources.

Code: Select all

import sys
import nmea

#Location, baud rate, timeout
nmea = NMEA0183('/dev/ttyUSB0', 4800, 5)
nmea.read()
gpstime = nmea.data_gps['utc']

#"19 NOV 1994 22:54:46"  ---- this is the format to use
gpstime = #1994-11-19T22:54:46Z ---- UTC format to de-construct. You would also have to correct for your time offset.

os.system('sudo date -u --set="%s"' % gpstime)
You may need some error handling for the connection. Data doesn't come right away sometimes...depending on the GPS unit. Check out the 'connect' function in NAVSTAT.py for details.
Last edited by nsweeting on Fri Feb 14, 2014 7:48 pm, edited 2 times in total.

nsweeting
Posts: 10
Joined: Sun Dec 23, 2012 3:56 pm

Re: Pi Navigation Station

Fri Feb 14, 2014 7:31 pm

It would be good to find some time for this again. I would like to see future development move towards the NMEA data being displayed through a web application instead of Pygame. Unfortunately, I have no working knowledge of this realm. Not a good start...but something to learn I guess

The code from this project would need to be shuffled around a bit, but I'm envisioning the backbone of NAVSTAT being used to gather serial NMEA data into an SQL database. The RPi would be run as a WAP - with NAVSTAT backend as well as a webserver going. It could then provide access to the data with a web application through a tablet or whatever.

There are NMEA multiplexers out there - like http://www.actisense.com/products/nmea-0183/ndc4.html
that would take multiple NMEA connections and turn them into one usb connection that could be used for the RPi.

With this you could feasibly have a full and fairly competent NMEA data visualizer through a tablet interface. There's a multitude of tools that could be accessed through this - gps, weather stations, engine monitors, transducers, AIS systems, etc... All accessed through constantly updated SQL database.

As mentioned before - my major realm is boats, with programming as a hobby. A lot of work involved in this. More than I could do alone.

Feel free to contact me if interested.

infinet
Posts: 1
Joined: Sat May 10, 2014 8:50 am

Re: Pi Navigation Station

Sat May 10, 2014 11:31 am

I have done a similar project for navigation. It uses pygtk to draw the gui, gpsd for positioning, it could also export images that can be served by webserver.

The vector shoreline it used is from NOAA. The performance is acceptable on a typical desktop, but very slow on raspberry pi. I guess it has something to do with the double precision math in python.

https://github.com/infinet/gpsd-navigator

Return to “Other projects”