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
00033
00034
00035
00036
00037
00038
00039
00040 #ifndef PCL_IO_DINAST_GRABBER_
00041 #define PCL_IO_DINAST_GRABBER_
00042
00043 #include <pcl/point_types.h>
00044 #include <pcl/point_cloud.h>
00045 #include <pcl/io/grabber.h>
00046 #include <pcl/common/time.h>
00047 #include <pcl/console/print.h>
00048 #include <libusb-1.0/libusb.h>
00049 #include <boost/circular_buffer.hpp>
00050
00051 namespace pcl
00052 {
00057 class PCL_EXPORTS DinastGrabber: public Grabber
00058 {
00059
00060 typedef void (sig_cb_dinast_point_cloud) (const boost::shared_ptr<const pcl::PointCloud<pcl::PointXYZI> >&);
00061
00062 public:
00066 DinastGrabber (const int device_position=1);
00067
00069 virtual ~DinastGrabber () throw ();
00070
00074 virtual bool
00075 isRunning () const;
00076
00080 virtual std::string
00081 getName () const
00082 { return (std::string ("DinastGrabber")); }
00083
00086 virtual void
00087 start ();
00088
00091 virtual void
00092 stop ();
00093
00095 virtual float
00096 getFramesPerSecond () const;
00097
00100 std::string
00101 getDeviceVersion ();
00102
00103 protected:
00104
00106 void
00107 onInit (const int device_id);
00108
00114 void
00115 setupDevice (int device_position,
00116 const int id_vendor = 0x18d1,
00117 const int id_product = 0x1402);
00118
00123 bool
00124 USBRxControlData (const unsigned char req_code,
00125 unsigned char *buffer,
00126 int length);
00127
00132 bool
00133 USBTxControlData (const unsigned char req_code,
00134 unsigned char *buffer,
00135 int length);
00136
00142 int
00143 checkHeader ();
00144
00147 void
00148 readImage ();
00149
00153 pcl::PointCloud<pcl::PointXYZI>::Ptr
00154 getXYZIPointCloud ();
00155
00158 void
00159 captureThreadFunction ();
00160
00162 int image_width_;
00163
00165 int image_height_;
00166
00168 int image_size_;
00169
00171 int sync_packet_size_;
00172
00173 double dist_max_2d_;
00174
00176 double fov_;
00177
00179 enum pixel_size { RAW8=1, RGB16=2, RGB24=3, RGB32=4 };
00180
00182 libusb_context *context_;
00183
00185 struct libusb_device_handle *device_handle_;
00186
00190 unsigned char *raw_buffer_ ;
00191
00193 boost::circular_buffer<unsigned char> g_buffer_;
00194
00196 unsigned char bulk_ep_;
00197
00199 enum { CMD_READ_START=0xC7, CMD_READ_STOP=0xC8, CMD_GET_VERSION=0xDC, CMD_SEND_DATA=0xDE };
00200
00201 unsigned char *image_;
00202
00204 bool second_image_;
00205
00206 bool running_;
00207
00208 boost::thread capture_thread_;
00209
00210 mutable boost::mutex capture_mutex_;
00211 boost::signals2::signal<sig_cb_dinast_point_cloud>* point_cloud_signal_;
00212 };
00213 }
00214
00215 #endif // PCL_IO_DINAST_GRABBER_