YDLIDAR X2 SDK  V1.4.1
CYdLidar.h
1 
2 #pragma once
3 #include "utils.h"
4 #include "ydlidar_driver.h"
5 #include <math.h>
6 
7 
8 #define PropertyBuilderByName(type, name, access_permission)\
9  access_permission:\
10  type m_##name;\
11  public:\
12  inline void set##name(type v) {\
13  m_##name = v;\
14  }\
15  inline type get##name() {\
16  return m_##name;\
17 }\
18 
19 
20 using namespace ydlidar;
21 
22 class YDLIDAR_API CYdLidar {
23  PropertyBuilderByName(float, MaxRange,
24  private)
25  PropertyBuilderByName(float, MinRange,
26  private)
27  PropertyBuilderByName(float, MaxAngle,
28  private)
29  PropertyBuilderByName(float, MinAngle,
30  private)
31  PropertyBuilderByName(float, OffsetTime, private)
32 
33  PropertyBuilderByName(bool, FixedResolution,
34  private)
35  PropertyBuilderByName(bool, Reversion,
36  private)
37  PropertyBuilderByName(bool, AutoReconnect,
38  private)
39  PropertyBuilderByName(bool, GlassNoise,
40  private)
41  PropertyBuilderByName(bool, SunNoise, private)
42 
43  PropertyBuilderByName(int, SerialBaudrate,
44  private)
45  PropertyBuilderByName(std::string, SerialPort,
46  private)
47  PropertyBuilderByName(std::vector<float>, IgnoreArray,
48  private)
49  PropertyBuilderByName(int, AbnormalCheckCount,
50  private)
51 
52 
53  public:
54  CYdLidar();
55  virtual ~CYdLidar();
56 
57  bool initialize();
58 
59  // Return true if laser data acquistion succeeds, If it's not
60  bool doProcessSimple(LaserScan &scan_msg, bool &hardwareError);
61 
62  //Turn on the motor enable
63  bool turnOn();
64  //Turn off the motor enable and close the scan
65  bool turnOff();
66 
67  //get fixed resolution node size
68  int getFixedSize() const;
69 
71  bool getDeviceHealth() const;
72 
74  bool getDeviceInfo(int &type);
75 
77  bool checkHeartBeat() const;
78 
80  bool checkScanFrequency();
81 
82  //Turn off lidar connection
83  void disconnecting();
84 
85  protected:
90  bool checkCOMMs();
91 
95  bool checkStatus();
96 
100  bool checkHardware();
101 
103  bool checkLidarAbnormal();
104 
105 
106 
107  private:
108  bool isScanning;
109  bool isConnected;
110  YDlidarDriver *lidarPtr;
111 
112  uint32_t m_pointTime;
113  uint64_t last_node_time;
114  int m_FixedSize;
115 
116 }; // End of class
117 
Definition: v8stdint.h:199
Definition: ydlidar_protocol.h:148
Definition: ydlidar_driver.h:21
Definition: CYdLidar.h:22