ensenso_grabber.h
Go to the documentation of this file.
1 #ifndef __ENSENSO_ENSENSO_GRABBER__
2 #define __ENSENSO_ENSENSO_GRABBER__
3 
4 // PCL
5 #include <pcl/pcl_config.h>
6 #include <pcl/common/io.h>
7 #include <pcl/common/time.h>
8 #include <pcl/io/eigen.h>
9 #include <pcl/io/boost.h>
10 #include <pcl/io/grabber.h>
11 #include <pcl/common/synchronizer.h>
12 // Others
13 #include <Eigen/Geometry>
14 #include <boost/thread.hpp>
15 #include <sensor_msgs/CameraInfo.h>
16 #include <geometry_msgs/TransformStamped.h>
17 // Ensenso SDK
18 #include <nxLib.h>
19 namespace pcl
20 {
21 template <typename T>
22 struct PCLGenImage : PCLImage
23 {
24  std::vector<T> data;
27 };
28 
29 struct Transform
30 {
31  double tx, ty, tz, qx, qy, qz, qw;
32 };
37 class PCL_EXPORTS EnsensoGrabber : public Grabber
38 {
39  typedef std::pair<pcl::PCLGenImage<pcl::uint8_t>, pcl::PCLGenImage<pcl::uint8_t> > PairOfImages;
40 
41 public:
42  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
43 
47 
48  // Define callback signature typedefs
49  typedef void
50  (sig_cb_ensenso_point_cloud)(const pcl::PointCloud<pcl::PointXYZ>::Ptr &);
51 
52  typedef void
53  (sig_cb_ensenso_point_cloud_rgb)(const pcl::PointCloud<pcl::PointXYZRGBA>::Ptr &);
54 
55  typedef void
56  (sig_cb_ensenso_images)(const boost::shared_ptr<PairOfImages>&, const boost::shared_ptr<PairOfImages>&);
57 
58  typedef void
59  (sig_cb_ensenso_images_rgb)(const boost::shared_ptr<PairOfImages>&, const boost::shared_ptr<PairOfImages>&, const boost::shared_ptr<PairOfImages>&);
60 
61  typedef void
62  (sig_cb_ensenso_image_depth)(const boost::shared_ptr<pcl::PCLGenImage<float> >&);
63 
67  EnsensoGrabber ();
68 
70  virtual ~EnsensoGrabber () throw ();
71 
91  bool calibrateHandEye ( const std::vector<Eigen::Affine3d, Eigen::aligned_allocator<Eigen::Affine3d> > &robot_poses,
92  const Eigen::Affine3d &camera_seed,
93  const Eigen::Affine3d &pattern_seed,
94  const std::string setup,
95  Eigen::Affine3d &estimated_camera_pose,
96  Eigen::Affine3d &estimated_pattern_pose,
97  int &iterations,
98  double &reprojection_error) const;
99 
102  bool closeDevices ();
103 
108  bool closeTcpPort (void);
109 
114  int collectPattern (const bool buffer=true) const;
115 
118  double decodePattern () const;
119 
123  bool discardPatterns () const;
124 
127  int enumDevices () const;
128 
138  bool estimatePatternPose (Eigen::Affine3d &pose, const bool average=false) const;
139 
142  std::string getName () const;
143 
150  bool getCameraInfo(std::string cam, sensor_msgs::CameraInfo &cam_info) const;
151 
156  bool getTFLeftToRGB(Transform& tf) const;
157 
166  bool getLastCalibrationPattern (std::vector<int> &grid_size, double &grid_spacing,
167  std::vector<Eigen::Vector2d> &left_points,
168  std::vector<Eigen::Vector2d> &right_points,
169  Eigen::Affine3d &pose) const;
170 
172  float getFramesPerSecond () const;
173 
176  int getPatternCount () const;
177 
182  bool grabSingleCloud (pcl::PointCloud<pcl::PointXYZ> &cloud);
183 
186  bool isRunning () const;
187 
190  bool isTcpPortOpen () const;
191 
195  bool openDevice (std::string serial);
196 
197 
201  bool openMonoDevice (std::string serial);
202 
207  bool openTcpPort (const int port = 24000);
208 
211  bool restoreDefaultConfiguration () const;
212 
217  bool setEnableCUDA (const bool enable=true) const;
218 
222  bool setFindPattern (const bool enable=true);
223 
227  bool setUseRGB (const bool enable=true);
228 
232  bool setAutoBlackLevel (const bool enable=true) const;
233 
237  bool setAutoExposure (const bool enable=true) const;
238 
242  bool setAutoGain (const bool enable=true) const;
243 
252  bool setBinning (const int binning=1) const;
253 
259  bool setBlackLevelOffset (const float offset=1.0) const;
260 
266  bool setExposure (const float exposure=1.0) const;
267 
281  bool setFlexView (const bool enable=false, const int imagepairs=2) const;
282 
289  bool setFrontLight (const bool enable=false) const;
290 
296  bool setGain (const float gain=1.0) const;
297 
301  bool setGainBoost (const bool enable=false) const;
302 
306  bool setGridSpacing (const double grid_spacing) const;
307 
312  bool setHardwareGamma (const bool enable=true) const;
313 
318  bool setHdr (const bool enable=false) const;
319 
326  bool setMinimumDisparity (const int disparity=-64) const;
327 
334  bool setNumberOfDisparities (const int number=128) const;
335 
348  bool setOptimizationProfile (const std::string profile="AlignedAndDiagonal") const;
349 
356  bool setPixelClock (const int pixel_clock=24) const;
357 
363  bool setProjector (const bool enable=true) const;
364 
376  bool setScaling (const float scaling=1.0) const;
377 
381  bool setTargetBrightness (const int target=80) const;
382 
393  bool setTriggerMode (const std::string mode="Software") const;
394 
399  bool setRGBTriggerDelay (const float delay=10) const;
400 
405  bool setUseOpenGL (const bool enable) const;
406 
419  bool setUseDisparityMapAreaOfInterest (const bool enable=false) const;
420 
426  bool setDepthChangeCost(const int changecost) const;
427 
435  bool setDepthStepCost(const int stepcost) const;
436 
447  bool setShadowingThreshold(const int shadowingthreshold) const;
448 
455  bool setUniquenessRatio(const int ratio) const;
456 
464  bool setMedianFilterRadius(const int radius) const;
465 
476  bool setSpeckleComponentThreshold(const int threshold) const;
477 
484  bool setSpeckleRegionSize(const int threshold) const;
485 
491  bool setFillBorderSpread(const int maximumspread) const;
492 
498  bool setFillRegionSize(const int regionsize) const;
499 
503  bool setSurfaceConnectivity(const int threshold) const;
504 
509  bool setNearPlane(const int near);
510 
515  bool setFarPlane(const int far);
516 
517 
520  void start ();
521 
523  void stop ();
524 
527  void storeCalibrationPattern (const bool enable);
528 
529 protected:
531  boost::thread grabber_thread_;
532 
534  boost::signals2::signal<sig_cb_ensenso_point_cloud>* point_cloud_signal_;
535 
537  boost::signals2::signal<sig_cb_ensenso_point_cloud_rgb>* point_cloud_rgb_signal_;
538 
540  boost::signals2::signal<sig_cb_ensenso_images>* images_signal_;
541 
543  boost::signals2::signal<sig_cb_ensenso_images_rgb>* images_rgb_signal_;
544 
546  boost::signals2::signal<sig_cb_ensenso_image_depth>* image_depth_signal_;
547 
549  NxLibItem camera_;
550 
551  NxLibItem monocam_;
552 
554  boost::shared_ptr<const NxLibItem> root_;
555 
557  bool use_rgb_;
558 
560  bool find_pattern_;
561 
562 
564  bool device_open_;
565 
567  bool mono_device_open_;
568 
570  bool tcp_open_;
571 
573  Eigen::Affine3d last_pattern_pose_;
574 
576  std::string last_stereo_pattern_;
577 
579  bool store_calibration_pattern_;
580 
582  mutable boost::mutex pattern_mutex_;
583 
585  bool running_;
586 
588  int near_plane_;
589 
591  int far_plane_;
592 
594  float fps_;
595 
597  double timestamp_;
598 
600  Transform tf_left_to_rgb_;
601 
603  mutable boost::mutex fps_mutex_;
604 
612  pcl::uint64_t static getPCLStamp (const double ensenso_stamp);
613 
619  std::string static getOpenCVType (const int channels, const int bpe, const bool isFlt);
620 
626  bool jsonToMatrix (const std::string json, Eigen::Affine3d &matrix) const;
627 
634  bool matrixToJson (const Eigen::Affine3d &matrix, std::string &json, const bool pretty_format=true) const;
635 
639  void processGrabbing ();
640 
644  void triggerCameras();
645 
650  void getImage(const NxLibItem& image_node, pcl::PCLGenImage<pcl::uint8_t>& image_out);
651 
655  void getDepthDataRGB(const pcl::PointCloud<pcl::PointXYZRGBA>::Ptr& cloud, const pcl::PCLGenImage<float>::Ptr& depthimage);
656 
660  void getDepthData(const pcl::PointCloud<pcl::PointXYZ>::Ptr& cloud, const pcl::PCLGenImage<float>::Ptr& depthimage);
661 
662 };
663 } // namespace pcl
664 
665 #endif // __PCL_IO_ENSENSO_GRABBER__
666 
std::vector< T > data
sensor_msgs::PointCloud2 PointCloud
pcl::PointXYZRGBA PointXYZRGBA
std::pair< pcl::PCLGenImage< pcl::uint8_t >, pcl::PCLGenImage< pcl::uint8_t > > PairOfImages
Grabber for IDS-Imaging Ensenso&#39;s devices.
boost::shared_ptr< ::pcl::PCLGenImage< T > const > ConstPtr
pcl::PointXYZ PointXYZ
boost::shared_ptr< ::pcl::PCLGenImage< T > > Ptr


ensenso
Author(s): Francisco Suarez Ruiz
autogenerated on Sat Feb 16 2019 03:42:20