bmegli / xv11lidar-test

Test for XV11 lidar (character/raw binary synchronized output)
GNU General Public License v3.0
6 stars 2 forks source link

Interfacing LIDAR from python #5

Open bmegli opened 7 years ago

bmegli commented 7 years ago

@bobmcfoo wrote:

Hi @bmegli, I have one more question. How do you interpret the data collected from the LIDAR sensor? I have gone to this website http://xv11hacking.wikispaces.com/LIDAR+Sensor but the data from the Python program I have written doesn't seem to match up with the format that is shown on the the xv11 wiki page. Here is the data my Python program has outputted:

b'Spin...3 ESCs or BREAK to abort...R\x80&\x00R\x80&\x00R\x80&\x00R\x80&\x00\xbcC\xfa\xed$&' Is there something that I am not seeing about the data from my program? Thanks again for being so patient with me!

bmegli commented 7 years ago

As for interfacing from Python you may find those repositories helpfull:

https://github.com/Xevel/NXV11 https://github.com/bombilee/NXV11 https://github.com/burf2000/Neato_XV-11_Ardunio

These are for Arduino but the Python code for interpreting the LIDAR data should be common.

Now - before going to those, you may want to make sure what LIDAR version you have.

You can do that by:

Option 1 - picocom and plug-unplug USB cable (LIDAR power)

Fire up picocom like you did, also set other-uart mode, don't turn the motor. After plugging-unplugging the USB cable LIDAR will output on UART message with firmware and hardware version

Option 2 - picocom and send help message through UART to LIDAR

Just like above but instead of plugging/unplugging send help with picocom. The LIDAR will answer with some information and menu. Just don't mess calibration and watch out what you do.

bmegli commented 7 years ago

Some more information:

My LIDARs output tends to be unstable in the first few revolutions so I am doing it like that:

You can do it in several ways, but the general idea is to find the frame boundrary (0xFA) and make sure that it is really a frame and then proceed with communication reading frames

Also make sure you are in other-uart mode. Otherwise ev3dev autodetection mechanism will mess with the pins of UART corrupting data you read (from time to time).

Finally if you just want to see the LIDAR output in realtime you can do it with ev3dev-mapping

bmegli commented 7 years ago

b'Spin...3 ESCs or BREAK to abort...R\x80&\x00R\x80&\x00R\x80&\x00R\x80&\x00\xbcC\xfa\xed$&'

Your xfa byte near the end may be the start of some frame