lejos.nxt.addon
Class GPSSensor

java.lang.Object
  extended by lejos.nxt.I2CSensor
      extended by lejos.nxt.addon.GPSSensor
All Implemented Interfaces:
SensorConstants

public class GPSSensor
extends I2CSensor

Class for controlling dGPS sensor from Dexter Industries. Documentation for this sensor can be found at Dexter Industries.

The sensor uses an integer-based representation of latitude and longitude values. Assume that you want to convert the value of 77 degrees, 2 minutes and 54.79 seconds to the integer-based representation. The integer value is computed as follows: R = 1000000 * (D + M / 60 + S / 3600) where D=77, M=2, and S=54.79. For the given values, the formula yields the integer value 77048553. Basically, this is equivalent to decimal degrees times a million.

You can use the standard javax.microedition.location package with this class by using a dGPSCriteria object to request a LocationProvider as follows:

dGPSCriteria criteria = new gGPSCriteria(SensorPort.S1);
LocationProvider lp = LocationProvider.getInstance(criteria);

Author:
Mark Crosbie 22 January, 2011

Field Summary
static byte DGPS_CMD_ANGD
           
static byte DGPS_CMD_ANGR
           
static byte DGPS_CMD_DIST
           
static byte DGPS_CMD_HEAD
           
static byte DGPS_CMD_LAT
           
static byte DGPS_CMD_LONG
           
static byte DGPS_CMD_SLAT
           
static byte DGPS_CMD_SLONG
           
static byte DGPS_CMD_STATUS
           
static byte DGPS_CMD_UTC
           
static byte DGPS_CMD_VELO
           
static byte DGPS_I2C_ADDR
           
 
Fields inherited from class lejos.nxt.I2CSensor
address, DEFAULT_I2C_ADDRESS, port, REG_PRODUCT_ID, REG_VENDOR_ID, REG_VERSION
 
Fields inherited from interface lejos.nxt.SensorConstants
BLACK, BLANK_INDEX, BLUE, BLUE_INDEX, GREEN, GREEN_INDEX, MAX_AD_RAW, MAX_TYPE, MIN_TYPE, MODE_ANGLESTEP, MODE_BOOLEAN, MODE_CELSIUS, MODE_FARENHEIT, MODE_PCTFULLSCALE, MODE_PERIODCOUNTER, MODE_RAW, MODE_TRANSITIONCNT, RED, RED_INDEX, TYPE_ANGLE, TYPE_COLORBLUE, TYPE_COLORFULL, TYPE_COLORGREEN, TYPE_COLORNONE, TYPE_COLORRED, TYPE_CUSTOM, TYPE_HISPEED, TYPE_LIGHT_ACTIVE, TYPE_LIGHT_INACTIVE, TYPE_LOWSPEED, TYPE_LOWSPEED_9V, TYPE_NO_SENSOR, TYPE_REFLECTION, TYPE_SOUND_DB, TYPE_SOUND_DBA, TYPE_SWITCH, TYPE_TEMPERATURE, WHITE, YELLOW
 
Constructor Summary
GPSSensor(I2CPort sensorPort)
          Constructor
 
Method Summary
 int getAngleToDest()
          Angle to destination in degrees
 int getDistanceToDest()
          Distance to destination in meters
 int getHeading()
          Read the current heading in degrees as reported by the GPS chip.
 int getLatitude()
          Read the current latitude as an integer value (decimal degrees times a million).
 int getLongitude()
          Read the current longitude as an integer value (decimal degrees times a million).
 int getRelativeHeading()
          Read the current relative heading in degrees.
 int getUTC()
          Get the current time stored on the dGPS
 int getVelocity()
          Read the current velocity in cm/s
 boolean linkStatus()
          Return status of link to the GPS satellites LED on dGPS should light if satellite lock acquired
 int setLatitude(int latitude)
          Set destination latitude coordinates
 int setLongitude(int longitude)
          Set destination longitude coordinates
 
Methods inherited from class lejos.nxt.I2CSensor
fetchString, getAddress, getData, getData, getPort, getProductID, getVendorID, getVersion, sendData, sendData, sendData, setAddress
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DGPS_I2C_ADDR

public static final byte DGPS_I2C_ADDR
See Also:
Constant Field Values

DGPS_CMD_UTC

public static final byte DGPS_CMD_UTC
See Also:
Constant Field Values

DGPS_CMD_STATUS

public static final byte DGPS_CMD_STATUS
See Also:
Constant Field Values

DGPS_CMD_LAT

public static final byte DGPS_CMD_LAT
See Also:
Constant Field Values

DGPS_CMD_LONG

public static final byte DGPS_CMD_LONG
See Also:
Constant Field Values

DGPS_CMD_VELO

public static final byte DGPS_CMD_VELO
See Also:
Constant Field Values

DGPS_CMD_HEAD

public static final byte DGPS_CMD_HEAD
See Also:
Constant Field Values

DGPS_CMD_DIST

public static final byte DGPS_CMD_DIST
See Also:
Constant Field Values

DGPS_CMD_ANGD

public static final byte DGPS_CMD_ANGD
See Also:
Constant Field Values

DGPS_CMD_ANGR

public static final byte DGPS_CMD_ANGR
See Also:
Constant Field Values

DGPS_CMD_SLAT

public static final byte DGPS_CMD_SLAT
See Also:
Constant Field Values

DGPS_CMD_SLONG

public static final byte DGPS_CMD_SLONG
See Also:
Constant Field Values
Constructor Detail

GPSSensor

public GPSSensor(I2CPort sensorPort)
Constructor

Parameters:
sensorPort - the sensor port the sensor is connected to
Method Detail

linkStatus

public boolean linkStatus()
Return status of link to the GPS satellites LED on dGPS should light if satellite lock acquired

Returns:
true if GPS link is up, else false

getUTC

public int getUTC()
Get the current time stored on the dGPS

Returns:
current UTC time stored on the device

getLatitude

public int getLatitude()

Read the current latitude as an integer value (decimal degrees times a million). See here for explanation. positive=North, negative=South.

Returns:
current latitude in decimal degrees

getLongitude

public int getLongitude()

Read the current longitude as an integer value (decimal degrees times a million). See here for explanation. positive=East, negative=West.

Returns:
current longitude in decimal degrees

getVelocity

public int getVelocity()
Read the current velocity in cm/s

Returns:
current velocity in cm/s

getHeading

public int getHeading()
Read the current heading in degrees as reported by the GPS chip.

Returns:
current heading in degrees

getRelativeHeading

public int getRelativeHeading()

Read the current relative heading in degrees. The relative heading is the angle of travel since the last request of this method. The first time this method is called, the GPS coordinates are stored in this chip. The second time it is called it reports the angle between the current coordinates and the coordinates from the previous call.

(See dGPS manual.)

Returns:
relative head

getDistanceToDest

public int getDistanceToDest()
Distance to destination in meters

Returns:
distance to destination in meters

getAngleToDest

public int getAngleToDest()
Angle to destination in degrees

Returns:
angle to destination in degrees

setLatitude

public int setLatitude(int latitude)
Set destination latitude coordinates

Parameters:
latitude - destination's latitude in decimal degrees
Returns:
0 if no error else error code

setLongitude

public int setLongitude(int longitude)
Set destination longitude coordinates

Parameters:
longitude - destination's longitude in decimal degrees
Returns:
0 if no error else error code