Skip to content

Commit

Permalink
修改适配SCL单通
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanyiaini committed May 29, 2023
1 parent 7a12bc6 commit 5bf99a3
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 33 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ project(ydlidar_sdk C CXX)
# version
set(YDLIDAR_SDK_VERSION_MAJOR 1)
set(YDLIDAR_SDK_VERSION_MINOR 1)
set(YDLIDAR_SDK_VERSION_PATCH 12)
set(YDLIDAR_SDK_VERSION_PATCH 13)
set(YDLIDAR_SDK_VERSION ${YDLIDAR_SDK_VERSION_MAJOR}.${YDLIDAR_SDK_VERSION_MINOR}.${YDLIDAR_SDK_VERSION_PATCH})

##########################################################
Expand Down
1 change: 1 addition & 0 deletions core/common/ydlidar_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ typedef enum {
TYPE_TRIANGLE = 1,/**< G4. G6. G2 LiDAR.*/
TYPE_TOF_NET = 2,/**< T15 LiDAR.*/
TYPE_GS = 3, //GS系列雷达(目前只有GS2)
TYPE_SCL = 4, //SCL雷达
TYPE_SDM = 5, //SDM单点雷达
TYPE_Tail,
} LidarTypeID;
Expand Down
13 changes: 7 additions & 6 deletions core/common/ydlidar_help.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ inline bool isTminiLidar(int model)
}

//根据雷达码判断是否是SCL雷达
inline bool isSCLLidar(int model)
inline bool isSCLLidar2(int model)
{
return model == DriverInterface::YDLIDAR_SCL;
}
Expand Down Expand Up @@ -514,7 +514,8 @@ inline bool isNetTOFLidar(int type) {
inline bool isTriangleLidar(int type) {
bool ret = false;

if (type == TYPE_TRIANGLE) {
if (type == TYPE_TRIANGLE ||
type == TYPE_SCL) {
ret = true;
}

Expand All @@ -532,13 +533,13 @@ inline bool isGSLidar(int type)
}

/**
* @brief Whether it is a GS2 type LiDAR
* @brief Whether it is a SCL type LiDAR
* @param type LiDAR type
* @return true if it is a Triangle type, otherwise false.
* @return true if it is a Triangle SCL type, otherwise false.
*/
inline bool isGS2Lidar(int type)
inline bool isSCLLidar(int type)
{
return (type == TYPE_GS);
return (type == TYPE_SCL);
}

inline bool isSDMLidar(int type)
Expand Down
40 changes: 20 additions & 20 deletions samples/tri_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ int main(int argc, char *argv[])
/// lidar baudrate
laser.setlidaropt(LidarPropSerialBaudrate, &baudrate, sizeof(int));
/// tof lidar
int optval = TYPE_TRIANGLE;
int optval = TYPE_SCL;
laser.setlidaropt(LidarPropLidarType, &optval, sizeof(int));
/// device type
optval = YDLIDAR_TYPE_SERIAL;
Expand Down Expand Up @@ -296,27 +296,27 @@ int main(int argc, char *argv[])
}

//获取用户版本
if (ret && ydlidar::os_isOk())
{
std::string userVersion;
if (laser.getUserVersion(userVersion))
{
printf("User version %s\n", userVersion.c_str());
}
}
// if (ret && ydlidar::os_isOk())
// {
// std::string userVersion;
// if (laser.getUserVersion(userVersion))
// {
// printf("User version %s\n", userVersion.c_str());
// }
// }

//获取设备信息
if (ret)
{
device_info di;
memset(&di, 0, DEVICEINFOSIZE);
if (!laser.getDeviceInfo(di)) {
ydlidar::core::common::printfVersionInfo(di, "", 0);
}
else {
printf("Fail to get device info\n");
}
}
// if (ret)
// {
// device_info di;
// memset(&di, 0, DEVICEINFOSIZE);
// if (!laser.getDeviceInfo(di)) {
// ydlidar::core::common::printfVersionInfo(di, "", 0);
// }
// else {
// printf("Fail to get device info\n");
// }
// }

LaserScan scan;
while (ydlidar::os_isOk())
Expand Down
2 changes: 1 addition & 1 deletion src/CYdLidar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1728,7 +1728,7 @@ bool CYdLidar::checkCOMMs()
//根据雷达类型创建对应的实例
if (isNetTOFLidar(m_LidarType))
lidarPtr = new ydlidar::ETLidarDriver(); //T15
else if (isGS2Lidar(m_LidarType)) //GS2
else if (isGSLidar(m_LidarType)) //GS
lidarPtr = new ydlidar::GSLidarDriver(m_DeviceType);
else if (isSDMLidar(m_LidarType)) //SDM
lidarPtr = new ydlidar::SDMLidarDriver();
Expand Down
11 changes: 6 additions & 5 deletions src/YDlidarDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ YDlidarDriver::YDlidarDriver(uint8_t type) :
trans_delay = 0;
scan_frequence = 0;
m_sampling_rate = -1;
model = YDLIDAR_SCL;
model = YDLIDAR_S2PRO;
retryCount = 0;
has_device_header = false;
m_SingleChannel = false;
Expand Down Expand Up @@ -1387,25 +1387,26 @@ void YDlidarDriver::parseNodeFromeBuffer(node_info *node)

if ((*node).dist != 0)
{
//printf("has angle 2nd parse %d %d\n", m_LidarType, model);
if (isOctaveLidar(model))
{
correctAngle = (int32_t)(((atan(((21.8 * (155.3 - ((*node).dist / 2.0))) / 155.3) / ((*node).dist / 2.0))) * 180.0 / 3.1415) * 64.0);
}
else if (isSCLLidar(model))
else if (isSCLLidar(m_LidarType) ||
isSCLLidar2(model))
{
//SCL雷达角度二级解析公式(α = asind(17.8/dist))
correctAngle = int32_t(asin(17.8 / node->dist) * 180.0 / M_PI * 64.0);
printf("SCL correct angle [%d]\n", correctAngle);
// printf("SCL correct angle [%d]\n", correctAngle);
}
else if (isTriangleLidar(m_LidarType) &&
!isTminiLidar(model)) //去掉Tmini雷达的角度二级解析
{
// printf("has angle 2nd parse\n");
correctAngle = (int32_t)(((atan(((21.8 * (155.3 - ((*node).dist / 4.0))) / 155.3) / ((*node).dist / 4.0))) * 180.0 / 3.1415) * 64.0);
}
else
{
// printf("no angle 2nd parse\n");
// printf("no angle 2nd parse\n");
}

m_InvalidNodeCount ++;
Expand Down

0 comments on commit 5bf99a3

Please sign in to comment.