Main MRPT website > C++ reference
MRPT logo

CBoardDLMS.h

Go to the documentation of this file.
00001 /* +---------------------------------------------------------------------------+
00002    |          The Mobile Robot Programming Toolkit (MRPT) C++ library          |
00003    |                                                                           |
00004    |                   http://mrpt.sourceforge.net/                            |
00005    |                                                                           |
00006    |   Copyright (C) 2005-2011  University of Malaga                           |
00007    |                                                                           |
00008    |    This software was written by the Machine Perception and Intelligent    |
00009    |      Robotics Lab, University of Malaga (Spain).                          |
00010    |    Contact: Jose-Luis Blanco  <jlblanco@ctima.uma.es>                     |
00011    |                                                                           |
00012    |  This file is part of the MRPT project.                                   |
00013    |                                                                           |
00014    |     MRPT is free software: you can redistribute it and/or modify          |
00015    |     it under the terms of the GNU General Public License as published by  |
00016    |     the Free Software Foundation, either version 3 of the License, or     |
00017    |     (at your option) any later version.                                   |
00018    |                                                                           |
00019    |   MRPT is distributed in the hope that it will be useful,                 |
00020    |     but WITHOUT ANY WARRANTY; without even the implied warranty of        |
00021    |     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         |
00022    |     GNU General Public License for more details.                          |
00023    |                                                                           |
00024    |     You should have received a copy of the GNU General Public License     |
00025    |     along with MRPT.  If not, see <http://www.gnu.org/licenses/>.         |
00026    |                                                                           |
00027    +---------------------------------------------------------------------------+ */
00028 
00029 #ifndef CBoardDLMS_H
00030 #define CBoardDLMS_H
00031 
00032 #include <mrpt/hwdrivers/CGenericSensor.h>
00033 #include <mrpt/hwdrivers/CInterfaceFTDIMessages.h>
00034 #include <mrpt/utils/CConfigFileBase.h>
00035 #include <mrpt/poses/CPose3D.h>
00036 
00037 namespace mrpt
00038 {
00039         namespace hwdrivers
00040         {
00041                 /** An interface to a custom board which interfaces two SICK laser scanners.
00042                   *  Implemented for the board v1.0 designed by 2008 @ ISA (University of Malaga).
00043                   *
00044                   *  \code
00045                   *  PARAMETERS IN THE ".INI"-LIKE CONFIGURATION STRINGS:
00046                   * -------------------------------------------------------
00047                   *   [DualLMS]
00048                   *        driver                       = CBoardDLMS
00049                   *        process_rate         = 30            ; Hz
00050                   *    USB_serialname   = DLMS-001
00051                   *
00052                   *    mPose_x                  = 0     ; Master laser range scaner 6D position on the robot (meters)
00053                   *        mPose_y                      = 0
00054           *    mPose_z                  = 0
00055                   *    mPose_yaw                = 0
00056                   *    mPose_pitch              = 0
00057                   *    mPose_roll               = 0
00058                   *
00059                   *    sPose_x                  = 0     ; Slave laser range scaner 6D position on the robot (meters)
00060                   *        sPose_y                      = 0
00061           *    sPose_z                  = 0
00062                   *    sPose_yaw                = 0
00063                   *    sPose_pitch              = 0
00064                   *    sPose_roll               = 0
00065                   *  \endcode
00066                   *
00067                   */
00068                 class HWDRIVERS_IMPEXP CBoardDLMS : public hwdrivers::CInterfaceFTDIMessages, public CGenericSensor
00069                 {
00070                         DEFINE_GENERIC_SENSOR(CBoardDLMS)
00071                 protected:
00072                         /** A copy of the device serial number (to open the USB FTDI chip)
00073                           */
00074                         std::string                                     m_usbSerialNumber;
00075                         uint32_t                                        m_timeStartUI;
00076                         mrpt::system::TTimeStamp        m_timeStartTT;
00077 
00078                         mrpt::poses::CPose3D            m_mSensorPose, m_sSensorPose;
00079 
00080                         /** Tries to connect to the USB device (if disconnected).
00081                           * \return True on connection OK, false on error.
00082                           */
00083                         bool    checkConnectionAndConnect();
00084 
00085                         bool    checkCRC( const std::vector<unsigned char> &frame );
00086 
00087                         /** 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)
00088                           *  See hwdrivers::CBoardDLMS for the possible parameters
00089                           */
00090                         void  loadConfig_sensorSpecific(
00091                                 const mrpt::utils::CConfigFileBase &configSource,
00092                                 const std::string         &iniSection );
00093 
00094                 public:
00095                         /** Constructor
00096                           * \param serialNumberUSBdevice The serial number (text) of the device to open.
00097                           *  The constructor will try to open the device. You can check if it failed calling "isOpen()".
00098                           */
00099                         CBoardDLMS( );
00100 
00101                         /** Destructor
00102                           */
00103                         virtual ~CBoardDLMS();
00104 
00105                         /** This method should be called periodically (at least at 1Hz to capture ALL the real-time data)
00106                         *  It is thread safe, i.e. you can call this from one thread, then to other methods from other threads.
00107                         *  This method processes data from the GPS and update the object state accordingly.
00108                         */
00109                         void  doProcess();
00110 
00111                         /** This method can or cannot be implemented in the derived class, depending on the need for it.
00112                           *  \exception This method must throw an exception with a descriptive message if some critical error is found.
00113                           */
00114                         virtual void initialize();
00115 
00116                         /** Query the firmware version on the device (can be used to test communications).
00117                           * \return true on success, false on communications errors or device not found.
00118                           */
00119                         bool queryFirmwareVersion( std::string &out_firmwareVersion );
00120 
00121                         /** Send a command to the DLMS Board
00122                           * \return true on success, false on communications errors or device not found.
00123                           */
00124                         bool sendCommand( uint8_t command, std::vector<unsigned char> &response );
00125 
00126                         bool queryTimeStamp( mrpt::system::TTimeStamp &tstamp );
00127 
00128                 }; // end of class
00129 
00130         } // end of namespace
00131 } // End of namespace
00132 
00133 #endif



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