(!) 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)


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,


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.

Wiki: gpsd_client/Tutorials/Getting Started with gpsd_client (last edited 2011-03-14 02:29:07 by NicuStiurca)