Skip to content

Commit

Permalink
修改三角雷达零位包前多1个0xAA数据造成解析失败的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanyiaini committed Mar 6, 2023
1 parent e77e2c7 commit a99d815
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion core/common/ydlidar_help.h
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@ inline bool printfVersionInfo(const device_info &info,

uint8_t Major = (uint8_t)(info.firmware_version >> 8);
uint8_t Minjor = (uint8_t)(info.firmware_version & 0xff);
printf("[YDLIDAR] Connection established in [%s][%d]:\n"
printf("[YDLIDAR] Connection established in [%s][%d]\n"
"Firmware version: %u.%u\n"
"Hardware version: %u\n"
"Model: %s\n"
Expand Down
2 changes: 1 addition & 1 deletion samples/tmini_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ int main(int argc, char *argv[]) {
int id = 0;

for (it = ports.begin(); it != ports.end(); it++) {
printf("%d. %s\n", id, it->first.c_str());
printf("%d. %s %s\n", id, it->first.c_str(), it->second.c_str());
id++;
}

Expand Down
4 changes: 3 additions & 1 deletion samples/tri_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
#include <string>
#include <algorithm>
#include <cctype>
#include <core/base/timer.h>

using namespace std;
using namespace ydlidar;

Expand Down Expand Up @@ -246,7 +248,7 @@ int main(int argc, char *argv[])
/// one-way communication
laser.setlidaropt(LidarPropSingleChannel, &isSingleChannel, sizeof(bool));
/// intensity
b_optvalue = true;
b_optvalue = false;
laser.setlidaropt(LidarPropIntenstiy, &b_optvalue, sizeof(bool));
/// Motor DTR
b_optvalue = false;
Expand Down
11 changes: 4 additions & 7 deletions src/CYdLidar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,13 +461,11 @@ bool CYdLidar::turnOn()
}

uint32_t t = getms();
// start scan...
//启动扫描
result_t op_result = lidarPtr->startScan();

if (!IS_OK(op_result))
{
op_result = lidarPtr->startScan();

if (!IS_OK(op_result))
{
lidarPtr->stop();
Expand All @@ -476,15 +474,12 @@ bool CYdLidar::turnOn()
return false;
}
}

printf("[YDLIDAR] Successed to start scan mode, Elapsed time %u ms\n", getms() - t);
fflush(stdout);

m_PointTime = lidarPtr->getPointTime();

// //获取强度标识
// lidarPtr->getIntensityFlag();

t = getms();
//计算采样率
if (checkLidarAbnormal())
{
Expand All @@ -495,6 +490,8 @@ bool CYdLidar::turnOn()
isScanning = false;
return false;
}
printf("[YDLIDAR] Successed to check the lidar, Elapsed time %u ms\n", getms() - t);
fflush(stdout);

if (m_SingleChannel && !isNetTOFLidar(m_LidarType))
{
Expand Down
10 changes: 10 additions & 0 deletions src/YDlidarDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,11 @@ result_t YDlidarDriver::parseResponseHeader(
setDriverError(NoError);
}
}
else if (currentByte == PH1) //防止出现连续0xAA
{
recvPos = 1;
continue;
}
else if (currentByte == PH3)
{
recvPos = 0;
Expand Down Expand Up @@ -2571,6 +2576,11 @@ result_t YDlidarDriver::parseHeader(
recvPos = 0;
continue;
}
else if (c == PH1)
{
recvPos = 1;
continue;
}
break;

case 2:
Expand Down

0 comments on commit a99d815

Please sign in to comment.