Reader small image

You're reading from  Mastering Beaglebone Robotics

Product typeBook
Published inDec 2014
Reading LevelBeginner
Publisher
ISBN-139781783988907
Edition1st Edition
Languages
Concepts
Right arrow
Author (1)
Richard Grimmett
Richard Grimmett
author image
Richard Grimmett

Richard Grimmett has more fun that should be allowed working on robotics projects while teaching Computer Science and Electrical Engineering at Brigham Young University Idaho. He has a Bachelors and Masters degree in Electrical Engineering and a PhD in Leadership Studies. He also has 26 years of experience in the Radar and Telecommunications industries, and even has one of the original brick phones. He has written books on the basics of using the BeagleBone Black for robotics projects, and another for the Raspberry PI and yet another for the Arduino.
Read more about Richard Grimmett

Right arrow

Chapter 7. Using GPS for Navigation

Your sailboat can sail, but you might want it to sail to a specific location. One of the coolest devices that you can connect to your robot is a GPS location device. It will allow your sailboat to know where it is, and then you can also know the bearing and distance to a new location.

In this chapter, you will be doing the following things:

  • Connecting the BeagleBone Black of your sailboat to a GPS device so that it can know where it is

  • Accessing the GPS programmatically so that you can use this position to determine the bearing and distance to a new location

Beginning with a GPS tutorial


Before you get started, let's start with a brief tutorial on GPS. GPS, which stands for Global Positioning System, is a system of satellites that transmits signals. GPS devices use these signals to calculate a position. There are a total of 24 satellites transmitting signals all around the earth at any given moment, but your device can only see the signal from a much smaller set of satellites.

Each of these satellites transmits a very accurate time signal that your device can receive and interpret. It receives the time signal from each of these satellites, and then based on the delay—the time it takes the signal to reach the device—it calculates the position of the receiver based on a procedure called triangulation. The following two diagrams illustrate how the device uses the delay differences from three satellites to calculate its position. The system can use more than three satellites, but for the sake of simplicity, let's look at how your device can use...

Connecting GPS to the BeagleBone Black


First, you'll need to obtain a GPS unit. There are many that are available, with different interfaces. Connecting a device that has a USB interface is very straightforward. When you plug the USB device into the BeagleBone Black, it will automatically try to recognize the new device and install the driver for it. The advantage of this approach is that it is very easy and you won't need to update any driver files. The problem with this approach is that you will need to add a powered USB hub.

Another possible choice that won't require an additional USB hub is a GPS that can connect to the RX/TX GPIO pins of the BeagleBone Black. The VPN1513 GPS Receiver w/ Antenna, marketed by Parallax and available on their online store, is an example of this choice. Here is an image of the device:

You should also purchase an antenna that can connect to the RF (gold) connector on the board. This is type SMA; these are available from electronic online retailers. Here is...

Parsing the GPS information


Your project will now have the GPS connected and also have access to querying the data via serial port. In this section, you will create a program to use this data to find where you are, and then you can determine what to do with that information.

If you have completed the last section, you should be able to receive the raw data from the GPS unit. Now you will be able to take this data and do something with it. For example, you can find your current latitude, longitude, and altitude, and then decide if your goal location is to the east or west, and to the north or south.

The first thing you'll need to do is parse the information out of the raw data. As noted previously, your position and speed are in the $GPMRC output of our GPS. First, you will write a program to simply parse out a couple of pieces of information from that data. Create a new file that looks like this screenshot:

Here are the details of the code shown in the preceding screenshot:

  • #!/usr/bin/python...

Calculating distance and bearing


Now that you have the data, you can do some interesting things with it. For your sailboat, you'll need to use your current location and a desired new location to give your sailboat a distance and a bearing.

Longitude from your GPS device is a measure of where you are on the earth with respect to east/west. Latitude is a measure of where you are with respect to north/south. These readings are normally given in degrees (considering the fact that the globe is round, so the readings start at 0 degrees and end at 360 degrees.) Since the earth is very large, the readings also include minutes and seconds, where a single degree is divided into 60 minutes and each minute is divided into 60 seconds.

In order to calculate distance and bearing, you're going to start with longitudinal and latitudinal positions on the earth's surface in the degrees.minutes.seconds format. You'll then translate these values into a digital degree format and use the haversine formula to calculate...

Summary


Now your sailboat has the ability to sail using the control of the rudder and the sail. It also has the ability to both know where it is, and calculate the distance and direction of a new waypoint. However, there is one additional capability that you'll need, that is, information about the wind so that you can actually sail your boat. You'll learn that in the next chapter, and you'll have a complete sailing robot.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Mastering Beaglebone Robotics
Published in: Dec 2014Publisher: ISBN-13: 9781783988907
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Richard Grimmett

Richard Grimmett has more fun that should be allowed working on robotics projects while teaching Computer Science and Electrical Engineering at Brigham Young University Idaho. He has a Bachelors and Masters degree in Electrical Engineering and a PhD in Leadership Studies. He also has 26 years of experience in the Radar and Telecommunications industries, and even has one of the original brick phones. He has written books on the basics of using the BeagleBone Black for robotics projects, and another for the Raspberry PI and yet another for the Arduino.
Read more about Richard Grimmett