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://www.mrpt.org/                                |
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                   * \ingroup mrpt_hwdrivers_grp
00068                   */
00069                 class HWDRIVERS_IMPEXP CBoardDLMS : public hwdrivers::CInterfaceFTDIMessages, public CGenericSensor
00070                 {
00071                         DEFINE_GENERIC_SENSOR(CBoardDLMS)
00072                 protected:
00073                         /** A copy of the device serial number (to open the USB FTDI chip)
00074                           */
00075                         std::string                                     m_usbSerialNumber;
00076                         uint32_t                                        m_timeStartUI;
00077                         mrpt::system::TTimeStamp        m_timeStartTT;
00078 
00079                         mrpt::poses::CPose3D            m_mSensorPose, m_sSensorPose;
00080 
00081                         /** Tries to connect to the USB device (if disconnected).
00082                           * \return True on connection OK, false on error.
00083                           */
00084                         bool    checkConnectionAndConnect();
00085 
00086                         bool    checkCRC( const std::vector<unsigned char> &frame );
00087 
00088                         /** 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)
00089                           *  See hwdrivers::CBoardDLMS for the possible parameters
00090                           */
00091                         void  loadConfig_sensorSpecific(
00092                                 const mrpt::utils::CConfigFileBase &configSource,
00093                                 const std::string         &iniSection );
00094 
00095                 public:
00096                         /** Constructor
00097                           * \param serialNumberUSBdevice The serial number (text) of the device to open.
00098                           *  The constructor will try to open the device. You can check if it failed calling "isOpen()".
00099                           */
00100                         CBoardDLMS( );
00101 
00102                         /** Destructor
00103                           */
00104                         virtual ~CBoardDLMS();
00105 
00106                         /** This method should be called periodically (at least at 1Hz to capture ALL the real-time data)
00107                         *  It is thread safe, i.e. you can call this from one thread, then to other methods from other threads.
00108                         *  This method processes data from the GPS and update the object state accordingly.
00109                         */
00110                         void  doProcess();
00111 
00112                         /** This method can or cannot be implemented in the derived class, depending on the need for it.
00113                           *  \exception This method must throw an exception with a descriptive message if some critical error is found.
00114                           */
00115                         virtual void initialize();
00116 
00117                         /** Query the firmware version on the device (can be used to test communications).
00118                           * \return true on success, false on communications errors or device not found.
00119                           */
00120                         bool queryFirmwareVersion( std::string &out_firmwareVersion );
00121 
00122                         /** Send a command to the DLMS Board
00123                           * \return true on success, false on communications errors or device not found.
00124                           */
00125                         bool sendCommand( uint8_t command, std::vector<unsigned char> &response );
00126 
00127                         bool queryTimeStamp( mrpt::system::TTimeStamp &tstamp );
00128 
00129                 }; // end of class
00130 
00131         } // end of namespace
00132 } // End of namespace
00133 
00134 #endif



Page generated by Doxygen 1.7.5 for MRPT 0.9.5 SVN: at Thu Oct 13 21:25:36 UTC 2011