#include <ArGPS.h>
Inheritance diagram for ArGPS:
Connects to GPS device over a serial port or other device connection and reads data. Supports GPS devices sending standard NMEA format data (specifically the GPRMC, GPGGA, GPGSA, GPGRME, and optionally PGRMZ, PGRME, and HCHDG messages). If your GPS device supports several data formats or modes, select NMEA output in its configuration.
The preferred method of creating and setting up a new ArGPS object is to use ArGPSConnector, which creates an instance of ArGPS or a subclass, and creates and opens its device connection, based on command-line parameters. (To manually create an ArGPS object, create an ArDeviceConnection instance and call setDeviceConnection(), then open that device connection and call connect() or blockingConnect().)
For either method, to get new data from the GPS, must call read() periodically, ideally at a rate equal to or faster than your GPS sends data (usually one second). read() returns flags indicating whether it received partial data from the GPS, a complete "message" of data that it used to update stored data, or an error. You can use an ArRobot synchronized task callback functor to call read(), or you can run a loop in a new thread. If you are calling read() from a loop in a new thread, the loop ought to include a call to ArUtil::sleep() for at least several hundred miliseconds to avoid starving other threads, since read() will return immediately if there is no data to read rather than blocking.
Definition at line 78 of file ArGPS.h.
[NOHEADER] | |
enum | FixType { NoFix, BadFix, GPSFix, DGPSFix, PPSFix, RTKinFix, FloatRTKinFix, DeadReckFix, ManualFix, SimulatedFix, UnknownFixType } |
double | getAltitude () const |
double | getCompassHeading () const |
Heading from magnetic north. | |
unsigned short | getDGPSStationID () const |
FixType | getFixType () const |
const char * | getFixTypeName () const |
unsigned short | getGPSPositionTimestamp () const |
double | getHDOP () const |
double | getLatitude () const |
double | getLongitude () const |
unsigned short | getNumSatellitesTracked () const |
double | getPDOP () const |
double | getPositionError () const |
double | getSpeed () const |
ArTime | getTimeReceivedPosition () const |
double | getVDOP () const |
double | getVerticalPositionError () const |
GPS device's error estimation in meters. | |
bool | haveAltitude () const |
bool | haveCompassHeading () const |
Have a compass heading value. | |
bool | haveDGPSStation () const |
bool | haveHDOP () const |
bool | haveLatitude () const |
bool | haveLongitude () const |
bool | havePDOP () const |
bool | havePosition () const |
bool | havePositionError () const |
bool | haveSpeed () const |
bool | haveVDOP () const |
bool | haveVerticalPositionError () const |
Public Types | |
enum | ReadFlags { ReadFinished = 0, ReadError = 1, ReadData = 2, ReadUpdated = 4 } |
Flags to indicates what the read() method did. i.e. If nothing was done, then the result will be 0. To check a read() return result result to see if data was updated, use (result & ReadUpdated). To check if there was an error, use (result & ReadError). | |
Public Member Functions | |
ArGPS () | |
bool | blockingConnect (unsigned long connectTimeout=8000) |
Call connect(), then keep attempting to read data. If no valid data is received and parsed (resulting in a stored data update) within the timeout period, return false. | |
virtual bool | connect () |
Check that the device connection is open, and get ready to read data from the GPS. If a non-standard device type was set, then device-specific initialization commands may be sent. | |
ArDeviceConnection * | getDeviceConnection (ArDeviceConnection *deviceConn) const |
Return device connection in use (or NULL if none). | |
void | logData () const |
Log last received data using ArLog. | |
void | printData () const |
virtual int | read () |
Read some data from the device connection, and update stored data as complete messages are received. Return when no more data is available. | |
void | setDeviceConnection (ArDeviceConnection *deviceConn) |
Set device connection to use. | |
void | setIgnoreChecksum (bool ignore) |
Set whether checksum sent with NMEA messages is ignored. | |
Protected Types | |
typedef ArFunctor1C< ArGPS, MessageVector * > | Handler |
typedef std::map< std::string, Handler * > | HandlerMap |
typedef std::vector< std::string > | MessageVector |
Protected Member Functions | |
void | beginChecksum () |
void | beginMessage () |
void | endMessage () |
void | handleGPGGA (MessageVector *message) |
void | handleGPGSA (MessageVector *message) |
void | handleGPRMC (MessageVector *message) |
void | handleHCHDG (MessageVector *message) |
void | handlePGRME (MessageVector *message) |
void | handlePGRMZ (MessageVector *message) |
void | nextField () |
bool | readFloatFromString (std::string &str, double *target, double(*convf)(double)=NULL) |
bool | readFloatFromStringVec (std::vector< std::string > *vec, size_t i, double *target, double(*convf)(double)=NULL) |
bool | readUShortFromString (std::string &str, unsigned short *target, unsigned short(*convf)(unsigned short)=NULL) |
bool | readUShortFromStringVec (std::vector< std::string > *vec, size_t i, unsigned short *target, unsigned short(*convf)(unsigned short)=NULL) |
Static Protected Member Functions | |
static double | feetToMeters (double f) |
static double | gpsDegminToDegrees (double degmin) |
static double | knotsToMPS (double knots) |
static double | metersToFeet (double m) |
static double | mpsToMph (double mps) |
Protected Attributes | |
char | checksumBuf [3] |
short | checksumBufOffset |
char | currentChecksum |
std::string | currentField |
MessageVector | currentMessage |
bool | gotCR |
bool | ignoreChecksum |
bool | inChecksum |
bool | inMessage |
const unsigned short | MaxFieldSize |
const unsigned short | MaxNumFields |
double | myAltitude |
ArArgumentParser * | myArgParser |
double | myCompassHeading |
bool | myCreatedOwnDeviceCon |
ArDeviceConnection * | myDevice |
unsigned short | myDGPSStationID |
FixType | myFixType |
Handler | myGPGGAHandler |
Handler | myGPGSAHandler |
Handler | myGPRMCHandler |
unsigned short | myGPSPositionTimestamp |
HandlerMap | myHandlers |
bool | myHaveAltitude |
bool | myHaveCompassHeading |
bool | myHaveDGPSStation |
bool | myHaveHDOP |
bool | myHavePDOP |
bool | myHavePosition |
bool | myHavePositionError |
bool | myHaveSpeed |
bool | myHaveVDOP |
bool | myHaveVerticalPositionError |
Handler | myHCHDGHandler |
double | myHDOP |
double | myLatitude |
double | myLongitude |
unsigned short | myNumSatellitesTracked |
ArRetFunctorC< bool, ArGPS > | myParseArgsCallback |
double | myPDOP |
Handler | myPGRMEHandler |
Handler | myPGRMZHandler |
double | myPositionError |
double | mySpeed |
ArTime | myTimeGotPosition |
double | myVDOP |
double | myVerticalPositionError |
|
Data accessors |
|
Initialize ArGPS object with the given device connection (e.g. an ArSerialDeviceConnection or other device connection object) and options.
|
|
Call connect(), then keep attempting to read data. If no valid data is received and parsed (resulting in a stored data update) within the timeout period, return false.
|
|
Check that the device connection is open, and get ready to read data from the GPS. If a non-standard device type was set, then device-specific initialization commands may be sent.
|
|
|
|
|
|
GPS device's error estimation in meters |
|
|
|
|
|
|
|
|
|
Print basic navigation data on one line to standard output, with no newline at end.
|
|
Read some data from the device connection, and update stored data as complete messages are received. Return when no more data is available.
|