ScannerSickS300.h
Go to the documentation of this file.
00001 /****************************************************************
00002  *
00003  * Copyright (c) 2010
00004  *
00005  * Fraunhofer Institute for Manufacturing Engineering   
00006  * and Automation (IPA)
00007  *
00008  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00009  *
00010  * Project name: care-o-bot
00011  * ROS stack name: cob_driver
00012  * ROS package name: cob_sick_s300
00013  * Description:
00014  *                                                              
00015  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00016  *                      
00017  * Author: Christian Connette, email:christian.connette@ipa.fhg.de
00018  * Supervised by: Christian Connette, email:christian.connette@ipa.fhg.de
00019  *
00020  * Date of creation: Jan 2009
00021  * ToDo:
00022  *
00023  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00024  *
00025  * Redistribution and use in source and binary forms, with or without
00026  * modification, are permitted provided that the following conditions are met:
00027  *
00028  *     * Redistributions of source code must retain the above copyright
00029  *       notice, this list of conditions and the following disclaimer.
00030  *     * Redistributions in binary form must reproduce the above copyright
00031  *       notice, this list of conditions and the following disclaimer in the
00032  *       documentation and/or other materials provided with the distribution.
00033  *     * Neither the name of the Fraunhofer Institute for Manufacturing 
00034  *       Engineering and Automation (IPA) nor the names of its
00035  *       contributors may be used to endorse or promote products derived from
00036  *       this software without specific prior written permission.
00037  *
00038  * This program is free software: you can redistribute it and/or modify
00039  * it under the terms of the GNU Lesser General Public License LGPL as 
00040  * published by the Free Software Foundation, either version 3 of the 
00041  * License, or (at your option) any later version.
00042  * 
00043  * This program is distributed in the hope that it will be useful,
00044  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00045  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00046  * GNU Lesser General Public License LGPL for more details.
00047  * 
00048  * You should have received a copy of the GNU Lesser General Public 
00049  * License LGPL along with this program. 
00050  * If not, see <http://www.gnu.org/licenses/>.
00051  *
00052  ****************************************************************/
00053 
00054 #ifndef SCANNERSICKS300_INCLUDEDEF_H
00055 #define SCANNERSICKS300_INCLUDEDEF_H
00056 //-----------------------------------------------
00057 
00058 // base classes
00059 #include <string>
00060 #include <vector>
00061 #include <map>
00062 #include <iostream>
00063 #include <math.h>
00064 #include <stdio.h>
00065 
00066 #include <cob_sick_s300/SerialIO.h>
00067 #include <cob_sick_s300/TelegramS300.h>
00068 
00106 class ScannerSickS300
00107 {
00108 public:
00109 
00110         // set of parameters which are specific to the SickS300
00111         struct ParamType
00112         {
00113                 int range_field; //measurement range (1 to 5) --> usually 1 (default)
00114                 double dScale;          // scaling of the scan (multiply with to get scan in meters)
00115                 double dStartAngle;     // scan start angle
00116                 double dStopAngle;      // scan stop angle
00117         };
00118 
00119         // storage container for received scanner data
00120         struct ScanPolarType
00121         {
00122                 double dr; // distance //r;
00123                 double da; // angle //a;
00124                 double di; // intensity; //bool bGlare;
00125         };
00126 
00127         enum
00128         {
00129                 SCANNER_S300_READ_BUF_SIZE = 10000,
00130                 READ_BUF_SIZE = 10000,
00131                 WRITE_BUF_SIZE = 10000
00132         };
00133 
00134         // Constructor
00135         ScannerSickS300();
00136 
00137         // Destructor
00138         ~ScannerSickS300();
00139 
00146         bool open(const char* pcPort, int iBaudRate, int iScanId);
00147 
00148         // not implemented
00149         void resetStartup();
00150 
00151         // not implmented
00152         void startScanner();
00153 
00154         // not implemented
00155         void stopScanner();
00156         //sick_lms.Uninitialize();
00157 
00158         // whether the scanner is currently in Standby or not
00159         bool isInStandby() {return m_bInStandby;};
00160 
00161         void purgeScanBuf();
00162 
00163         bool getScan(std::vector<double> &vdDistanceM, std::vector<double> &vdAngleRAD, std::vector<double> &vdIntensityAU, unsigned int &iTimestamp, unsigned int &iTimeNow, const bool debug);
00164 
00165         void setRangeField(const int field, const ParamType &param) {m_Params[field] = param;}
00166 
00167 private:
00168 
00169         // Constants
00170         static const double c_dPi;
00171 
00172         // Parameters
00173         typedef std::map<int, ParamType> PARAM_MAP;
00174         PARAM_MAP m_Params;
00175         double m_dBaudMult;
00176 
00177         // Variables
00178         unsigned char m_ReadBuf[READ_BUF_SIZE+10];
00179         unsigned char m_ReadBuf2[READ_BUF_SIZE+10];
00180         unsigned int m_uiSumReadBytes;
00181         std::vector<int> m_viScanRaw;
00182         int m_iPosReadBuf2;
00183         static unsigned char m_iScanId;
00184         int m_actualBufferSize;
00185         bool m_bInStandby;
00186 
00187         // Components
00188         SerialIO m_SerialIO;
00189         TelegramParser tp_;
00190 
00191         // Functions
00192         void convertScanToPolar(const PARAM_MAP::const_iterator param, std::vector<int> viScanRaw,
00193                                                         std::vector<ScanPolarType>& vecScanPolar);
00194 
00195 };
00196 
00197 //-----------------------------------------------
00198 #endif


cob_sick_s300
Author(s): Florian Weisshardt
autogenerated on Thu Aug 27 2015 12:45:42