Navit is an open source navigation system with GPS tracking.
It works great with a Raspberry Pi, a GPS module and a small TFT with touch, jut like the official Raspberry Pi Display or PiScreen.
In this guide, we will be using;
- A Raspberry PI 3
- The official Raspberry Pi Display
- BerryGPS-IMU
- SmartPi Touch
Setting up the GPS
Navit can be installed without a GPS connected to your Raspberry Pi, but you will not be able to use the real-time turn by turn navigation. You will however be able to browse maps. If you are not going to use a GPS, you can skip to the next step.
As we are using the BerryGPS-IMU, we will be following the guide in the link below. As most GPS modules use serial to communication, this guide can be followed for other GPS modules.
BerryGPS Setup Guide for the Raspberry Pi
The images below shows how we have connected the BerryGPS-IMU to the Raspberry Pi 3 whilst it is in the SmartPi Touch case.
If you plan on testing this out in your car, you need to be mindfully of where you place your BerryGPS. In my setup and I have placed it in the air vent as shown below, and BerryGPS gets a good strong signal.
If you are using an external antenna, then there is no need to worry about where your BerryGPS is placed.
Navit
Apply any updates;
pi@raspberrypi ~/ $ sudo apt-get upgrade
Install Navit;
We will copy the default Navit config folder under the home directory.
pi@raspberrypi ~/navit-build $ cp /etc/navit/navit.xml .navit/navit.xml
You can now run Navit;
If there is no GPS signal, Navit will default to Munich as shown below. If you have a GPS signal, you will most likely have a blank screen as Navit has moved to the coordinates from your GPS and there is no map install for that location (yet).
Download Maps
Navit can use Garmin or OpenStreetMaps(OSM). In this guide we are using OSM.
Go to http://maps9.navit-project.org/ and download your map.
The file will be named something silimiar to this; osm_bbox_151.1,-33.9,151.3,-33.7.bin
We will rename it so it is easier to read. And place it under /home/pi/maps
pi@raspberrypi ~/ $ mkdir ~/maps
pi@raspberrypi ~/ $ mv sydney.bin maps/
The Navit config file needs to be edited to include the new map. While we are there we will also disable the sample map that came with the source.
To disable the sample map, look for;
<!-- If you dont want to use the sample map, either set enabled="no" in the next line or remove the xml file from the maps directory --> <mapset enabled="yes"> <xi:include href="$NAVIT_SHAREDIR/maps/*.xml"/> </mapset>
And changed enabled to "no"
<!-- If you dont want to use the sample map, either set enabled="no" in the next line or remove the xml file from the maps directory --> <mapset enabled="no"> <xi:include href="$NAVIT_SHAREDIR/maps/*.xml"/> </mapset>
To enable the map which was just downloaded, look for;
<!-- Mapset template for openstreetmaps --> <mapset enabled="no"> <map type="binfile" enabled="yes" data="/media/mmc2/MapsNavit/osm_europe.bin"/> </mapset>
And set it to enabled and specify the location of the bin file which was just downloaded. And set enabled to yes.
<!-- Mapset template for openstreetmaps --> <mapset enabled="yes"> <map type="binfile" enabled="yes" data="/home/pi/maps/sydney.bin"/> </mapset>
Enable Speech
Navit can also read out the directions when navigating.
Look for;
<speech type="cmdline" data="echo 'Fix the speech tag in navit.xml to let navit say:' '%s'" cps="15"/>
and change it to;
<speech type="cmdline" data="espeak '%s'" cps="15"/>
Change Locale
The default locale is set to United Kingdom/English. Which means that the default country when searching for an address will be United Kingdom.
If you are not in the United Kingdom, then it is best to change this.
In navit.xml, look for
<config xmlns:xi="http://www.w3.org/2001/XInclude">
And change it to your specific locale;
<config xmlns:xi="http://www.w3.org/2001/XInclude" language="en_AU">
As I am in Australia, I have set it to en_AU. Now when I search for an address the default country is Australia.
Some other examples are;
language="en_US"
language="fr_FR",
language="de_FR",
language="pl_PL"
Open Full Screen
To force Navit to open in full screen, look for;
<gui type="internal" enabled="yes"><![CDATA[
and change it to
<gui type="internal" enabled="yes" fullscreen="1"><![CDATA[
Follow Vehicle
When using Navit in navigation mode, we want the screen to update as the vehicle moves. By default, the screen will only update once the vehicle reaches the edge of the screen.
<vehicle name="Local GPS" profilename="car" enabled="yes" active="1" source="gpsd://localhost" gpsd_query="w+xj">
and change it to
<vehicle name="Local GPS" profilename="car" enabled="yes" active="1" source="gpsd://localhost" gpsd_query="w+xj" follow="2">
A value of 2 would refresh the screen every two seconds.
Customise Navit
With the default config file, Navit is hard to use with a touchscreen, an example of this is in the screenshot with Munich above.
One of the good features of Navit is that it almost everything is configurable.
We want to add some buttons and some routing information like next instruction, distance, speed, etc.. And hopefully it will look like the below screenshot
The config for Navit is found in ~/.navit/navit.xml
We will edit this file so that the display looks as shown above. You will also need to download the customs icons.
Download the configs needed for navit.xml
If you are using the Raspberry Pi official display, download this config file or use wget;
If you are using a 3.5" TFT, like PiScreen or PiTFT, download this config file or use wget;
Then download the icons;
Extract the icons from the zip file into the directory where Navit stores icon images;
No we will added the config from the downloaded text file to the Navit config file.
Open the config file;
Insert the new config in just before the lines below;
<!-- for a debug log --> <log enabled="no" type="textfile_debug" data="debug_%Y%m%d-%i.txt" flush_size="1000" flush_time="30"/>
The next time you start Navit, it should look as shown in the above screenshot.
Other Useful Navit Modifications
Width & Height
To specify the width and height of the Navit window, look for this
<graphics type="gtk_drawing_area"/>
And change it to something like this;
<graphics type="gtk_drawing_area" w="600" h="400"/>
Disable Points of Interest
To permanently disable points of interest, look for;
<layer name="POI Symbols">
And disable it as shown;
<layer name="POI Symbols" enabled="no">
Couple ?'s. First thanks for the write-up ! Great info. I have the same setup only with a GPS dongle. Everything seems to work except how do I center the map on the GPS fix ? I have Lat. and Long. in but it's a little off. Also change the speed to MPH for US. Haven't got the map to follow the vehicle either. Did add follow ="2". Any ideas ?? Thanks !
Adding
follow = 2
in thevehicle
tag should work. this tells Navit to update the screen every 2 seconds.To change to mph, in the Navit tag, enter
imperial="1"
Hey, im not sure how to activate the new buttons. I just need to open the .txt und copy this stuff into the two lines you wrote?
Thx a lot for your guide
download my txt file and copy the contents into navit.xml on your Pi
Thanks for the blog post. Have got it working on the Raspberry Pi.
Is there any way to trace out your route on Navit? In other words to show where you have been?
Thanks,
Tom
This write-up saved me hours of work. Thank you very much.
I changed the speed to mph, but the altitude seems to still be in meters. Anyway to set that?
Great project. Can the current time be displayed on the map as an icon?
Looks straight forward. I have just ordered a BerryGPS-IMU board and antenna from Amazon, for my Raspberry Pi 3. I looked at your Pi setup guide but I don't see where you specify the GIPO pin connections but in this guide I see there are 3 used. Can you clarify this please.
The BerryGPS-IMU can sit directly onto of the Raspberry Pi. However, in this guide this wouldn't have worked as the Raspberry Pi is mounted behind the TFT and the GPS module wouldn't have had access to the sky. So it was just connected by 3 jumper cables, 3.3v, GND and RXD .
Questions about navigation. When I enter a town that I want to set as the destination. It is giving me locations that are not on the map I downloaded. Any suggestions as to how to correct this?
how do you recommended getting navit to launch the GUI at startup?
Hi Guys,
Did anyone try Navit on Raspbian stretch? i did follow the above mentioned steps and get the map loaded, but i dont see any buttons to Zoom in and out or the speed. i just get the map loaded. on checking i get many errors in the terminal. can any help me to fix the issue.
Thanks in advance!!
I enabled the zoom buttons in ~/.navit/navit.xml as follows -- the zoom buttons then appear when next starting navit:
This worked on my pi.
Hi ibi, how did you get the zoom buttons enabled, please
I've got Navit working on my raspberry pi, with a gps giving the correct position, but cannot see how to put zoom buttons on the map!
I've downloaded the maps bin file, renamed and moved it to /etc/navit/maps.bin.
I've also enabled to use openstreetmaps and edited the location to the bin file but when I run "navit" i get a blank yellow screen with no map. I DO NOT have a GPS antenna installed yet.
Mu assumption is that it is still opening up to Munich (default) location, and Munich is no longer the current map.
Have you tried to search a location in the map you downloaded?
Did you ever get that working? I had the same issue where navit just displayed a yellow empty screen upon launch, It however had loaded the map but was zoomed in at a different lat/long, I zoomed out all the way and noticed some text at a different location, manually centered around that and slowly zoomed in, and voila the map finally appeared.
You can edit navit.xml and enter the location you want the map to open up to
https://wiki.navit-project.org/index.php/Basic_configuration
"On Navit's very first startup, it needs a center to look at on the map. By default this is set to Munich in Germany (at latitude 48.08 and longditude, which is conveniently covered by the sample map created on installation."
center="4808 N 1134 E"
How do I enable SDL graphics on navit?
Excellent tutorial!
It would be great if this would be the default values.
There would be higher adoption of Navit!
Hi, thanks for the tutorial. it is very good. one question though. any ideas on how to enable a button to center the map on the current location?
Hey!
Thank you so much for this post!!
Just a small help. I need to track the 'TURNS' of the vehicle. Anyway I could get that, I mean any tags?
Thanks in advance, keep the good work!
Hello,
I am new at this.
I ran into an unusual situation running your procedure on a raspberry pi 4:
After the original install, due to a corrupted navit.xml file I attempted to remove the navit application and after numerous attempts ( install/uninstall) i found a copy of the navit.xml in a hidden directory (not visible in file manager but accessible from terminal). I was able to finally delete this phantom file and only after a reboot does it appear to be finally deleted. Any thoughts?
these hidden files are the config for Navit. if you like to customize the navit.xml, chose this one
Hello I follow the procedure but when run the navit it has these error
error:navit:xinclude:Unable to include /usr/share/navit/maps/*.xml
just disable this mapset ...
Still not working . Help me pls
Hi
Will the above work with a RPi zero?
Thanks
yes, it will work with any Pi