Skip to content

Commit

Permalink
修改GS可打印帧率
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanyiaini committed Apr 25, 2024
1 parent d2e76da commit 48fe336
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 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 2)
set(YDLIDAR_SDK_VERSION_PATCH 4)
set(YDLIDAR_SDK_VERSION_PATCH 5)
set(YDLIDAR_SDK_VERSION ${YDLIDAR_SDK_VERSION_MAJOR}.${YDLIDAR_SDK_VERSION_MINOR}.${YDLIDAR_SDK_VERSION_PATCH})

##########################################################
Expand Down
5 changes: 3 additions & 2 deletions examples/gs_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,10 @@ int main(int argc, char *argv[])
{
if (laser.doProcessSimple(scan))
{
printf("Module [%d] [%d] points\n",
printf("Module [%d] [%d] points in [%.02f]Hz\n",
scan.moduleNum,
int(scan.points.size()));
int(scan.points.size()),
scan.scanFreq);

//打印帧间隔
// uint32_t t = getms();
Expand Down
3 changes: 2 additions & 1 deletion src/CYdLidar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,8 @@ bool CYdLidar::doProcessSimple(LaserScan &outscan)
scanfrequency = global_nodes[i].scanFreq / 10.0 + 3.0;
}
}
else if (isTEALidar(lidar_model)) //TEA雷达转速范围10~30,无缩放
else if (isTEALidar(lidar_model) ||
isGSLidar(m_LidarType)) //TEA雷达转速范围10~30,无缩放
{
scanfrequency = global_nodes[i].scanFreq;
}
Expand Down
8 changes: 7 additions & 1 deletion src/GSLidarDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,7 @@ int GSLidarDriver::cacheScanData()

int timeout_count = 0;
retryCount = 0;
lastStamp = 0;

m_isScanning = true;

Expand Down Expand Up @@ -822,6 +823,11 @@ result_t GSLidarDriver::waitPackage(node_info *node, uint32_t timeout)
else
{
CheckSumResult = true;
if (lastStamp > 0)
{
m_ScanFreq = 1000.0 / (getms() - lastStamp);
}
lastStamp = getms();
}
break;
}
Expand All @@ -848,7 +854,7 @@ result_t GSLidarDriver::waitPackage(node_info *node, uint32_t timeout)
stamp = (*node).stamp;

(*node).index = 0x03 & (moduleNum >> 1); //模组地址转编号: 1, 2, 4
(*node).scanFreq = 0;
(*node).scanFreq = m_ScanFreq;
(*node).qual = 0;
(*node).sync = Node_NotSync;

Expand Down
1 change: 1 addition & 0 deletions src/GSLidarDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ namespace ydlidar
uint64_t stamp = 0; //时间戳
std::list<gs_module_nodes> datas; //各模组数据
double m_pitchAngle = Angle_PAngle;
uint32_t lastStamp = 0; //上一次时间
};

} // namespace ydlidar
Expand Down

0 comments on commit 48fe336

Please sign in to comment.