Navigating with Navit on the Raspberry Pi

Navit Raspberry Pi

Navigating with Navit on the Raspberry Pi

navit running on a Raspberry Pi

 

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 Displayor PiScreen.

 

In this guide, we will be using;

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.


Raspberry Pi Navit GPS

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.

Raspberry Pi GPS

If you are using an external antenna, then there is no need to worry about where your BerryGPS is placed.

navit-gif

Navit

Apply any updates;

pi@raspberrypi ~/ $ sudo apt-get update
pi@raspberrypi ~/ $ sudo apt-get upgrade

Install Navit;

pi@raspberrypi ~/ $ sudo apt-get install navit espeak

We will copy the default Navit config folder under the home directory.

pi@raspberrypi ~/navit-build $ mkdir ~/.navit
pi@raspberrypi ~/navit-build $ cp /etc/navit/navit.xml  .navit/navit.xml

You can now run Navit;

pi@raspberrypi ~/navit-build $ 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).Navit Map

 

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 ~/ $ mv osm_bbox_151.1,-33.9,151.3,-33.7.bin sydney.bin
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.

pi@raspberrypi ~/ $ nano ~/.navit/navit.xml

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>

BerryGPS Raspberry Pi GPS

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

navit0

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;

pi@raspberrypi ~/ $ wget ozzmaker.com/downloads/navit-OSD-800-480.txt

If you are using a 3.5″ TFT, like PiScreen or PiTFT, download this config file or use wget;

pi@raspberrypi ~/ $ wget ozzmaker.com/downloads/navit-OSD-480-320.txt

Then download the icons;

pi@raspberrypi ~/ $ wget ozzmaker.com/downloads/navit_icons.zip

Extract the icons from the zip file into the directory where Navit stores icon images;

pi@raspberrypi ~/ $ sudo unzip navit_icons.zip -d /usr/share/navit/icons/

No we will added the config from the downloaded text file to the Navit config file.
Open the config file;

pi@raspberrypi ~/ $ nano ~/.navit/navit.xml

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">
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值