Skip to content

Commit

Permalink
fix check lidar error
Browse files Browse the repository at this point in the history
  • Loading branch information
yangfuyuan committed Dec 4, 2018
1 parent 1f3bd29 commit 95edab4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 26 deletions.
1 change: 0 additions & 1 deletion include/CYdLidar.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ class YDLIDAR_API CYdLidar
bool isScanning;
int node_counts ;
double each_angle;
int print_error_info;
bool m_isMultipleRate;
double m_FrequencyOffset;

Expand Down
10 changes: 0 additions & 10 deletions include/ydlidar_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -540,16 +540,6 @@ namespace ydlidar{
*/
result_t sendData(const uint8_t * data, size_t size);

/**
* @brief 发送掉电保护命令 \n
* @return 返回执行结果
* @retval RESULT_OK 发送成功
* @retval RESULT_FAILE 发送失败
* @note只有(G4, G4C, F4PRO)雷达支持掉电保护功能, 别的型号雷达暂不支持
*/
result_t sendHeartBeat();


/**
* @brief 关闭数据获取通道 \n
*/
Expand Down
29 changes: 14 additions & 15 deletions src/CYdLidar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ CYdLidar::CYdLidar() : lidarPtr(nullptr)
isScanning = false;
node_counts = 720;
each_angle = 0.5;
print_error_info = 0;
m_FrequencyOffset = 0.4;
m_isMultipleRate = false;
m_IgnoreArray.clear();
Expand Down Expand Up @@ -256,17 +255,15 @@ bool CYdLidar::getDeviceHealth() const {
} else {
ydlidar::console.error("YDLidar running correctly ! The health status is bad");
}
if (healthinfo.status == 2) {
if (print_error_info == 3)
ydlidar::console.error("Error, Yd Lidar internal error detected. Please reboot the device to retry.");
if (healthinfo.status == 2) {
ydlidar::console.error("Error, Yd Lidar internal error detected. Please reboot the device to retry.");
return false;
} else {
return true;
}

} else {
if (print_error_info == 3)
ydlidar::console.error( "Error, cannot retrieve Yd Lidar health code: %x", op_result);
} else {
ydlidar::console.error( "Error, cannot retrieve Yd Lidar health code: %x", op_result);
return false;
}

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

device_info devinfo;
result_t ans = lidarPtr->getDeviceInfo(devinfo);
if (!IS_OK(ans)) {
if (print_error_info == 3)
ydlidar::console.error("get DeviceInfo Error" );
if (!IS_OK(ans)) {
ydlidar::console.error("get DeviceInfo Error" );
return false;
}
std::string model;
Expand Down Expand Up @@ -622,19 +618,22 @@ bool CYdLidar::checkStatus()
for (it=checkmodel.begin(); it!=checkmodel.end(); ++it) {
if(it->second)
continue;
print_error_info++;
lidarPtr->disconnect();
delete lidarPtr;
lidarPtr = nullptr;
m_SerialBaudrate = it->first;

bool ret = checkCOMMs();
if (!ret) {
if (!checkCOMMs()) {
return false;
} else {
break;
}
}

if(it == checkmodel.end()) {
return false;
}
} else {
ret = true;
print_error_info = 0;
break;
}
}
Expand Down

0 comments on commit 95edab4

Please sign in to comment.