Setting up GNSS / RTK on Linux
Setting up GNSS / RTK on Linux
This guide will walk you through setting up your GNSS / RTK module on Linux, in order to use it with the ZED SDK’s Global Localization module.
While the guide focuses on the ublox ZED F9P GNSS module, the instructions provided should also be applicable to other GNSS modules. By leveraging the power of GNSS / RTK technology, you will be able to enhance the accuracy and reliability of your positioning data, opening up new possibilities for your ZED-based applications.
Installation
Using gpsd is the simplest way to retrieve the GNSS data on Linux.
To access GNSS data in a program, we are going to use gpsd, a service daemon that retrieves and parses GNSS data from multiple formats and provides multiple APIs to access this data easily.
gpsd is used to connect applications with the GPS receiver hardware. It manages USB GPS devices so the applications don’t have to. In Linux, if you set up the gpsd properly with GPS receivers hardware, most GNSS location-aware applications can get the GNSS data by calling gpsd. Furthermore, gpsd shares the GPS receiver to all applications running on this Linux machine.
It is required to install gpsd from source to get the most recent stable version:
In order to run without root privileges, it is recommended to add your user to the dialout and tty groups:
Log out of the session or reboot the device for these changes to take effect.
To verify that the GNSS module is properly detected, you can use the following command:
You should see a file named /dev/ttyACM0 or dev/ttyUSB0 containing the GNSS raw data. The streamed data should look as such:
Usage of GPSD
By default, gpsd uses a systemctl service to run, however as the service has reliability issues for USB GNSS modules, we recommend running the daemon by hand, and create a cron job to start the service at boot.
To run the daemon, use the following command:
The following cron job can be added with crontab -e :
Change ttyACM0 with the communication port of your GNSS sensor
You can test that gpsd is working properly with the xgps tool installed with gpsd:
Enabling RTK on your GNSS module
Enabling RTK (Real-Time Kinematic) functionality brings significant advantages over traditional GNSS positioning.
RTK uses a network of reference stations and a rover receiver to provide highly accurate and precise positioning in real-time. Unlike standard GNSS, which typically offers accuracy within a few meters, RTK can achieve centimeter-level accuracy. By leveraging carrier-phase measurements and advanced algorithms, RTK overcomes common limitations of GNSS, such as atmospheric disturbances and signal multipath.
Using NTRIP
gpsd can act as an NTRIP client in order to retrieve RTK corrections from an RTK base station.
We will go through how to set up the NTRIP connection in order to get RTK centimeter-level accuracy.
For this you will need:
- url: the NTRIP URL address of the base station
- port: the NTRIP port of the base station
- mountpoint: the mountpoint you choose to use (Note: for good performance, the base station is recommended to be less than 25km away from the rover)
- username: the username used for the NTRIP connection (optional)
- password: the password used for the NTRIP connection (optional)
You can now run gpsd as an NTRIP client with:
Change ttyACM0 with the communication port of your GNSS sensor
You can now run xgps and wait for the GNSS to get an RTK fix. (The ECEF pAcc gives the horizontal accuracy; with an RTK FIX status this value should be of about a few centimeters)
Set RTK configuration at boot
gpsd runs as a cronjob set to run at the system’s startup. Update the cron job with the following command, so that gpsd will connect to the base station at every boot:
And replace the gpsd line already present with the following:
Change ttyACM0 with the communication port of your GNSS sensor
Using GNSS in your applications
With the successful setup and configuration of GNSS, it’s time to explore how to leverage GNSS data in your ZED SDK application.
To help you get started, we provide Geotracking samples on our GitHub repository. These samples allow you to view live fused GNSS global data, record GNSS sequences, and even replay them for testing purposes.
Python
To access GNSS data in Python, you can use the gpsdclient library. This library provides a Python interface to the gpsd daemon, allowing you to easily retrieve GNSS data in your Python scripts. With gpsdclient, you can access a range of GNSS data, including latitude, longitude, altitude, speed, and more. This makes it a powerful tool for building GNSS-enabled applications in Python.
You can install gpsdclient with:
Here is an example of a simple script using gpsdclient:
You can find a full code example of how to use the library in our Geotracking samples on GitHub.
C++
To access GNSS data in C++, you can use the libgpsmm library.
You can install libgpsmm with:
Here is an example of a simple script using libgpsmm:
You can find a full code example of how to use the library in our Global Localization samples on GitHub.

