Description avNav

Navigation in the Browser

Raspberry Pi as on board computer

15.12.2020

Important Hint:

In no case I promise or can be held responsible for correct function of AvNav - especially using it for navigation is at your own risk. Before using it I recommend to carefully test the precision of the display and the used charts.

Motivation

After already navigating for some time with raster charts (first on Windows with Seaclear, later at Windows, WindowsCE and OSX with OpenCPN and OziExplorer) I was looking for options to extend this and make it better suite to my needs when being at sea.

My wish list was:

  • Navigation on small devices (laptops always are slightly too bulky) – 7 or 10 inch tablet would be perfect

  • Navigation also in the cockpit

  • Track storage

  • Connection to "on board" electronics - I own a VHF that provides AIS data

  • Usage of raster charts (BSB, NV, everything that can be downloaded using mobile atlas creator)

  • Minimized installation effort

  • Small, low power consumption (should be possible to run it all the time)

  • Not too much manual work - avoid soldering own circuits

At some point in time I noticed the raspberry pi and felt it could become a perfect device for my needs.

After some research (back in 2012...) I found that there was no ready to go solution that would perfectly fit my needs. Especially the handling of serial devices (typically USB-serial converters) is at least tricky most of the time on linux.

So I started this project. I try to provide some description here for people that would like to use it. The software is available at an open source license (MIT).



Overview

avnav-raspi-2020
The whole solution consists of different parts:

  • A Raspberry Pi with the server software (avnav_server.py), that is reading the connected devices (NMEA via serial-USB converter – like PL 2303), Bluetooth GPS, multiplexing and storing the data and providing them via WLAN

  • A variant of this software for the desktop (Windows/OSx/Linux) for converting and preparing the charts

The raspberry pi creates an access point and various devices can access its data:

  • There is some (other) navigation software running on the device (tested: InavX,OpenCPN), those access the NMEA data via TCP or UDP.

  • On the client devices there is only a browser. All the navigation is handled by the AvNav WebApp that is downloaded from the raspi. There is no need for any other installed software on the device, only a current HTML5 browser (tested: Chrome Windows, OSX, Safari, Android starting 4.4 – Chrome/Stock/Boat Browser, IOS, Blackberry stockBrowser, WebBrowser mini).

The server part is written in python and can be configured via an xml file. The normal set up is ready to go - i.e. there is no need for any configuration to get started. Beside the software itself there are images that you can download to get started - see installation.

The java script app provides all the basic navigation functions on raster charts (gemf,mbtiles) or OESenc vector charts  including AIS display, waypoint navigation, routes, tracks,... The charts being used by the web app must be installed on the raspberry.

OESenc charts can be bought in the o-charts shop.

If you have chart formats that cannot be handled directly in the app you have to convert them into gemf - using avnav at the desktop (or directly on the pi within the App). The converter can handle the following formats:

  • All chart sources that can be read by GDAL software (especially BSB)

  • Charts downloaded with Mobile Atlas Creator

Beside the described set up there is also an  Android-App that provides similar functions.The server part is implemented natively in Java, the display part is identical.

The following chapters describe the parts a bit more in detail.

The Server Software (avnav_server.py)

The pi holds a normal Debian image (app. 2GB). Afterwards a couple of additional packages will be installed together with AvNav.

The structure of the server software:

The server tries to detect all devices connected via USB-serial and via bluetooth-serial. You have to take care that your USB-serial device is correctly handled by the pi - like e.g. this one. The server scans connected devices (via dbus) and discoveres the device nodes. Afterwards it tries to do some auto-bauding (i.e. determine the baudrate for the device) between 4800 and 34000 baud and tries to receive NMEA data. If no data is detected it starts over again by closing and reopening the devices. This way it can cope with disconnecting and reconnecting devices. I have connected a AIS VHF that gets GPS data from the pi and sends AIS data to it. If bluetooth serial devices are detected it will also try to read from them.

You can also configure devices to output the data and this way have a NMEA multiplexer.

All NMEA data internally are stored in a queue and are provided to outputs. By default a TCP socket is open that you can connect to (default port: 34567).

Additionally you can configure more outputs (TCP,UDP,serial).

Internally the data (including AIS) is also provided towards a decoder that will store them in the server software ("NMEA decoded data"). Those data is provided via an HTTP json API for the app. Additionally the server writes track data, computes routing information, handles anchor watch and alarms.

For controlling an auto pilot the server computes RMB data and sends them to the internal queue so that it can be received by any connected device.

If there is a valid time information in the GPS data it sets the system time of the raspberry.

For automated start up there is a (systemd) service so you can control start and stop via systemctl.

Most of the server functions you can configure via an xml file (avnav_server.xml). In the installed template there are examples for a couple of use cases already being included. Additionally (if a bluetooth device has been detected) AvNav tries to connect to bluetooths serial devices and receive NMEA data from them.

Normally there is no need for additional configuration.

You can find the software on github for installation instructions see the installation description.

Software on the raspberry

On the  raspberry the following directories are used;

Directory

Content

/usr/lib/avnav software

/home/pi/avnav/data/

base data directory

.../data/charts

charts - see  converting charts.

.../dava/log

logfiles

.../data/tracks

trackfiles (gpx), one file per day, nmea logs

.../data/routes routes - xxx.gpx and the current segment (leg) currentLeg.json
.../data/import input directory for the converter
.../data/user/viewer location of user files (user.js, user.css,...)
.../data/user/images location for user image files
.../data/layout location if user layout files

Except the systemd scripts (and some command scripts) the software is running with the user pi (on the raspberry). You can also start the software from the command line using the command "avnav". On a desktop system you can run this as any user.

The Web App

The app is a single page app built with ReactJs.
It communicates with the server using HTTP. The app entry point is http://avnav.avnav.de/viewer/avnav_viewer.html. It is optimized for mobile devices - especially tablets starting at 7". But you can use it also on desktop systems or larger displays. Meaningful usage starts at around 900x540 pixel.

For a user documentation of the app refer to this description.