SweiLz / PyYDLidar

Python 3 package to get data from YDLidar
MIT License
5 stars 1 forks source link

YDLidarX2 #1

Open ggjj11 opened 4 years ago

ggjj11 commented 4 years ago

Hi,

thank you for sharing your code! It looks really good! I am trying to get data from my YDLidarX2 via python and found your package. Could you enable getting data from there too. I tried adapting the baudrate according to the data sheet, but I was not able to retrieve data. Running the example script, I get:

lidar.getDeviceHealth()
... in getDeviceHealth
    device_health = unpack("<BH", self._serial.read(lidar_ans_header[2]))
struct.error: unpack requires a buffer of 3 bytes

Could you help me getting the X2 to work with your code?

This is what the visual studio debugger tells me: image

I am not sure whether the lidar_ans_header[2] should be as big as 9101 ? Maybe that is part of the problem.

Visual studio throws here with the exception "unpack requires a buffer of 3 bytes" (in the line device_health = unpack("<BH", temp))

SweiLz commented 4 years ago

Do you try this SDK https://github.com/YDLIDAR/YDLidar-SDK

ggjj11 commented 4 years ago

Thank you very much for your hint to the official ydlidar sdk! I did not know their project. I tried to build it, but the visual studio build failed on windows and I was not able to create a python package I could include with their repository (I submitted issues to their repo now).

If you have an idea what would need to be fixed to get the X2 working with your code, I would be happy to try it out. Otherwise, feel free to close this issue.