Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef SCANNERSICKS300_INCLUDEDEF_H
00019 #define SCANNERSICKS300_INCLUDEDEF_H
00020
00021
00022
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
00045 struct ParamType
00046 {
00047 int range_field;
00048 double dScale;
00049 double dStartAngle;
00050 double dStopAngle;
00051 };
00052
00053
00054 struct ScanPolarType
00055 {
00056 double dr;
00057 double da;
00058 double di;
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
00069 ScannerSickS300();
00070
00071
00072 ~ScannerSickS300();
00073
00080 bool open(const char* pcPort, int iBaudRate, int iScanId);
00081
00082
00083 void resetStartup();
00084
00085
00086 void startScanner();
00087
00088
00089 void stopScanner();
00090
00091
00092
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 ¶m) {m_Params[field] = param;}
00100
00101 private:
00102
00103
00104 static const double c_dPi;
00105
00106
00107 typedef std::map<int, ParamType> PARAM_MAP;
00108 PARAM_MAP m_Params;
00109 double m_dBaudMult;
00110
00111
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
00122 SerialIO m_SerialIO;
00123 TelegramParser tp_;
00124
00125
00126 void convertScanToPolar(const PARAM_MAP::const_iterator param, std::vector<int> viScanRaw,
00127 std::vector<ScanPolarType>& vecScanPolar);
00128
00129 };
00130
00131
00132 #endif