lds_lidar.h
Go to the documentation of this file.
1 //
2 // The MIT License (MIT)
3 //
4 // Copyright (c) 2019 Livox. All rights reserved.
5 //
6 // Permission is hereby granted, free of charge, to any person obtaining a copy
7 // of this software and associated documentation files (the "Software"), to deal
8 // in the Software without restriction, including without limitation the rights
9 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 // copies of the Software, and to permit persons to whom the Software is
11 // furnished to do so, subject to the following conditions:
12 //
13 // The above copyright notice and this permission notice shall be included in
14 // all copies or substantial portions of the Software.
15 //
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 // SOFTWARE.
23 //
24 
27 #ifndef LIVOX_ROS_DRIVER_LDS_LIDAR_H_
28 #define LIVOX_ROS_DRIVER_LDS_LIDAR_H_
29 
30 #include <memory>
31 #include <mutex>
32 #include <vector>
33 
34 #include "lds.h"
35 #include "livox_sdk.h"
36 #include "rapidjson/document.h"
37 #include "timesync.h"
38 
39 namespace livox_ros {
40 
44 class LdsLidar : public Lds {
45  public:
46  static LdsLidar *GetInstance(uint32_t interval_ms) {
47  static LdsLidar lds_lidar(interval_ms);
48  return &lds_lidar;
49  }
50 
51  int InitLdsLidar(std::vector<std::string> &broadcast_code_strs,
52  const char *user_config_path);
53  int DeInitLdsLidar(void);
54 
55  private:
56  LdsLidar(uint32_t interval_ms);
57  LdsLidar(const LdsLidar &) = delete;
58  ~LdsLidar();
59  LdsLidar &operator=(const LdsLidar &) = delete;
60  virtual void PrepareExit(void);
61 
62  static void OnLidarDataCb(uint8_t handle, LivoxEthPacket *data,
63  uint32_t data_num, void *client_data);
64  static void OnDeviceBroadcast(const BroadcastDeviceInfo *info);
65  static void OnDeviceChange(const DeviceInfo *info, DeviceEvent type);
66  static void StartSampleCb(livox_status status, uint8_t handle,
67  uint8_t response, void *clent_data);
68  static void StopSampleCb(livox_status status, uint8_t handle,
69  uint8_t response, void *clent_data);
70  static void DeviceInformationCb(livox_status status, uint8_t handle,
71  DeviceInformationResponse *ack,
72  void *clent_data);
73  static void LidarErrorStatusCb(livox_status status, uint8_t handle,
74  ErrorMessage *message);
75  static void ControlFanCb(livox_status status, uint8_t handle,
76  uint8_t response, void *clent_data);
77  static void SetPointCloudReturnModeCb(livox_status status, uint8_t handle,
78  uint8_t response, void *clent_data);
79  static void SetCoordinateCb(livox_status status, uint8_t handle,
80  uint8_t response, void *clent_data);
81  static void SetImuRatePushFrequencyCb(livox_status status, uint8_t handle,
82  uint8_t response, void *clent_data);
83  static void SetRmcSyncTimeCb(livox_status status, uint8_t handle,
84  uint8_t response, void *client_data);
85  static void ReceiveSyncTimeCallback(const char *rmc, uint32_t rmc_length,
86  void *client_data);
87  static void GetLidarExtrinsicParameterCb(
88  livox_status status, uint8_t handle,
89  LidarGetExtrinsicParameterResponse *response, void *clent_data);
90  static void SetHighSensitivityCb(livox_status status, uint8_t handle,
91  DeviceParameterResponse *response,
92  void *clent_data);
93 
94  void ResetLdsLidar(void);
95  int AddBroadcastCodeToWhitelist(const char *broadcast_code);
96  bool IsBroadcastCodeExistInWhitelist(const char *broadcast_code);
97 
100  bool IsAutoConnectMode(void) { return auto_connect_mode_; }
102  int ParseConfigFile(const char *pathname);
103  int AddRawUserConfig(UserRawConfig &config);
104  bool IsExistInRawConfig(const char *broadcast_code);
105  int GetRawConfig(const char *broadcast_code, UserRawConfig &config);
106 
109  volatile bool is_initialized_;
110  char broadcast_code_whitelist_[kMaxLidarCount][kBroadcastCodeSize];
111  std::vector<UserRawConfig> raw_config_;
112 
116  std::mutex config_mutex_;
117 };
118 
119 } // namespace livox_ros
120 #endif
static void SetImuRatePushFrequencyCb(livox_status status, uint8_t handle, uint8_t response, void *clent_data)
Definition: lds_lidar.cpp:405
static void SetRmcSyncTimeCb(livox_status status, uint8_t handle, uint8_t response, void *client_data)
Definition: lds_lidar.cpp:529
void ResetLdsLidar(void)
Definition: lds_lidar.cpp:60
std::vector< UserRawConfig > raw_config_
Definition: lds_lidar.h:111
int GetRawConfig(const char *broadcast_code, UserRawConfig &config)
Definition: lds_lidar.cpp:759
LdsLidar & operator=(const LdsLidar &)=delete
TimeSync * timesync_
Definition: lds_lidar.h:114
static void SetCoordinateCb(livox_status status, uint8_t handle, uint8_t response, void *clent_data)
Definition: lds_lidar.cpp:376
static void OnDeviceChange(const DeviceInfo *info, DeviceEvent type)
Definition: lds_lidar.cpp:228
std::mutex config_mutex_
Definition: lds_lidar.h:116
static void SetPointCloudReturnModeCb(livox_status status, uint8_t handle, uint8_t response, void *clent_data)
Definition: lds_lidar.cpp:350
unsigned char uint8_t
Definition: stdint.h:125
static void OnDeviceBroadcast(const BroadcastDeviceInfo *info)
Definition: lds_lidar.cpp:172
void EnableAutoConnectMode(void)
Definition: lds_lidar.h:98
static void ControlFanCb(livox_status status, uint8_t handle, uint8_t response, void *clent_data)
Definition: lds_lidar.cpp:347
uint32_t whitelist_count_
Definition: lds_lidar.h:108
int ParseConfigFile(const char *pathname)
Definition: lds_lidar.cpp:644
char broadcast_code_whitelist_[kMaxLidarCount][kBroadcastCodeSize]
Definition: lds_lidar.h:110
bool IsExistInRawConfig(const char *broadcast_code)
Definition: lds_lidar.cpp:744
int AddBroadcastCodeToWhitelist(const char *broadcast_code)
Definition: lds_lidar.cpp:557
TimeSyncConfig timesync_config_
Definition: lds_lidar.h:115
virtual void PrepareExit(void)
Definition: lds_lidar.cpp:153
int AddRawUserConfig(UserRawConfig &config)
Definition: lds_lidar.cpp:733
static void StartSampleCb(livox_status status, uint8_t handle, uint8_t response, void *clent_data)
Definition: lds_lidar.cpp:501
static void ReceiveSyncTimeCallback(const char *rmc, uint32_t rmc_length, void *client_data)
Definition: lds_lidar.cpp:538
static LdsLidar * GetInstance(uint32_t interval_ms)
Definition: lds_lidar.h:46
unsigned int uint32_t
Definition: stdint.h:127
static void OnLidarDataCb(uint8_t handle, LivoxEthPacket *data, uint32_t data_num, void *client_data)
Definition: lds_lidar.cpp:158
static void GetLidarExtrinsicParameterCb(livox_status status, uint8_t handle, LidarGetExtrinsicParameterResponse *response, void *clent_data)
Definition: lds_lidar.cpp:431
GenericDocument< UTF8<> > Document
GenericDocument with UTF8 encoding.
Definition: document.h:3029
int InitLdsLidar(std::vector< std::string > &broadcast_code_strs, const char *user_config_path)
Definition: lds_lidar.cpp:62
bool IsBroadcastCodeExistInWhitelist(const char *broadcast_code)
Definition: lds_lidar.cpp:574
LdsLidar(uint32_t interval_ms)
Definition: lds_lidar.cpp:48
volatile bool is_initialized_
Definition: lds_lidar.h:109
static void SetHighSensitivityCb(livox_status status, uint8_t handle, DeviceParameterResponse *response, void *clent_data)
Definition: lds_lidar.cpp:471
static void DeviceInformationCb(livox_status status, uint8_t handle, DeviceInformationResponse *ack, void *clent_data)
Definition: lds_lidar.cpp:310
int DeInitLdsLidar(void)
Definition: lds_lidar.cpp:137
void DisableAutoConnectMode(void)
Definition: lds_lidar.h:99
bool IsAutoConnectMode(void)
Definition: lds_lidar.h:100
int ParseTimesyncConfig(rapidjson::Document &doc)
Definition: lds_lidar.cpp:589
static void StopSampleCb(livox_status status, uint8_t handle, uint8_t response, void *clent_data)
Definition: lds_lidar.cpp:526
static void LidarErrorStatusCb(livox_status status, uint8_t handle, ErrorMessage *message)
Definition: lds_lidar.cpp:324


livox_ros_driver
Author(s): Livox Dev Team
autogenerated on Mon Mar 15 2021 02:40:46