AURobotServers
4
|
#include <uresgps.h>
Public Member Functions | |
void | closePort () |
virtual bool | decodeReplayLine (char *line) |
const char * | getDevice () |
const char * | getDeviceName () |
int | getDeviceSpeed () |
const char * | getLastLatLongSentance () |
UTime | getLastPositionTime () |
const char * | getLastSentance () |
const char * | getLastStatusSentance () |
const char * | getLastUtmSentance () |
int | getSpeed () |
UResBase * | getUtmHist () |
bool | isConnected () |
bool | isLogGpsOpen () |
void | openLogfile (bool open) |
void | openPort () |
virtual const char * | print (const char *preString, char *buff, int buffCnt) |
void | run () |
void | setDevice (const char *value) |
bool | setResource (UResBase *resource, bool remove) |
void | setSpeed (int value) |
UResGps () | |
void | UResGpsInit () |
virtual | ~UResGps () |
Public Member Functions inherited from UResVarPool | |
int | addMethod (const char *formalName, const char *paramTypes, const char *comment) |
int | addMethodV (const char *formalName, const char *paramTypes, const char *comment) |
UVarPool * | addStruct (const char *name, const char *comment, bool copy=false) |
UVariable * | addVar (const char *name, const double initialValue, const char *type, const char *comment) |
UVariable * | addVar (const char *name, const char *initialValue, const char *type, const char *comment) |
UVariable * | addVarA (const char *name, const char *initialValue, const char *type, const char *comment) |
bool | callGlobal (const char *name, const char *paramOrder, char **strings, const double *doubles, double *value, UDataBase **returnStruct, int *returnStructCnt) |
bool | callGlobalV (const char *name, const char *paramOrder, UVariable **params, UDataBase **returnStruct, int *returnStructCnt) |
Call a method from the root var pool scope It may be in the structure direct (no '.') or in any sub-structure that the 'name.subname' indicate. More... | |
bool | callLocal (const char *name, const char *paramOrder, char **strings, const double *doubles, double *value, UDataBase **returnStruct, int *returnStructCnt) |
bool | callVS (const char *function, const char *stringParam) |
int | callVSCD (const char *function, const char *strPar, UDataBase *data, int cooSys) |
void | createBaseVar () |
virtual bool | createVarSpace (const int varCnt, const int structCnt, const int methCnt, const char *note, bool copy=false) |
bool | getGlobalString (const char *name, const char **value) |
bool | getGlobalValue (const char *name, double *value) |
bool | getGlobalValue (const char *name, const char **value) |
bool | getGlobalValue (const char *name, bool *value) |
bool | getGlobalValue (const char *name, UTime *value) |
bool | getLocalValue (const char *name, double *value) |
get a value in this variable tree More... | |
bool | getLocalValue (const char *name, bool *value) |
bool | getLocalValue (const char *name, UTime *value) |
double | getLocalValue (int idx) |
UPosition | getLocalValue3D (int idx) |
UPosRot | getLocalValue6D (int idx) |
bool | getLocalValueBool (int idx) |
int | getLocalValueInt (int idx) |
UTime | getLocalValueTime (int idx) |
const char * | getLogFileName () |
const char * | getVarDescription (int idx) |
UVarCalc * | getVarPool () |
virtual bool | gotAllResources (char *missingThese, int missingTheseCnt) |
bool | isLogFileOpen () |
bool | isLogFileOpen (const char *structName) |
bool | isVarPoolUpdated (int lastCnt, int *newCnt) |
void | logFileClose () |
bool | logFileOpen () |
void | logFileStart (const char *structName, bool open) |
virtual bool | methodCall (const char *name, const char *paramOrder, char **strings, const double *doubles, double *value, UDataBase **returnStruct=NULL, int *returnStructCnt=NULL) |
bool | setGlobalVar (const char *name, const double value, bool mayAdd) |
Assigns a value to a variable. The variable may be a part of a structure. More... | |
bool | setLocalVar (int idx, double value, const int element) |
bool | setLocalVar (const char *name, const double value, bool mayAdd) |
Assigns a value to a variable. The variable may be a part of a structure. More... | |
bool | setLocalVar3D (int idx, UPosition *value) |
bool | setLocalVar6D (int idx, UPosRot *value) |
bool | setLocalVarAdd (int idx, double value, const int element) |
bool | setLocalVarPose (int idx, UPose *value) |
void | setVarPool (UVarCalc *sharedVarPool) |
int | updateQTvars (int structIdx) |
UResVarPool () | |
virtual | ~UResVarPool () |
Public Member Functions inherited from UResBase | |
void | createReplayVar (UVarPool *pool) |
virtual void | createResources () |
UCmdExe * | getCorePointer () |
char * | getLogFileName (char *fn, const int fnCnt) |
int | getResFuncIdx () |
const char * | getResID () |
int | getResVersion () |
bool | isA (const char *idStr) |
bool | isAlsoA (const char *id) |
virtual void | print (const char *preString) |
virtual void | saveSettings () |
void | setCorePointer (UCmdExe *serverCore) |
void | setResFuncIdx (int idx) |
virtual void | setResID (const char *id, const int version) |
virtual void | stop (bool) |
virtual void | updateReplayStatus () |
UResBase () | |
virtual | ~UResBase () |
Public Member Functions inherited from UReplay | |
void | addChild (UReplay *child) |
char * | getLogFileName (char *fn, const int fnCnt) |
char * | getReplayFileName (char *fn, const int fnCnt) |
int | getReplayLogLine () |
bool | isReplay () |
bool | isReplayFileOpen () |
void | removeChild (UReplay *child) |
virtual void | replayAdvanceTime (UTime untilTime) |
void | replaySetBaseFileName (const char *name, const char *preName="") |
void | replaySetFileName (const char *name) |
virtual bool | replayStep () |
int | replayStep (int steps) |
virtual bool | replayToTime (UTime untilTime) |
void | setParent (UReplay *parent) |
bool | setReplay (bool value) |
UReplay () | |
virtual | ~UReplay () |
Public Member Functions inherited from ULock | |
bool | lock () |
void | lockInit () |
void | post () |
bool | tryLock () |
bool | tryWait () |
ULock () | |
void | unlock () |
bool | wait () |
~ULock () | |
Public Member Functions inherited from UVarMethodImplement | |
virtual bool | methodCallV (const char *name, const char *paramOrder, UVariable *params[], UDataBase **returnStruct, int *returnStructCnt) |
virtual | ~UVarMethodImplement () |
Static Public Member Functions | |
static const char * | getResClassID () |
Static Public Member Functions inherited from UResVarPool | |
static const char * | getResClassID () |
Public Attributes | |
ULogFile | logGps |
Public Attributes inherited from UReplay | |
bool | replayTimeAdvancePending |
UTime | replayTimeNow |
Protected Member Functions | |
char | ascii2hex (char input) |
Implementation of a ASCII to HEX coverter. More... | |
void | createBaseVar () |
int | receiveFromDevice (FILE *device, char *buff, int buffCnt, const double timeoutSec) |
bool | start () |
void | stop () |
void | toLog (const char *message) |
void | updateVars () |
bool | validateNMEA (char *in_buf) |
Protected Member Functions inherited from UResVarPool | |
void | setDescription (const char *note, bool copy=false) |
Protected Member Functions inherited from UResBase | |
UResBase * | getStaticResource (const char *resName, bool mayCreate, bool staticOnly=true) |
get a pointer to a static resource. More... | |
Protected Attributes | |
int | dataRxMsgCnt |
UTime | dataRxTime |
char | logGpsName [MAX_FILENAME_LENGTH] |
UResPoseHist * | mapPose |
UResPoseHist * | odoPose |
pthread_t | threadHandle |
bool | threadRunning |
bool | threadStop |
UResPoseHist * | utmPose |
Protected Attributes inherited from UResBase | |
int | resFuncIdx |
char | resID [MAX_RESOURCE_ID_LENGTH] |
char | resIsAlso [MAX_RESOURCE_ISALSO_LENGTH] |
int | resVersion |
Protected Attributes inherited from UReplay | |
bool | replay |
FILE * | replayFile |
char | replayFileName [REPLAY_FILE_NAME_LENGTH] |
replay filename More... | |
char | replayLine [MAX_LOG_LINE_LENGTH] |
int | replayLogLine |
UReplay * | replayParent |
UTime | replayTimeNext |
Private Member Functions | |
int | advanceNmeaMessage (char *rxBuff, int rxBuffCnt, char *pEnd) |
void | clear () |
UTime | getTimeLocal () |
bool | hasNmeaMessage (char *rxBuff, int rxBuffCnt, char **pEnd) |
bool | parseNMEA (char *inBuf, UTime tod) |
Function to transform from Lat-Long to UTM in a given zone. More... | |
Private Attributes | |
UTime | lastTime |
UGpsLatLong | latLong |
received Lat-Long position More... | |
bool | latLongUpdated |
set when Lat-Long is updated More... | |
ULogFile | log2 |
debug log More... | |
UTime | msgTime |
Local computer time for last message - to be used in UTM pose history. More... | |
char | replaySentence [GPS_SENTENCE_MAX_LENGTH] |
replay line in NMEA format to replay More... | |
ULock | replaySentenceLock |
lock to protect integrity of sentence More... | |
bool | replaySentenceNew |
is new replay data available More... | |
char | sentence [GPS_SENTENCE_MAX_LENGTH] |
last message received More... | |
UGpsStatus | status |
Status of the GPS reception. More... | |
bool | statusUpdated |
set when status is updated More... | |
UGpsUTM | utm |
Received UTM position. More... | |
bool | utmUpdated |
set when utm is updated More... | |
UVariable * | varBaud |
device baudrate More... | |
UVariable * | varDevice |
device file name More... | |
UVariable * | varDop |
Dilution of position 1 is perfect, 5 is fair, >8 is bad. More... | |
UVariable * | varEasting |
index to UTM Easting in current zone in meter More... | |
UVariable * | varEgnos |
index to EGNOS variable More... | |
UVariable * | varFixRate |
Number of fixes per second. More... | |
UVariable * | varGmt |
Last received GMT time. More... | |
UVariable * | varGmts |
Last received GMT time. More... | |
UVariable * | varGPGGA |
UVariable * | varGPGLL |
UVariable * | varGPGSA |
UVariable * | varGPGSV |
UVariable * | varGPRMC |
UVariable * | varGPVTG |
NMEA strings. More... | |
UVariable * | varHeading |
index to Heading received from GPS (compas degrees) More... | |
UVariable * | varHeight |
Longitude in decimal degrees, positive is East. More... | |
UVariable * | varLat |
Latitude in decimal degrees, positive is North. More... | |
UVariable * | varLong |
Longitude in decimal degrees, positive is East. More... | |
UVariable * | varMakeUTM |
Do automatic conversion to UTM. More... | |
UVariable * | varMapPoseKeep |
Maintain Map-pose with UTM coordinates. More... | |
UVariable * | varMapPoseRef |
Map-pose set with UTM coordinates relative to this position [east, north]. More... | |
UVariable * | varMode |
index to gps mode (1=noFix 3 = 3D fix) More... | |
UVariable * | varNorthing |
UTM northing in current zone in meter. More... | |
UVariable * | varOpen |
device file name More... | |
UVariable * | varPTNL |
UVariable * | varSatsUsed |
Number of used satelites in calculation. More... | |
UVariable * | varSatsVisible |
Number of visible satellites. More... | |
UVariable * | varSpeed |
index to Speed received from GPS [m/s] More... | |
UVariable * | varTime |
Last fix time. More... | |
UVariable * | varTimes |
Last fix time. More... | |
UVariable * | varUpdCntLL |
index to number of UTM updates received More... | |
UVariable * | varUpdCntUTM |
index to replay flag More... | |
UVariable * | varUseOdoHeading |
use odometry history to estimate heading for map and utm pose update More... | |
UVariable * | varUtmPoseKeep |
Maintain UTM-pose with raw UTM coordinates. More... | |
UVariable * | varUTMZone |
index to variable with UTM zone More... | |
Additional Inherited Members | |
Static Protected Attributes inherited from UReplay | |
static const int | MAX_LOG_LINE_LENGTH = 10000 |
static const int | REPLAY_FILE_NAME_LENGTH = 264 |
max length of replay filename More... | |
This is the shared resource class. It must enherit from the resource base class (or one of its decendent) as shown.
|
inline |
Constructor
|
virtual |
Destructor
|
private |
Removes one NMEA message from input buffer, and if there is more than one, then the start of the new message - the '$' is moved to start of buffer, and the new buffer length is returned.If no new measse is found (no '$') then the buffer is returned empty.
rxBuff | is the buffer to check. |
rxBuffCnt | is the number of bytes in buffer. |
pEnd | is end of massage to be discarded. |
|
protected |
Implementation of a ASCII to HEX coverter.
Takes both upper and lower case ascii values but has no check for non HEX values.
[in] | input | Character input in ascii values |
|
private |
Clear all structures in this class
|
inline |
Close serial port
Referenced by UFunctionGps::handleCommand().
|
protected |
Make the variables that will be available to other plugins
|
virtual |
Decode this replay line, that is assumed to be valid.
line | is a pointer to the line. |
Reimplemented from UReplay.
References GPS_SENTENCE_MAX_LENGTH.
|
inline |
set the serial device filename.
|
inline |
Get serial port name
Referenced by UFunctionGps::handleCommand().
|
inline |
Get serial port speed (bit/sec) - may not be used if USB device.
Referenced by UFunctionGps::handleCommand().
|
inline |
Get the latest lat-long received sentence.
|
inline |
Get time of laset received sentence position sentence.
References UGpsStatus::clear().
Referenced by UFunctionGps::handleCommand().
|
inline |
Get the latest received sentence - may or may not be used.
References UGpsStatus::sentence.
|
inline |
Get the latest status received sentence.
|
inline |
Get the latest UTM received sentence.
|
inlinestatic |
Fixed name of this resource type
|
inline |
get the serial device speed.
|
private |
Get time local time for last (lat-long) message
References UTime::getTimeTm(), and UTime::setTime().
|
inline |
Get pointer to the UTM pose history structure (or NULL is not available)
|
private |
checks if first character is a '$' and ends with a '*xx' sequence. The CR character after the checksum is replaced by a '\0'
rxBuff | is the buffer to check. |
rxBuffCnt | is the number of bytes in buffer |
pEnd | will be set to just after the message (most likely point to LF character after checksum) if there is a message, if no message is found, then pEnd is unchanged. (pEnd may be NULL). |
bool UResGps::isConnected | ( | ) |
Is the serial port to the GPS open
Referenced by UFunctionGps::handleCommand().
|
inline |
Is logfile open
Referenced by UFunctionGps::handleCommand().
|
inline |
Open (or close) logfile for raw gps data. Nothing happens if trying to open an open file or close a closed file.
[in] | Set | parameter to true to open port and false to close |
References ULock::lock(), and ULock::unlock().
Referenced by UFunctionGps::handleCommand().
|
inline |
Open seial port to GPS
Referenced by UFunctionGps::handleCommand().
|
private |
Function to transform from Lat-Long to UTM in a given zone.
The algorithm is supplied by Anders Gaasedal and is also used in his truck control project.
[in] | easting | in meter relative to central median (+ 500km) |
[in] | northing | in meter from equator |
[in] | zone | of central meridian |
[out] | latitude | as calculated (in degrees) |
[out] | longitude | as calculated (in degrees) |
Currently GPRMC, GPGGA, GPGSA, GPGSV anf PFST strings are supported.
[in] | *inBuf | Pointer to the string to be parsed. |
[in] | *tod | is the computer time data were received, to be used in utmHistory stack. |
References GPS_SENTENCE_MAX_LENGTH, and UGpsStatus::sentence.
|
virtual |
print status to a string buffer
Reimplemented from UResVarPool.
References bool2str(), and UGpsStatus::sentence.
|
protected |
Receive data from device Returns when a newline '
' is received, and there may be more data and possibly more messages. in the received data buffer.
[in] | 'buff' | is the buffer place where the received data is stored, |
[in] | Returns | when 'buffCnt' is reached - regardless of data |
[in] | Return | if timeout ('timeoutSec' sec) has passed with no data. |
void UResGps::run | ( | ) |
Run the receice loop for the GPS device. This call do not return until the threadStop flag is set true.
replace with non-blocking - see below
References UTime::Now(), setDeviceSpeed(), UTime::setTimeTod(), UTime::valid, and Wait().
Referenced by threadRunGps().
|
inline |
set the serial device filename.
Referenced by UFunctionGps::handleCommand().
|
virtual |
Set (or remove) ressource (core pointer needed by event handling)
Reimplemented from UResVarPool.
References UResPoseHist::getMapPoseID(), UResPoseHist::getOdoPoseID(), UResPoseHist::getUtmPoseID(), UResBase::isA(), and UResVarPool::setResource().
|
inline |
set the serial device speed.
Referenced by UFunctionGps::handleCommand().
|
protected |
|
protected |
Stop read thread - and wait for thread join
|
protected |
Save this string to the logfile after a timestamp with current time.
References UTime::getMicrosec(), UTime::getSec(), and UTime::now().
|
protected |
Update global variables from received data
References UPose::add(), UPose::h, latlon2UTM(), limitToPi(), UPoseTVQ::set(), utm2latlon(), UPose::x, and UPose::y.
void UResGps::UResGpsInit | ( | ) |
Initialize resource
|
protected |
check if this is a valid NMEA message checksum is correct.
[in] | the | sting with the message, of max length GPSSTRINGSIZE. |
|
protected |
Number of full messages received
|
protected |
Timestamp of the letest received data
|
private |
Last time data was received - including date Used when message holds time but no date, especially needed during replay.
|
private |
received Lat-Long position
|
private |
set when Lat-Long is updated
|
private |
debug log
ULogFile UResGps::logGps |
File handle to GPS log
Referenced by UFunctionGps::handleCommand().
|
protected |
Name of logfile
|
protected |
Pointer to Map pose history resource
|
private |
Local computer time for last message - to be used in UTM pose history.
|
protected |
Pointer to odometry pose history resource
|
private |
replay line in NMEA format to replay
|
private |
lock to protect integrity of sentence
|
private |
is new replay data available
|
private |
last message received
|
private |
Status of the GPS reception.
|
private |
set when status is updated
|
protected |
Thread handle for frame read thread.
|
protected |
Is thread actually running
|
protected |
Should thread stop - terminate
|
private |
Received UTM position.
|
protected |
The gps data received from GPS receiver Pointer to UTM pose history resource
|
private |
set when utm is updated
|
private |
device baudrate
|
private |
device file name
|
private |
Dilution of position 1 is perfect, 5 is fair, >8 is bad.
|
private |
index to UTM Easting in current zone in meter
|
private |
index to EGNOS variable
|
private |
Number of fixes per second.
|
private |
Last received GMT time.
|
private |
Last received GMT time.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
NMEA strings.
|
private |
index to Heading received from GPS (compas degrees)
|
private |
Longitude in decimal degrees, positive is East.
|
private |
Latitude in decimal degrees, positive is North.
|
private |
Longitude in decimal degrees, positive is East.
|
private |
Do automatic conversion to UTM.
|
private |
Maintain Map-pose with UTM coordinates.
|
private |
Map-pose set with UTM coordinates relative to this position [east, north].
|
private |
index to gps mode (1=noFix 3 = 3D fix)
|
private |
UTM northing in current zone in meter.
|
private |
device file name
|
private |
|
private |
Number of used satelites in calculation.
|
private |
Number of visible satellites.
|
private |
index to Speed received from GPS [m/s]
|
private |
Last fix time.
|
private |
Last fix time.
|
private |
index to number of UTM updates received
|
private |
index to replay flag
index to number of UTM updates received
|
private |
use odometry history to estimate heading for map and utm pose update
|
private |
Maintain UTM-pose with raw UTM coordinates.
|
private |
index to variable with UTM zone