ADDING GPS TO YOUR ROBOT
Welcome to the FlowStone Workshop number 23, where we give a beginners guide to computer programming using the FlowStone graphical programming language. In this issue we are going to look at how to add GPS to your Robots
WHAT IS GPS
GPS stands for ‘Global Positioning System’ and is commonly found in car satnav systems to tell you where you are exactly on this planet called Earth. It works by triangulating very accurate timing signals from several satellites to give you a precise Latitude (Lat) and Longitude (Lon).
HOW CAN WE USE GPS
If you know your Latitude and Longitude you can plot where you are on a map, send your position to someone else so they can locate you, or navigate from your current position to a new position or way point. This is how many Quadcopter drones navigate or log there path and we can use this exact same system on our robots both on the ground and in the air.
THE HARDWARE
First of all you need a GPS receiver, and these come in various forms, most of them are a GPS Module with everything you need on a small board. There will be a GPS antenna, a small microprocessor and often a micro battery to reserve system data for rapid satellite acquisition. The cool thing is that most of these send out serial data using TTL RS232, some even convert the serial data into a virtual comport via USB so you can plug them directly into your laptop or mini PC. We will be using the GNSS GPS mouse WHAT IS GPS from Locosys LS23030-G that has the USB connector, although you can choose from several connectors with TTL if you prefer.




If you want to use a microprocessor to interface to your GPS receiver you can just use a serial port on the chip to read the serial data usually at a baud rate of 9600.
CONNECTING TO THE PC
If you have the USB version you can just plug it in to your PC and load the comport driver, if you have a TTL version then you will need a USB to TTL serial converter but ultimately it comes up as a Com port in FlowStone.
NMEA SENTENCES
NMEA is the ‘National Marine Electronics Association’ and are the organization that have defined the GPS ASCII protocol. This in our case is split into several sting types:
GGA – Global positioning system ? xed data
GLL – Geographic position – latitude/longitude
GSA – GNSS DOP and active satellites
GSV – GNSS satellites in view
RMC – Recommended minimum speci? c GPS data
VTG – Course over ground and ground speed
Each one of these being a piece OF text strings something like this:
“$GPGGA,183015.000,2503.7123,N,12138.7446, E,2,16,0.68,123.2,M,15.3,M,0000,0000*66”
By default the GPS receiver will spew all of these out presenting you with a huge amount of data. The standard GPS frequency is 1Hz (ie. you get the data once a second), but this can be increase up to 10Hz if required, also the baud rate can be changed via software to enable you to read the data at a higher rate.
For our example we will only concentrate on the RMC string which contains everything we need for our application in a minimum string. We can tell the GPS receiver to only send out this string which vastly simplifies things.
Here’s an example of the comport setup FlowStone:
FlowStone Comport Setup
Here’s an example of an RMC String: $GNRMC,183015.000,A,2503.7123,N,12138.744 6,E,0.01,34.92,270812,,,D*43

Generally we are only interested in the Longitude and Latitude, plus perhaps the speed over ground for our robots. So in FlowStone we can start by looking for a string starting with $GPRMC and then splitting the string up into a comma separated array.
This is how we extract the data from each element of the GPS string. There is another thing you will need to do and that is to decode the Latitude and Longitude from Degrees and Minutes into just Degrees. Since the first part of the Lat/Lon is already in Degrees we only need to convert the Minutes part.

Eg.
Latitude (ddmm.mmmm): 5308.6331 = 53.143885°
Longitude(dddmm.mmmm): 00132.8369 = 1.547282°
To do the conversion you need to divide the mm.mmmm part by 60
Eg. 5308.6331 where dd = 53, mm.mmmm = 08.6331 08.6331/60 = 0.143885 Add the ‘dd’ of 53 and you get : 53.143885°
Here’s the FlowStone finished project available to download from our FlowStone examples area via www.dsprobotics.com/ support/. This reads the GPS data in real time and displays it on the screen.
CONCLUSION
Adding GPS to your robots will help you navigate from where you are to where you want to be. Whilst at first glance it appears very complicated it is not that hard to extract the Latitude and Longitude data from the NMEA strings. You can also use this data to log where your robot has been and use the PC to draw a plot of the path taken or even draw it on Google maps etc.
Links
DSPRobotics, DSPRobotics.com
Locosys, www.locosystech.com