[Documentation] [TitleIndex] [WordIndex

(!) Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

Getting Started with gpsd_client (C++)

Description: Detailed tutorial for running gpsd_client in ROS

Tutorial Level: BEGINNER

Next Tutorial: Writing a Subscriber for gpsd_client (C++)

Hardware Requirements

This tutorial has been tested with the following devices:

* Garmin 18-18x, 1-5hz LVC (serial connection)

Installation

Start by installing the gpsd package.

$ sudo apt-get install gpsd

Now, in order to install the gpsd_client for ROS you should install the revision control tool git,

$ sudo apt-get install git-core

To install the stack containing gpsd_client we suggest the path given by /opt/ros/boxturtle/stacks, but this is left to the preferences of the user. Once you are located in your chosen folder type,

$ sudo git clone git://ram.umd.edu/ros/gps_umd.git

It will download all the stack to the designated folder. Once this is done move to the directory where the gpsd_client package is located,

$ roscd gpsd_client

If for some reason this does not work, move to the gpsd_client folder through the following path:

/[your_chosen folder]/umd-ros-pkg/gps_umd/gpsd_client

and proceed to compile the package

$ sudo rosmake --rosdep-install

Now, the gpsd_client node should be ready to use. If you get some error messages while compiling the package be sure that the dependencies were compiled before, specially the gps_common package.

Optional Packages

As an option we can install the gpsd-clients and python-gps packages which provide tools (e.g. gpscat, cgps, xgps) to test the communication with the GPS through the serial port as explained in the optional section 1.4.

$ sudo apt-get install gpsd-clients python-gps

Physical Connections

Be sure that your Garmin 18-18x GPS is correctly attached to a serial port and powered on.

Optional: Testing the GPS with gpscat

If you want to check the actual data transmitted by the GPS you can use gpscat.

$ gpscat -s [baudrate] [serial_port]

The baud rate changes depending on the GPS model you are using, so we suggest to try different values (e.g. 1200, 4800, 9600, 19200).

Using a Garmin 18 (5 hz) GPS we should receive NMEA data typing the following command,

$ gpscat -s 19200 /dev/ttyS1

The NMEA messages should appear on the terminal as follows,

$GPRMC,002454,A,3553.5295,N,13938.6570,E,0.0,43.1,180700,7.1,W,A*3F
$GPRMB,A,,,,,,,,,,,,A,A*0B
$GPGGA,002454,3553.5295,N,13938.6570,E,1,05,2.2,18.3,M,39.0,M,,*7F
$GPGSA,A,3,01,04,07,16,20,,,,,,,,3.6,2.2,2.7*35
$GPGSV,3,1,09,01,38,103,37,02,23,215,00,04,38,297,37,05,00,328,00*70
$GPGSV,3,2,09,07,77,299,47,11,07,087,00,16,74,041,47,20,38,044,43*73
$GPGSV,3,3,09,24,12,282,00*4D
$GPGLL,3553.5295,N,13938.6570,E,002454,A,A*4F
$GPBOD,,T,,M,,*47
$PGRME,8.6,M,9.6,M,12.9,M*15
$PGRMZ,51,f*30
$HCHDG,101.1,,,7.1,W*3C
$GPRTE,1,1,c,*37
$GPRMC,002456,A,3553.5295,N,13938.6570,E,0.0,43.1,180700,7.1,W,A*3D

You should receive NMEA data from the GPS even if it has not got any signal from the satellites.

Using gpsd_client for ROS

As mentioned at the gpsd_client web site, the gpsd daemon should be running before the gpsd_client node is running. To run the gpsd daemon type,

$ gpsd -S [TCP_port] [serial_port]

The default TCP port is 2947.

In this tutorial we will use the TCP port 4000 and the serial port /dev/ttyS1 as before.

$ gpsd -S 4000 /dev/ttyS1

We can check that the data from the GPS is now going through the TCP port 4000 by typing

$ telnet localhost 4000

Afterwards press any key and you should start visualizing NMEA data on the screen.

Now, we are ready to run the MASTER node,

$ roscore

and the gpsd_client node,

$ rosrun gpsd_client gpsd_client _host:=localhost _port:=4000

Testing the Node

Now, we are ready to test the node

$ rostopic echo /fix

We should be able to see the actual ROS messages from the GPS on the terminal.


2019-11-30 12:43