MCP robot

GPS Subsystem


1. Hardware

The GPS receiver is a Garmin 16 series unit. Schuyler Salz assembled an RJ45-to-serial adapter so that the data from the receiver could be read by a computer. The adapter also provides power to the receiver. Prior work on this unit was also done by Ben Vic.

2. Software

A gpsd runs on the MCP's computer and is constantly receiving NMEA sentences from the gps unit. Any program running on the MCP can connect to the gpsd process through port 2497 retrieve data.

The MCP's navigation program uses libgps to connect to the gpsd. A thread in the navigation program continuously polls and receives data from gpsd. Information in the NMEA sentences are stored into gps_data_t struct. The latitude and longitude values are extracted from the struct and stored in global variables that are accessible to the rest of the GPS. The thread then takes the current position and the previous position of the MCP to determine the direction that the MCP is traveling in relation to the east.

Code listing 2.1: Class Declaration

#define D2R 57.29578 //180 degrees over pi radians

static double old_latitude;
static double old_longitude;

static double earth_radius = 6356.9; //in kilometers, the polar radius of the earth
static double smallest_lat=90;
static double smallest_lon=180;
static double largest_lat = -180;
static double largest_lon = -180;

class gps_object{
  // gps_data_t * gpsdata;
  pthread_mutex_t gps_mutex;
  pthread_cond_t gps_cond;
  pthread_t gps_thread_id;

  gps_data_t * getdata();
  double* getdirection();

void update_gpsdata(char *message);
void *gps_monitor(void *arg);
double distance (double a1, double b1, double a2, double b2);
double lat2Y(double lat);
double lon2X(double lon);
double Y2lat(double Y);
double X2lon(double X);

Updated 2005-05-22
Yan Tran

Summary:  The MCP's subsystem for getting GPS data.
Developed by students of the Engaging Computing Group in the Department of Computer Science at the University of Massachusetts Lowell