GPS Waypoint Navigation with E-Maxx Truck

Motivation

This tutorial explains how to convert a Traxxas E-Maxx truck into a GPS navigable ground vehicle. This tutorial assumes the reader:

Parts List and Sources

To complete this tutorial, you'll need the following items:

PART DESCRIPTIONVENDORPARTPRICE (2006)QTYTOTAL
Traxxas E-Maxx TruckTower HobbiesLXVS28**$3291$329
GPS ReceiverGarmin eTrex Vista$2461$246
GPS Data CableGarmin010-10205-00$22.851$22.85
Basic Stamp ModuleDigi-KeyBS2P24-ND$79.001$79.00
Basic Stamp Demo BoardDigi-Key45183-ND$89.001$89.00
Single Row Pin HeadersDigikey S1251E-36-ND$3.851$3.85
Servo ControllerScott Edwards ElectronicsMini SSC II$44.001$44.00

Interpreting the GPS Data

The National Marine Electronics Association (NMEA, pronounced Nee-muh) has developed a standard for all GPS devices. For this tutorial, we will be using two NMEA data strings. The $GPRMC data string, or the Recommended Minimum Specific GPS/TRANSIT Data, contains 12 pieces of information separated by commas within the string:

  1. Time Stamp
  2. Validity: A for OK, V for invalid
  3. Current Latitude
  4. North or South
  5. Current Longitude
  6. East or West
  7. Speed (in knots)
  8. True Course (in degrees)
  9. Date Stamp
  10. Variation
  11. East or West
  12. Checksum

For this tutorial, we will be concerned with the true course (8) which is the current heading of the ground vehicle (in degrees) and is measured clockwise from the North direction. If your truck is heading East, for example, then the true course would be equal to 90 degrees. This single value saves an enormous amount of computation. Otherwise, you would have to draw a vector from the previous latitude/longitude point to the current latitude/longitude point and then calculate the angle it forms with the North direction.

The other data string we will be using is the $GPRMB, or the Recommended Minimum Navigation Information. This data string contains 14 pieces of information separated by commas within the string:

  1. Data Status
  2. Crosstrack Error (in nautical miles)
  3. Direction to Steer to Correct Error (L or R)
  4. Origin Waypoint ID#
  5. Destination Waypoint ID#
  6. Destination Waypoint Latitude
  7. North or South
  8. Destination Waypoint Longitude
  9. East or West
  10. Range to Destination (in nautical miles)
  11. Bearing to Destination (in degrees)
  12. Destination Closing Velocity (in knots)
  13. Arrival Status; (A=entered or perpendicular passed)
  14. Checksum

Again, we will only be using one piece of data from this string. The bearing to destination (11) details the heading to the next waypoint (in degrees) from the current position and is also measured clockwise from the North direction.

Turning Algorithm

Now that the current heading of the ground vehicle and the heading to the next waypoint are known, we can discern which way and how much the truck should turn in order to hit the next waypoint. For example, the figure below shows one scenario given the waypoint heading angle (measured from the North direction) and the true course angle (which is the current heading of the vehicle, also measured from the North direction). Intuitively, it is obvious the truck should turn right here to head towards the next waypoint.

The easiest way of coding such an algorithm is to say that if the truck heading (or true course) is less than the waypoint heading, turn right; otherwise turn left. This type of bang-bang control takes a lot of tuning, however, as you have to get the turning radius just right. If your ground vehicle is a degree off to the left, then the truck will still implement a turn left condition and will probably throw it off-course. Using proportional control is much more efficient and works by computing the error between the truck heading and waypoint heading. This way, when the truck is only a degree or two off, the controller will make a comparable adjustment to get back on track. Both pieces of code can be downloaded in the next section.

Programming the Microcontroller

Once everything is mounted, the next step is to program the Basic Stamp. Basic Stamp software can be downloaded from Parallax. Once the software is downloaded and installed, download the GPS navigation code for the E-Maxx emaxxGps_bangBang.bsp and emaxxGps_proportional.bsp. Open one of them using the Basic Stamp software and then select Run => Run. Note: if you're connecting your BS2p to a port other than COM4, you will have to edit this in the code before trying to program your Stamp. Finally, disconnect the RS232 cable from your Basic Stamp board.

Marking Waypoints

Before mounting the GPS receiver to the E-Maxx truck, you must first program the waypoint route into the device. The first step is to manually store the waypoints in memory. Using the circular button on the Garmin eTrex Vista, navigate to Main Menu => Waypoints and upon arriving at each waypoint you'd like to store, click on Okay. The receiver will then prompt you to name the waypoint. You can just accept the default value which will number them in sequential order. Continue storing in all waypoints you'd like your E-Maxx to follow and once finished, the waypoints must be entered into a Route. Go to Main Menu => Route and enter in the waypoints in the desired order. Note: if the last waypoint in the route is ever closer than the next waypoint, the GPS device will automatically set the endpoint as the next waypoint. Unfortunately, this prevents the user from programming circular routes. See below for a graphical description.

To verify your route is setup properly, go into Main Menu => Routes and click on Navigate. Start walking with the GPS receiver in hand and the arrow should direct you from your current position to the next waypoint. Note: the true heading value will not be accurate unless your are in motion. Therefore, you must be walking in order for the arrow to correctly point you in the right direction.

Mounting the GPS Receiver

The GPS receiver is sensitive to magnetic interference. Therefore, the GPS receiver has to be elevated so that it is not in close proximity to the brushed motors on the E-Maxx truck. I created a mount out of lightweight balsa wood and secured the receiver using a zip tie. Determine how much of the Garmin data cable is needed to reach from the GPS receiver to the Basic Stamp module (mounted anywhere on the truck chassis). Now strip the end of the cable at the determined length to expose the 3 wires inside the insulation. Feed the transmit and ground wires into a 2-pin female header. This will fit over pin 0 and Vss of the Basic Stamp development board.

Testing GPS Navigation

Your truck is now ready to do GPS waypoint navigation. Control the throttle manually and watch as the Basic Stamp microcontroller steers your E-Maxx truck to each of the waypoints stored in the route. Here is a video demonstrating this:

This tutorial was created by B. Green: home page