YDLIDAR / YDLidar-SDK

Driver for receiving YD LiDAR data and more...
Other
119 stars 221 forks source link

C++ example working but python example displays *** Buffer overflow detected ***: terminated #15

Open camelator opened 2 years ago

camelator commented 2 years ago

Here is the simple python code. I have the same parameters for the c++ code and it works. I am using Ubuntu 20.04

import ydlidar

port = "/dev/ttyUSB1";

laser = ydlidar.CYdLidar(); laser.setlidaropt(ydlidar.LidarPropSerialPort, port); laser.setlidaropt(ydlidar.LidarPropSerialBaudrate, 153600) laser.setlidaropt(ydlidar.LidarPropLidarType, ydlidar.TYPE_TRIANGLE); laser.setlidaropt(ydlidar.LidarPropDeviceType, ydlidar.YDLIDAR_TYPE_SERIAL); laser.setlidaropt(ydlidar.LidarPropScanFrequency, 8.0); laser.setlidaropt(ydlidar.LidarPropSampleRate, 4); laser.setlidaropt(ydlidar.LidarPropSingleChannel, True); laser.setlidaropt(ydlidar.LidarPropIntenstiy, True); laser.setlidaropt(ydlidar.LidarPropSupportMotorDtrCtrl,False); laser.setlidaropt(ydlidar.LidarPropFixedResolution,False) ; laser.setlidaropt(ydlidar.LidarPropReversion,False) laser.setlidaropt(ydlidar.LidarPropInverted,False) laser.setlidaropt(ydlidar.LidarPropAutoReconnect,True) laser.setlidaropt(ydlidar.LidarPropSupportHeartBeat,False)

laser.setlidaropt(ydlidar.LidarPropMaxAngle,180.0) laser.setlidaropt(ydlidar.LidarPropMinAngle,0.0) laser.setlidaropt(ydlidar.LidarPropMaxRange,64.0) laser.setlidaropt(ydlidar.LidarPropMinRange,0.05)

ret = laser.initialize(); if ret: ret = laser.turnOn(); scan = ydlidar.LaserScan() while ret and ydlidar.os_isOk() : r = laser.doProcessSimple(scan); if r: print("Scan received[",scan.stamp,"]:",scan.points.size(),"ranges is [",1.0/scan.config.scan_time,"]Hz"); else : print("Failed to get Lidar Data.") laser.turnOff(); laser.disconnecting();

Display: YDLidar SDK initializing YDLidar SDK has been initialized [YDLIDAR]:SDK Version: 1.0.3 LiDAR successfully connected [YDLIDAR]:Lidar running correctly ! The health status: good LiDAR init success! [YDLIDAR1]:Fixed Size: 720 [YDLIDAR1]:Sample Rate: 4K [YDLIDAR1]:Fixed Size: 720 [YDLIDAR1]:Sample Rate: 4K [YDLIDAR]:Single Fixed Size: 570 [YDLIDAR]:Sample Rate: 4K [YDLIDAR INFO] Current Sampling Rate : 4K [YDLIDAR INFO] Now YDLIDAR is scanning ...... buffer overflow detected : terminated

The issue comes from the line below, but I am not able to debug. /Maybe someone can help me?

r = laser.doProcessSimple(scan)

Kang-Jik-Kim commented 1 year ago

hi, i solved problem. but im not certain that this is perfect solution. i found handleVersionInfoByPackage occur buffer error in c++ code.

just rid off handleVersionInfoByPackage(debug); code at CYdLidar.cpp and then build again

CYdLidar.cpp is at src/CydLidar.cpp

  1. rid off handleVersionInfoByPackage(debug) in src/CYdLidar.cpp
  2. cd build
  3. make
  4. sudo make install
  5. cd ..
  6. sudo python3 setup.py install
  7. do again