Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes

GPS Class Reference

Abstract base class for GPS receiver drivers. More...

#include <GPS.h>

Inherited by AP_GPS_Auto, AP_GPS_HIL, AP_GPS_MTK, AP_GPS_MTK16, AP_GPS_NMEA, AP_GPS_None, AP_GPS_SIRF, and AP_GPS_UBLOX.

Collaboration diagram for GPS:
Collaboration graph
[legend]

List of all members.

Public Types

enum  GPS_Status { NO_GPS = 0, NO_FIX = 1, GPS_OK = 2 }

Public Member Functions

 GPS (Stream *s)
void update (void)
GPS_Status status (void)
virtual void init (void)=0

Public Attributes

long time
 GPS time in milliseconds from the start of the week.
long latitude
 latitude in degrees * 10,000,000
long longitude
 longitude in degrees * 10,000,000
long altitude
 altitude in cm
long ground_speed
 ground speed in cm/sec
long ground_course
 ground course in 100ths of a degree
long speed_3d
 3D speed in cm/sec (not always available)
int hdop
 horizontal dilution of precision in cm
uint8_t num_sats
 Number of visible satelites.
bool new_data
bool fix
 true if we have a position fix (use status instead)
bool valid_read
 true if we have seen data from the GPS (use status instead)
bool print_errors
 deprecated

Protected Member Functions

virtual bool read (void)=0
long _swapl (const void *bytes)
int _swapi (const void *bytes)
void _error (const char *msg)

Protected Attributes

Stream_port
 port the GPS is attached to

Detailed Description

Abstract base class for GPS receiver drivers.

Definition at line 14 of file GPS.h.


Member Enumeration Documentation

GPS status codes

Note:
Non-intuitive ordering for legacy reasons
Enumerator:
NO_GPS 

No GPS connected/detected.

NO_FIX 

Receiving valid GPS messages but no lock.

GPS_OK 

Receiving valid messages and locked.

Definition at line 40 of file GPS.h.


Constructor & Destructor Documentation

GPS::GPS ( Stream s  )  [inline]

Constructor

Note:
The stream is expected to be set up and configured for the correct bitrate before init is called.
Parameters:
s Stream connected to the GPS module.

Definition at line 25 of file GPS.h.


Member Function Documentation

void GPS::_error ( const char *  msg  )  [protected]

emit an error message

based on the value of print_errors, emits the printf-formatted message in msg,... to stderr

Parameters:
fmt printf-like format string
Note:
deprecated as-is due to the difficulty of hooking up to a working printf vs. the potential benefits

Definition at line 34 of file GPS.cpp.

int16_t GPS::_swapi ( const void *  bytes  )  [inline, protected]

perform an endian swap on an int

Parameters:
bytes pointer to a buffer containing bytes representing an int in the wrong byte order
Returns:
endian-swapped value

Definition at line 158 of file GPS.h.

long GPS::_swapl ( const void *  bytes  )  [inline, protected]

perform an endian swap on a long

Parameters:
bytes pointer to a buffer containing bytes representing a long in the wrong byte order
Returns:
endian-swapped value

Definition at line 141 of file GPS.h.

virtual void GPS::init ( void   )  [pure virtual]

Startup initialisation.

This routine performs any one-off initialisation required to set the GPS up for use.

Must be implemented by the GPS driver.

Implemented in AP_GPS_406, AP_GPS_Auto, AP_GPS_HIL, AP_GPS_MTK, AP_GPS_MTK16, AP_GPS_NMEA, AP_GPS_None, AP_GPS_SIRF, and AP_GPS_UBLOX.

virtual bool GPS::read ( void   )  [protected, pure virtual]

read from the GPS stream and update properties

Must be implemented by the GPS driver.

Returns:
true if a valid message was received from the GPS

Implemented in AP_GPS_Auto, AP_GPS_HIL, AP_GPS_MTK, AP_GPS_MTK16, AP_GPS_NMEA, AP_GPS_None, AP_GPS_SIRF, and AP_GPS_UBLOX.

GPS_Status GPS::status ( void   )  [inline]

Query GPS status

The 'valid message' status indicates that a recognised message was received from the GPS within the last 500ms.

Returns:
Current GPS status

Definition at line 53 of file GPS.h.

void GPS::update ( void   ) 

Update GPS state based on possible bytes received from the module.

This routine must be called periodically to process incoming data.

GPS drivers should not override this function; they should implement read instead.

Definition at line 7 of file GPS.cpp.


Member Data Documentation

Stream* GPS::_port [protected]

port the GPS is attached to

Definition at line 88 of file GPS.h.

altitude in cm

Definition at line 68 of file GPS.h.

bool GPS::fix

true if we have a position fix (use status instead)

Definition at line 81 of file GPS.h.

ground course in 100ths of a degree

Definition at line 70 of file GPS.h.

ground speed in cm/sec

Definition at line 69 of file GPS.h.

int GPS::hdop

horizontal dilution of precision in cm

Definition at line 72 of file GPS.h.

latitude in degrees * 10,000,000

Definition at line 66 of file GPS.h.

longitude in degrees * 10,000,000

Definition at line 67 of file GPS.h.

Set to true when new data arrives. A client may set this to false in order to avoid processing data they have already seen.

Definition at line 78 of file GPS.h.

uint8_t GPS::num_sats

Number of visible satelites.

Definition at line 73 of file GPS.h.

deprecated

Definition at line 85 of file GPS.h.

3D speed in cm/sec (not always available)

Definition at line 71 of file GPS.h.

long GPS::time

GPS time in milliseconds from the start of the week.

Definition at line 65 of file GPS.h.

true if we have seen data from the GPS (use status instead)

Definition at line 82 of file GPS.h.


The documentation for this class was generated from the following files: