Main MRPT website > C++ reference
MRPT logo
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes

mrpt::hwdrivers::CGPSInterface Class Reference


Detailed Description

A parser of NMEA commands, for connecting to a GPS by a serial port.

This class also supports more advanced GPS equipped with RTK corrections. See the JAVAD/TopCon extra initialization parameters.

  PARAMETERS IN THE ".INI"-LIKE CONFIGURATION STRINGS:
 -------------------------------------------------------
   [supplied_section_name]
    COM_port_WIN = COM3
    COM_port_LIN = ttyS0
    baudRate     = 4800   // The baudrate of the communications (typ. 4800 bauds)
    pose_x       = 0      // 3D position of the sensed point relative to the robot (meters)
    pose_y       = 0
    pose_z       = 0
    customInit   =       // See below for possible values

           // The next parameters are optional and will be used only
    // if customInit=="JAVAD" to enable/configure the usage of RTK corrections:
    //JAVAD_rtk_src_port=/dev/ser/b
    //JAVAD_rtk_src_baud=9600
    //JAVAD_rtk_format=cmr

VERSIONS HISTORY: -9/JUN/2006: First version (JLBC) -4/JUN/2008: Added virtual methods for device-specific initialization commands. -10/JUN/2008: Converted into CGenericSensor class (there are no inhirited classes anymore).

Definition at line 77 of file CGPSInterface.h.

#include <mrpt/hwdrivers/CGPSInterface.h>

Inheritance diagram for mrpt::hwdrivers::CGPSInterface:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 CGPSInterface (int BUFFER_LENGTH=500)
 Constructor.
virtual ~CGPSInterface ()
 Destructor.
void doProcess ()
 This method should be called periodically (at least at 1Hz to capture ALL the real-time data) It is thread safe, i.e.
bool isGPS_connected ()
 Returns true if communications work.
bool isGPS_signalAcquired ()
 Returns true if the last message from the GPS indicates that the signal from sats has been acquired.
void setSerialPortName (const std::string &COM_port)
 Set the serial port to use (COM1, ttyUSB0, etc).
std::string getSerialPortName () const
 Get the serial port to use (COM1, ttyUSB0, etc).

Protected Member Functions

bool OnConnectionEstablished ()
 Implements custom messages to be sent to the GPS unit just after connection and before normal use.
void loadConfig_sensorSpecific (const mrpt::utils::CConfigFileBase &configSource, const std::string &iniSection)
 Loads specific configuration for the device from a given source of configuration parameters, for example, an ".ini" file, loading from the section "[iniSection]" (see utils::CConfigFileBase and derived classes) See hwdrivers::CGPSInterface for the possible parameters.
void setJAVAD_rtk_src_port (const std::string &s)
 If not empty, will send a cmd "set,/par/pos/pd/port,...".
void setJAVAD_rtk_src_baud (unsigned int baud)
 Only used when "m_JAVAD_rtk_src_port" is not empty.
void setJAVAD_rtk_format (const std::string &s)
 Only used when "m_JAVAD_rtk_src_port" is not empty: format of RTK corrections: "cmr", "rtcm", "rtcm3", etc.

Protected Attributes

CSerialPort m_COM
poses::CPoint3D m_sensorPose
std::string m_customInit

Private Member Functions

bool tryToOpenTheCOM ()
 Returns true if the COM port is already open, or try to open it in other case.
void processBuffer ()
 Process data in "m_buffer" to extract GPS messages, and remove them from the buffer.
void processGPSstring (const std::string &s)
 Process a complete string from the GPS:
void getNextToken (const std::string &str, std::string &token, unsigned int &parserPos)
 Tokenize a string "str" into commas separated tokens.
void JAVAD_sendMessage (const char *str, bool waitForAnswer=true)
 Private auxiliary method. Raises exception on error.

Private Attributes

std::string m_COMname
int m_COMbauds
bool m_GPS_comsWork
bool m_GPS_signalAcquired
int m_BUFFER_LENGTH
char * m_buffer
size_t m_bufferLength
size_t m_bufferWritePos
std::string m_JAVAD_rtk_src_port
 If not empty, will send a cmd "set,/par/pos/pd/port,...". Example value: "/dev/ser/b".
unsigned int m_JAVAD_rtk_src_baud
 Only used when "m_JAVAD_rtk_src_port" is not empty.
std::string m_JAVAD_rtk_format
 Only used when "m_JAVAD_rtk_src_port" is not empty: format of RTK corrections: "cmr", "rtcm", "rtcm3", etc.
mrpt::slam::CObservationGPS m_latestGPS_data

Constructor & Destructor Documentation

mrpt::hwdrivers::CGPSInterface::CGPSInterface ( int  BUFFER_LENGTH = 500)

Constructor.

Parameters:
BUFFER_LENGTHThe size of the communications buffer (default value should be fine always)
virtual mrpt::hwdrivers::CGPSInterface::~CGPSInterface ( ) [virtual]

Destructor.


Member Function Documentation

void mrpt::hwdrivers::CGPSInterface::doProcess ( ) [virtual]

This method should be called periodically (at least at 1Hz to capture ALL the real-time data) It is thread safe, i.e.

you can call this from one thread, then to other methods from other threads. This method processes data from the GPS and update the object state accordingly.

Implements mrpt::hwdrivers::CGenericSensor.

void mrpt::hwdrivers::CGPSInterface::getNextToken ( const std::string &  str,
std::string &  token,
unsigned int &  parserPos 
) [private]

Tokenize a string "str" into commas separated tokens.

std::string mrpt::hwdrivers::CGPSInterface::getSerialPortName ( ) const

Get the serial port to use (COM1, ttyUSB0, etc).

bool mrpt::hwdrivers::CGPSInterface::isGPS_connected ( )

Returns true if communications work.

bool mrpt::hwdrivers::CGPSInterface::isGPS_signalAcquired ( )

Returns true if the last message from the GPS indicates that the signal from sats has been acquired.

void mrpt::hwdrivers::CGPSInterface::JAVAD_sendMessage ( const char *  str,
bool  waitForAnswer = true 
) [private]

Private auxiliary method. Raises exception on error.

void mrpt::hwdrivers::CGPSInterface::loadConfig_sensorSpecific ( const mrpt::utils::CConfigFileBase configSource,
const std::string &  iniSection 
) [protected, virtual]

Loads specific configuration for the device from a given source of configuration parameters, for example, an ".ini" file, loading from the section "[iniSection]" (see utils::CConfigFileBase and derived classes) See hwdrivers::CGPSInterface for the possible parameters.

Implements mrpt::hwdrivers::CGenericSensor.

bool mrpt::hwdrivers::CGPSInterface::OnConnectionEstablished ( ) [protected]

Implements custom messages to be sent to the GPS unit just after connection and before normal use.

Returns false or raise an exception if something goes wrong.

void mrpt::hwdrivers::CGPSInterface::processBuffer ( ) [private]

Process data in "m_buffer" to extract GPS messages, and remove them from the buffer.

void mrpt::hwdrivers::CGPSInterface::processGPSstring ( const std::string &  s) [private]

Process a complete string from the GPS:

void mrpt::hwdrivers::CGPSInterface::setJAVAD_rtk_format ( const std::string &  s) [inline, protected]

Only used when "m_JAVAD_rtk_src_port" is not empty: format of RTK corrections: "cmr", "rtcm", "rtcm3", etc.

Definition at line 134 of file CGPSInterface.h.

void mrpt::hwdrivers::CGPSInterface::setJAVAD_rtk_src_baud ( unsigned int  baud) [inline, protected]

Only used when "m_JAVAD_rtk_src_port" is not empty.

Definition at line 131 of file CGPSInterface.h.

void mrpt::hwdrivers::CGPSInterface::setJAVAD_rtk_src_port ( const std::string &  s) [inline, protected]

If not empty, will send a cmd "set,/par/pos/pd/port,...".

Example value: "/dev/ser/b"

Definition at line 128 of file CGPSInterface.h.

void mrpt::hwdrivers::CGPSInterface::setSerialPortName ( const std::string &  COM_port)

Set the serial port to use (COM1, ttyUSB0, etc).

bool mrpt::hwdrivers::CGPSInterface::tryToOpenTheCOM ( ) [private]

Returns true if the COM port is already open, or try to open it in other case.

Returns:
true if everything goes OK, or false if there are problems opening the port.

Member Data Documentation

Definition at line 143 of file CGPSInterface.h.

Definition at line 141 of file CGPSInterface.h.

Definition at line 144 of file CGPSInterface.h.

Definition at line 145 of file CGPSInterface.h.

Definition at line 114 of file CGPSInterface.h.

Definition at line 138 of file CGPSInterface.h.

Definition at line 137 of file CGPSInterface.h.

Definition at line 118 of file CGPSInterface.h.

Definition at line 139 of file CGPSInterface.h.

Definition at line 140 of file CGPSInterface.h.

Only used when "m_JAVAD_rtk_src_port" is not empty: format of RTK corrections: "cmr", "rtcm", "rtcm3", etc.

Definition at line 149 of file CGPSInterface.h.

Only used when "m_JAVAD_rtk_src_port" is not empty.

Definition at line 148 of file CGPSInterface.h.

If not empty, will send a cmd "set,/par/pos/pd/port,...". Example value: "/dev/ser/b".

Definition at line 147 of file CGPSInterface.h.

Definition at line 173 of file CGPSInterface.h.

Definition at line 116 of file CGPSInterface.h.




Page generated by Doxygen 1.7.3 for MRPT 0.9.4 SVN:exported at Tue Jan 25 21:56:31 UTC 2011