User Tools

Site Tools


navitnavigation

Navigation with navit on RaspberryPi

This article describes, how to setup a Raspberry Pi with open source project navit as a navigation software. It could be setup in a car and if e.g. attached to a monitor with touch interface, it could be used as a navigation system with up-to-date maps from OpenStreetMap.

I've tested it and it works pretty cool, this is why I finally documented it here.

Prerequisites

This project requires the setup of an GPS-Module (e.g. from adafruit Ultimate GPS from adafruit), if this is done, the gpsd has to be up an running. The gpsd is the daemon which is connected by navit to get the current position.

Preparation

Before starting to implement it helps to get some packages preinstalled, which wil be used during the installation steps:

sudo apt-get update
sudo apt-get upgrade
 
sudo apt-get install gpsd gpsd-clients cmake subversion build-essential espeak freeglut3-dev imagemagick libdbus-1-dev libdbus-glib-1-dev libdevil-dev libfontconfig1-dev libfreetype6-dev libfribidi-dev libgarmin-dev libglc-dev libgps-dev libgtk2.0-dev libimlib2-dev libpq-dev libqt4-dev libqtwebkit-dev librsvg2-bin libsdl-image1.2-dev libspeechd-dev libxml2-dev ttf-liberation

Installation of navit

As the installation of the precompiled package (which is existing) is somehow too old, it's ok to just build it on your own on the Raspberry Pi. So if you are really lazy you just install the precompiled package (which is not recommended):

sudo apt-get install navit

But if you want to get an up-to-date version, you can easily build it on your own, by just grabbing a copy of the current version from the subversion repository (as also recommend by the team!) an compile it on your own:

pi@gpsraspberrypi ~ $ svn co https://navit.svn.sourceforge.net/svnroot/navit/trunk/navit/ navit_repository
pi@gpsraspberrypi ~ $ cd navit_repository
pi@gpsraspberrypi ~/navit_repository $ mkdir build
pi@gpsraspberrypi ~/navit_repository $ cd build
pi@gpsraspberrypi ~/navit_repository/build $ cmake ..
pi@gpsraspberrypi ~/navit_repository/build $ make

The “make” takes about 30 minutes on the Raspberry Pi an then you are done so far. Finally just copy the folder with the build-result to a destination of your choice, which can be found now in “~/navit_repository/build/navit”. I copied mine to pi's home, so mine can be accessed now by going to:

cd ~/navit

If you have a look in the final build result, the folder should look somehow like this one:

pi@gpsraspberrypi ~/navit $ ls -al --color=auto ~/navit
drwxr-xr-x 16 pi pi    4096 Aug 14 16:48 .
drwxr-xr-x 11 pi pi    4096 Aug 14 16:34 ..
drwxr-xr-x  3 pi pi    4096 Aug 14 12:14 binding
-rw-r--r--  1 pi pi      83 Aug 14 16:46 bookmark.txt
-rw-r--r--  1 pi pi    1723 Aug 14 12:14 builtin.c
drwxr-xr-x  8 pi pi    4096 Aug 14 12:15 CMakeFiles
-rw-r--r--  1 pi pi    4934 Aug 14 12:15 cmake_install.cmake
-rw-r--r--  1 pi pi      91 Aug 14 16:50 destination.txt
drwxr-xr-x  3 pi pi    4096 Aug 14 12:15 fib-1.1
drwxr-xr-x  3 pi pi    4096 Aug 14 12:14 font
drwxr-xr-x  7 pi pi    4096 Aug 14 12:14 graphics
drwxr-xr-x  5 pi pi    4096 Aug 14 12:14 gui
-rw-r--r--  1 pi pi 3178680 Aug 14 12:21 libnavit_core.a
-rw-r--r--  1 pi pi   55724 Aug 14 12:15 Makefile
drwxr-xr-x  9 pi pi    4096 Aug 14 12:14 map
drwxr-xr-x  3 pi pi    4096 Aug 14 16:32 maps
drwxr-xr-x  3 pi pi    4096 Aug 14 12:36 maptool
-rwxr-xr-x  1 pi pi 1568620 Aug 14 12:21 navit
-rw-r--r--  1 pi pi    5447 Aug 14 12:21 navit.dtd
-rw-r--r--  1 pi pi  298194 Aug 14 11:46 navit.xml
drwxr-xr-x  3 pi pi    4096 Aug 14 12:14 osd
drwxr-xr-x  5 pi pi    4096 Aug 14 12:14 speech
drwxr-xr-x  3 pi pi    4096 Aug 14 12:14 support
drwxr-xr-x  6 pi pi    4096 Aug 14 12:14 vehicle
-rw-r--r--  1 pi pi      53 Aug 14 12:15 version.h
drwxr-xr-x  3 pi pi   69632 Aug 14 12:44 xpm

Before starting the first time, a map of the current GPS region is needed, so that there is something to see at the current GPS-position.

Grabbing and installing a map

The big advantage here is, that maps from the open street map project can be taken. The part of the map can easily be chosen as required, which is really cool! That gives a high flexibility in regards of the size of the used SD-card and the region I'm interested in.

To grab a map, just use the offered navit service Navit Planet Extractor. Just mark a region and save the binary mapfile of the marked region on the RaspberryPi. In this example is a region chosen, covering the south of Danmark and the north of Germany (that's currently enough for me, but I could also choose the world, which has a size of 15GB today).

By clicking on “Get Map” a binary map of the section is downloaded. I renamed the file to osm_soutdk_sh.bin an put it on the Raspberry Pi in the navit folder “maps”. Size of my chosen map is 356MB, which is pretty small in size for such a big area with really(!) up-to-date map data right from yesterday!

pi@gpsraspberrypi ~ $ ls -alh --color=auto ~/navit/maps/
insgesamt 360M
drwxr-xr-x  3 pi pi 4,0K Aug 14 16:32 .
drwxr-xr-x 16 pi pi 4,0K Aug 14 17:42 ..
drwxr-xr-x  3 pi pi 4,0K Aug 14 12:15 CMakeFiles
-rw-r--r--  1 pi pi 1,2K Aug 14 12:15 cmake_install.cmake
-rw-r--r--  1 pi pi 6,8K Aug 14 12:15 Makefile
-rw-r--r--  1 pi pi 1,2M Aug 14 12:45 osm_bbox_11.3,47.9,11.7,48.2.bin
-rw-r--r--  1 pi pi 2,0M Aug 14 12:44 osm_bbox_11.3,47.9,11.7,48.2.osm.bz2
-rw-r--r--  1 pi pi   84 Aug 14 12:45 osm_bbox_11.3,47.9,11.7,48.2.xml
-rw-r--r--  1 pi pi 356M Aug 13 23:54 osm_soutdk_sh.bin

Finally some sections inside the navit.xml has to be updated, to point to the new map. Just edit the navit.xml by using an editor of your choice with the following changes. Find the section with “<map type=“binfile” […]” and modify to your needs:

 <!-- Mapset template for openstreetmaps -->
 <mapset enabled="yes">
 <map type="binfile" enabled="no" data="/media/mmc2/MapsNavit/osm_europe.bin"/>
 <map type="binfile" enabled="yes" data="/home/pi/navit/maps/osm_soutdk_sh.bin"/>
 </mapset>

Set all other mapsets to “no”, to ensure, that only the new OSM-map is loaded an used:

 <mapset enabled="no">
 [...]

That's it :-).

Run navit

If all former steps are done, navit could be started. There are two options, one is running on local X-session and another is by using the ssh connection from another linux (or system running an X-server).

Just connect the RaspberryPi with ssh by forwarding X (param -X) and skipping forwarding to X11 SECURITY extension controls (param -Y):

ssh -X -Y pi@192.168.0.123

Change into navit folder an run navit:

pi@gpsraspberrypi ~ $ cd navit
pi@gpsraspberrypi ~/navit $ ./navit 

An this is, how it might look:

You can zoom in an out. By left clicking, the menu raises:

By adding/activating some more OSD features in navit.xml and planning a route, the final screen might look like this one (german setup):

navitnavigation.txt · Last modified: 14.08.2014 18:57 by andreas