ScannerSickS300.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *   http://www.apache.org/licenses/LICENSE-2.0
00009 
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016  
00017 
00018 #ifndef SCANNERSICKS300_INCLUDEDEF_H
00019 #define SCANNERSICKS300_INCLUDEDEF_H
00020 //-----------------------------------------------
00021 
00022 // base classes
00023 #include <string>
00024 #include <vector>
00025 #include <map>
00026 #include <iostream>
00027 #include <math.h>
00028 #include <stdio.h>
00029 
00030 #include <cob_sick_s300/SerialIO.h>
00031 #include <cob_sick_s300/TelegramS300.h>
00032 
00040 class ScannerSickS300
00041 {
00042 public:
00043 
00044         // set of parameters which are specific to the SickS300
00045         struct ParamType
00046         {
00047                 int range_field; //measurement range (1 to 5) --> usually 1 (default)
00048                 double dScale;          // scaling of the scan (multiply with to get scan in meters)
00049                 double dStartAngle;     // scan start angle
00050                 double dStopAngle;      // scan stop angle
00051         };
00052 
00053         // storage container for received scanner data
00054         struct ScanPolarType
00055         {
00056                 double dr; // distance //r;
00057                 double da; // angle //a;
00058                 double di; // intensity; //bool bGlare;
00059         };
00060 
00061         enum
00062         {
00063                 SCANNER_S300_READ_BUF_SIZE = 10000,
00064                 READ_BUF_SIZE = 10000,
00065                 WRITE_BUF_SIZE = 10000
00066         };
00067 
00068         // Constructor
00069         ScannerSickS300();
00070 
00071         // Destructor
00072         ~ScannerSickS300();
00073 
00080         bool open(const char* pcPort, int iBaudRate, int iScanId);
00081 
00082         // not implemented
00083         void resetStartup();
00084 
00085         // not implmented
00086         void startScanner();
00087 
00088         // not implemented
00089         void stopScanner();
00090         //sick_lms.Uninitialize();
00091 
00092         // whether the scanner is currently in Standby or not
00093         bool isInStandby() {return m_bInStandby;}
00094 
00095         void purgeScanBuf();
00096 
00097         bool getScan(std::vector<double> &vdDistanceM, std::vector<double> &vdAngleRAD, std::vector<double> &vdIntensityAU, unsigned int &iTimestamp, unsigned int &iTimeNow, const bool debug);
00098 
00099         void setRangeField(const int field, const ParamType &param) {m_Params[field] = param;}
00100 
00101 private:
00102 
00103         // Constants
00104         static const double c_dPi;
00105 
00106         // Parameters
00107         typedef std::map<int, ParamType> PARAM_MAP;
00108         PARAM_MAP m_Params;
00109         double m_dBaudMult;
00110 
00111         // Variables
00112         unsigned char m_ReadBuf[READ_BUF_SIZE+10];
00113         unsigned char m_ReadBuf2[READ_BUF_SIZE+10];
00114         unsigned int m_uiSumReadBytes;
00115         std::vector<int> m_viScanRaw;
00116         int m_iPosReadBuf2;
00117         static unsigned char m_iScanId;
00118         int m_actualBufferSize;
00119         bool m_bInStandby;
00120 
00121         // Components
00122         SerialIO m_SerialIO;
00123         TelegramParser tp_;
00124 
00125         // Functions
00126         void convertScanToPolar(const PARAM_MAP::const_iterator param, std::vector<int> viScanRaw,
00127                                                         std::vector<ScanPolarType>& vecScanPolar);
00128 
00129 };
00130 
00131 //-----------------------------------------------
00132 #endif


cob_sick_s300
Author(s): Florian Weisshardt
autogenerated on Sat Jun 8 2019 21:02:23