pangolinViewer.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. //
  2. // Created by zx on 22-12-2.
  3. //
  4. #ifndef LIO_LIVOX_CPP__PANGOLINVIEWER_H_
  5. #define LIO_LIVOX_CPP__PANGOLINVIEWER_H_
  6. #include <pangolin/var/var.h>
  7. #include <pangolin/var/varextra.h>
  8. #include <pangolin/gl/gl.h>
  9. #include <pangolin/gl/gldraw.h>
  10. #include <pangolin/display/display.h>
  11. #include <pangolin/display/view.h>
  12. #include <pangolin/display/widgets.h>
  13. #include <pangolin/display/default_font.h>
  14. #include <pangolin/handler/handler.h>
  15. #include "segment/LidarFeatureExtractor.h"
  16. #include <thread>
  17. #include "define/typedef.h"
  18. class PangolinViewer
  19. {
  20. public:
  21. typedef void(*ViewerSpinOnceCallback)(PangolinViewer*);
  22. typedef void(*StartLocateBtnCallback)(std::string);
  23. typedef void(*StartBtnCallback)();
  24. typedef void(*StopBtnCallback)();
  25. typedef void(*FreqChangedCallback)(int);
  26. public:
  27. static PangolinViewer* CreateViewer();
  28. void SetCallbacks(ViewerSpinOnceCallback spinOnce,StartLocateBtnCallback startBtn,
  29. StopBtnCallback stopBtn,FreqChangedCallback freqChanged);
  30. void ShowRealtimePose(Eigen::Matrix4d pose);
  31. void ShowSlamCost(double cost);
  32. void ShowSlamQueueTime(int queue,double tm);
  33. void DrawCloud(PointCloud::Ptr cloud,double r,double g,double b,
  34. double alpha,double psize);
  35. void Join();
  36. ~PangolinViewer();
  37. private:
  38. static void loop(PangolinViewer* p);
  39. PangolinViewer();
  40. void Init();
  41. protected:
  42. static PangolinViewer* viewer_;
  43. std::thread* thread_;
  44. pangolin::GlFont *text_font_ ;
  45. pangolin::OpenGlRenderState* s_cam_;
  46. pangolin::View *d_cam_ ;
  47. pangolin::Var<bool>* lvx_checkbox_;
  48. pangolin::Var<std::string>* lvx_file_;
  49. pangolin::Var<bool>* start_button_;
  50. pangolin::Var<bool>* stop_button_;
  51. pangolin::Var<double>* freq_double_;
  52. pangolin::Var<std::string>* timequeue_string_;
  53. pangolin::Var<std::string>* xyz_string_;
  54. pangolin::Var<std::string>* rpy_string_;
  55. pangolin::Var<std::string>* cost_string_;
  56. ViewerSpinOnceCallback spinOnce_callback_=nullptr;
  57. StartLocateBtnCallback startBtn_callback_=nullptr;
  58. StopBtnCallback stopBtn_callback_= nullptr;
  59. FreqChangedCallback freqChanged_callback_= nullptr;
  60. };
  61. #endif //LIO_LIVOX_CPP__PANGOLINVIEWER_H_