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
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef SWISSRANGER_HH
00033 #define SWISSRANGER_HH
00034
00035 #include <stdexcept>
00036 #include <stdio.h>
00037 #include <stdlib.h>
00038 #include <string>
00039 #include <string.h>
00040
00041 #include <opencv/cv.h>
00042
00043
00044 #define DWORD unsigned int
00045
00046 #define SR_IMG_DISTANCE 0
00047 #define SR_IMG_AMPLITUDE 1
00048 #define SR_IMG_CONFIDENCE 2
00049
00050 #include <libusbSR.h>
00051
00052
00053 #include "std_msgs/PointCloud.h"
00054 #include "std_msgs/ImageArray.h"
00055 #include "ros/common.h"
00056
00057
00058 #define MODE (AM_CONF_MAP | AM_COR_FIX_PTRN | AM_SW_ANF | AM_MEDIAN | AM_DENOISE_ANF | AM_MEDIANCROSS | AM_CONV_GRAY)// | AM_SHORT_RANGE)
00059
00060 namespace swissranger
00061 {
00063
00064 #define DEF_EXCEPTION(name, parent) \
00065 class name : public parent { \
00066 public: \
00067 name (const char* msg) : parent (msg) {} \
00068 }
00069
00071 DEF_EXCEPTION(Exception, std::runtime_error);
00072
00073 const unsigned int SR_COLS = 176;
00074 const unsigned int SR_ROWS = 144;
00075
00076 class SwissRanger
00077 {
00078 public:
00079 SwissRanger ();
00080 ~SwissRanger ();
00081
00082 int open ();
00083 int close ();
00084
00085 void readData (std_msgs::PointCloud &cloud, std_msgs::ImageArray &images);
00086
00087 int setAutoIllumination (bool on);
00088 int setIntegrationTime (int time);
00089 int getIntegrationTime ();
00090 int setModulationFrequency (int freq);
00091 int getModulationFrequency ();
00092 int setAmplitudeThreshold (int thresh);
00093 int getAmplitudeThreshold ();
00094
00095
00096 unsigned int rows_, cols_, inr_;
00097 std::string device_id_;
00098 std::string lib_version_;
00099
00100
00101 bool getPCDFilter () { return this->pcd_filter_; }
00102 void setPCDFilter (bool filter) { this->pcd_filter_ = filter; }
00103
00104 bool getUndistortImage (int img_type)
00105 {
00106 switch (img_type)
00107 {
00108 case SR_IMG_DISTANCE: return (this->undistort_distance_);
00109 case SR_IMG_AMPLITUDE: return (this->undistort_amplitude_);
00110 case SR_IMG_CONFIDENCE: return (this->undistort_confidence_);
00111 }
00112 }
00113 void setUndistortImage (int img_type, bool filter)
00114 {
00115 switch (img_type)
00116 {
00117 case SR_IMG_DISTANCE: { this->undistort_distance_ = filter; break; }
00118 case SR_IMG_AMPLITUDE: { this->undistort_amplitude_ = filter; break; }
00119 case SR_IMG_CONFIDENCE: { this->undistort_confidence_ = filter; break; }
00120 }
00121 }
00122
00123 private:
00124
00125 CMesaDevice* srCam_;
00126
00127 ImgEntry* imgEntryArray_;
00128 float *buffer_, *xp_, *yp_, *zp_;
00129
00130 int integration_time_, modulation_freq_;
00131
00132 std::string getDeviceString ();
00133 std::string getLibraryVersion ();
00134
00135
00136 void rotateImage180 (uint8_t *img, uint8_t *rot_img, int width, int height);
00137
00138
00139 CvMat *intrinsic_, *distortion_;
00140 void undistort (uint8_t *img, uint8_t *un_img, int width, int height);
00141 void contours (uint8_t *img, uint8_t *con_img, int width, int height, int threshold);
00142 double getAngle (float px, float py, float pz, float qx, float qy, float qz);
00143
00144 bool pcd_filter_;
00145 bool undistort_distance_, undistort_amplitude_, undistort_confidence_;
00146 };
00147 };
00148
00149 #endif