Skip to content

Commit 95edab4

Browse files
committed
fix check lidar error
1 parent 1f3bd29 commit 95edab4

File tree

3 files changed

+14
-26
lines changed

3 files changed

+14
-26
lines changed

include/CYdLidar.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ class YDLIDAR_API CYdLidar
9393
bool isScanning;
9494
int node_counts ;
9595
double each_angle;
96-
int print_error_info;
9796
bool m_isMultipleRate;
9897
double m_FrequencyOffset;
9998

include/ydlidar_driver.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -540,16 +540,6 @@ namespace ydlidar{
540540
*/
541541
result_t sendData(const uint8_t * data, size_t size);
542542

543-
/**
544-
* @brief 发送掉电保护命令 \n
545-
* @return 返回执行结果
546-
* @retval RESULT_OK 发送成功
547-
* @retval RESULT_FAILE 发送失败
548-
* @note只有(G4, G4C, F4PRO)雷达支持掉电保护功能, 别的型号雷达暂不支持
549-
*/
550-
result_t sendHeartBeat();
551-
552-
553543
/**
554544
* @brief 关闭数据获取通道 \n
555545
*/

src/CYdLidar.cpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ CYdLidar::CYdLidar() : lidarPtr(nullptr)
3030
isScanning = false;
3131
node_counts = 720;
3232
each_angle = 0.5;
33-
print_error_info = 0;
3433
m_FrequencyOffset = 0.4;
3534
m_isMultipleRate = false;
3635
m_IgnoreArray.clear();
@@ -256,17 +255,15 @@ bool CYdLidar::getDeviceHealth() const {
256255
} else {
257256
ydlidar::console.error("YDLidar running correctly ! The health status is bad");
258257
}
259-
if (healthinfo.status == 2) {
260-
if (print_error_info == 3)
261-
ydlidar::console.error("Error, Yd Lidar internal error detected. Please reboot the device to retry.");
258+
if (healthinfo.status == 2) {
259+
ydlidar::console.error("Error, Yd Lidar internal error detected. Please reboot the device to retry.");
262260
return false;
263261
} else {
264262
return true;
265263
}
266264

267-
} else {
268-
if (print_error_info == 3)
269-
ydlidar::console.error( "Error, cannot retrieve Yd Lidar health code: %x", op_result);
265+
} else {
266+
ydlidar::console.error( "Error, cannot retrieve Yd Lidar health code: %x", op_result);
270267
return false;
271268
}
272269

@@ -278,9 +275,8 @@ bool CYdLidar::getDeviceInfo(int &type) {
278275

279276
device_info devinfo;
280277
result_t ans = lidarPtr->getDeviceInfo(devinfo);
281-
if (!IS_OK(ans)) {
282-
if (print_error_info == 3)
283-
ydlidar::console.error("get DeviceInfo Error" );
278+
if (!IS_OK(ans)) {
279+
ydlidar::console.error("get DeviceInfo Error" );
284280
return false;
285281
}
286282
std::string model;
@@ -622,19 +618,22 @@ bool CYdLidar::checkStatus()
622618
for (it=checkmodel.begin(); it!=checkmodel.end(); ++it) {
623619
if(it->second)
624620
continue;
625-
print_error_info++;
626621
lidarPtr->disconnect();
622+
delete lidarPtr;
623+
lidarPtr = nullptr;
627624
m_SerialBaudrate = it->first;
628625

629-
bool ret = checkCOMMs();
630-
if (!ret) {
626+
if (!checkCOMMs()) {
631627
return false;
628+
} else {
629+
break;
632630
}
633631
}
634-
632+
if(it == checkmodel.end()) {
633+
return false;
634+
}
635635
} else {
636636
ret = true;
637-
print_error_info = 0;
638637
break;
639638
}
640639
}

0 commit comments

Comments
 (0)