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).
#include <mrpt/hwdrivers/CGPSInterface.h>

Public Member Functions | |
| CGPSInterface (int BUFFER_LENGTH=500, mrpt::hwdrivers::CSerialPort *outPort=NULL, mrpt::synch::CCriticalSection *csOutPort=NULL) | |
| 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). | |
| void | setExternCOM (CSerialPort *outPort, mrpt::synch::CCriticalSection *csOutPort) |
| bool | isAIMConfigured () |
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. | |
| bool | setJAVAD_AIM_mode () |
| Set Advanced Input Mode for the primary port. | |
| bool | unsetJAVAD_AIM_mode () |
| Unset Advanced Input Mode for the primary port and use it only as a command port. | |
| bool | useExternCOM () |
Protected Attributes | |
| CSerialPort | m_COM |
| CSerialPort * | m_out_COM |
| mrpt::synch::CCriticalSection * | m_cs_out_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. | |
| bool | m_useAIMMode |
| Use this mode for receive RTK corrections from a external source through the primary port. | |
| TTimeStamp | m_last_timestamp |
| bool | m_AIMConfigured |
| Indicates if the AIM has been properly set up. | |
| double | m_data_period |
| The period in seconds which the data should be provided by the GPS. | |
| mrpt::slam::CObservationGPS | m_latestGPS_data |
| mrpt::slam::CObservationGPS::TUTCTime | m_last_UTC_time |
| mrpt::hwdrivers::CGPSInterface::CGPSInterface | ( | int | BUFFER_LENGTH = 500, |
| mrpt::hwdrivers::CSerialPort * | outPort = NULL, |
||
| mrpt::synch::CCriticalSection * | csOutPort = NULL |
||
| ) |
Constructor.
| BUFFER_LENGTH | The size of the communications buffer (default value should be fine always) |
| virtual mrpt::hwdrivers::CGPSInterface::~CGPSInterface | ( | ) | [virtual] |
Destructor.
| 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::isAIMConfigured | ( | ) | [inline] |
Definition at line 116 of file CGPSInterface.h.
| 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::setExternCOM | ( | CSerialPort * | outPort, |
| mrpt::synch::CCriticalSection * | csOutPort | ||
| ) | [inline] |
Definition at line 113 of file CGPSInterface.h.
| bool mrpt::hwdrivers::CGPSInterface::setJAVAD_AIM_mode | ( | ) | [protected] |
Set Advanced Input Mode for the primary port.
This can be used to send RTK corrections to the device using the same port that it's used for the commands. The RTK correction stream must be re-packaged into a special frame with prefix ">>"
| 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 149 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 146 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 143 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.
| bool mrpt::hwdrivers::CGPSInterface::unsetJAVAD_AIM_mode | ( | ) | [protected] |
Unset Advanced Input Mode for the primary port and use it only as a command port.
| bool mrpt::hwdrivers::CGPSInterface::useExternCOM | ( | ) | [inline, protected] |
Definition at line 160 of file CGPSInterface.h.
bool mrpt::hwdrivers::CGPSInterface::m_AIMConfigured [private] |
Indicates if the AIM has been properly set up.
Definition at line 184 of file CGPSInterface.h.
char* mrpt::hwdrivers::CGPSInterface::m_buffer [private] |
Definition at line 170 of file CGPSInterface.h.
int mrpt::hwdrivers::CGPSInterface::m_BUFFER_LENGTH [private] |
Definition at line 168 of file CGPSInterface.h.
size_t mrpt::hwdrivers::CGPSInterface::m_bufferLength [private] |
Definition at line 171 of file CGPSInterface.h.
size_t mrpt::hwdrivers::CGPSInterface::m_bufferWritePos [private] |
Definition at line 172 of file CGPSInterface.h.
CSerialPort mrpt::hwdrivers::CGPSInterface::m_COM [protected] |
Definition at line 124 of file CGPSInterface.h.
int mrpt::hwdrivers::CGPSInterface::m_COMbauds [private] |
Definition at line 165 of file CGPSInterface.h.
Definition at line 164 of file CGPSInterface.h.
Definition at line 128 of file CGPSInterface.h.
Definition at line 133 of file CGPSInterface.h.
double mrpt::hwdrivers::CGPSInterface::m_data_period [private] |
The period in seconds which the data should be provided by the GPS.
Definition at line 185 of file CGPSInterface.h.
bool mrpt::hwdrivers::CGPSInterface::m_GPS_comsWork [private] |
Definition at line 166 of file CGPSInterface.h.
bool mrpt::hwdrivers::CGPSInterface::m_GPS_signalAcquired [private] |
Definition at line 167 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 176 of file CGPSInterface.h.
unsigned int mrpt::hwdrivers::CGPSInterface::m_JAVAD_rtk_src_baud [private] |
Only used when "m_JAVAD_rtk_src_port" is not empty.
Definition at line 175 of file CGPSInterface.h.
If not empty, will send a cmd "set,/par/pos/pd/port,...". Example value: "/dev/ser/b".
Definition at line 174 of file CGPSInterface.h.
TTimeStamp mrpt::hwdrivers::CGPSInterface::m_last_timestamp [private] |
Definition at line 181 of file CGPSInterface.h.
Definition at line 211 of file CGPSInterface.h.
Definition at line 210 of file CGPSInterface.h.
CSerialPort* mrpt::hwdrivers::CGPSInterface::m_out_COM [protected] |
Definition at line 127 of file CGPSInterface.h.
Definition at line 131 of file CGPSInterface.h.
bool mrpt::hwdrivers::CGPSInterface::m_useAIMMode [private] |
Use this mode for receive RTK corrections from a external source through the primary port.
Definition at line 179 of file CGPSInterface.h.
| Page generated by Doxygen 1.7.5 for MRPT 0.9.5 SVN: at Sun Oct 16 12:16:33 UTC 2011 |