diff --git a/CMakeLists.txt b/CMakeLists.txt index 24c49fc..c2d2d75 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 0) +set(YDLIDAR_SDK_VERSION_PATCH 1) set(YDLIDAR_SDK_VERSION ${YDLIDAR_SDK_VERSION_MAJOR}.${YDLIDAR_SDK_VERSION_MINOR}.${YDLIDAR_SDK_VERSION_PATCH}) ########################################################## diff --git a/examples/tmini_test.cpp b/examples/tmini_test.cpp index be0d652..7812970 100644 --- a/examples/tmini_test.cpp +++ b/examples/tmini_test.cpp @@ -79,7 +79,7 @@ int main(int argc, char *argv[]) { int id = 0; for (it = ports.begin(); it != ports.end(); it++) { - printf("%d. %s %s\n", id, it->first.c_str(), it->second.c_str()); + printf("[%d] %s %s\n", id, it->first.c_str(), it->second.c_str()); id++; } @@ -163,7 +163,7 @@ int main(int argc, char *argv[]) { std::string input_frequency; - float frequency = 10.0; + float frequency = 6.0; // while (ydlidar::os_isOk() && !isSingleChannel) { // printf("Please enter the lidar scan frequency[5-12]:"); @@ -211,7 +211,7 @@ int main(int argc, char *argv[]) { //////////////////////bool property///////////////// /// fixed angle resolution - bool b_optvalue = true; + bool b_optvalue = false; laser.setlidaropt(LidarPropFixedResolution, &b_optvalue, sizeof(bool)); b_optvalue = false; /// rotate 180 diff --git a/src/CYdLidar.cpp b/src/CYdLidar.cpp index 15b70b6..28fb67e 100644 --- a/src/CYdLidar.cpp +++ b/src/CYdLidar.cpp @@ -848,8 +848,6 @@ void CYdLidar::disconnecting() if (lidarPtr) { lidarPtr->disconnect(); - delete lidarPtr; - lidarPtr = nullptr; } scanning = false; @@ -1735,6 +1733,14 @@ bool CYdLidar::checkCalibrationAngle(const std::string &serialNumber) -------------------------------------------------------------*/ bool CYdLidar::checkCOMMs() { + //如果雷达类型有变化则需要先删除旧对象 + if (lidarPtr && + lidarPtr->getLidarType() != m_LidarType) + { + delete lidarPtr; + lidarPtr = nullptr; + } + //如果未创建对象 if (!lidarPtr) { printf("[YDLIDAR] SDK initializing\n"); diff --git a/src/YDlidarDriver.cpp b/src/YDlidarDriver.cpp index 23e68e1..b757f0d 100644 --- a/src/YDlidarDriver.cpp +++ b/src/YDlidarDriver.cpp @@ -2037,9 +2037,11 @@ result_t YDlidarDriver::stopMotor() { /************************************************************************/ /* get the current scan frequency of lidar */ /************************************************************************/ -result_t YDlidarDriver::getScanFrequency(scan_frequency &frequency, - uint32_t timeout) { - result_t ans; +result_t YDlidarDriver::getScanFrequency( + scan_frequency &frequency, + uint32_t timeout) +{ + result_t ans; if (!m_isConnected) { return RESULT_FAIL;