LIDAR_Lite_v3 Velocity measurements with Raspberry PI

Moderators: adafruit_support_bill, adafruit

Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Locked
User avatar
xa_rob
 
Posts: 4
Joined: Thu Jan 06, 2022 5:33 am

LIDAR_Lite_v3 Velocity measurements with Raspberry PI

Post by xa_rob »

Garmin LIDAR-Lite Optical Distance Sensor - V3 Product ID: 4058
with https://pypi.org/project/adafruit-circu ... lidarlite/
pip3 install adafruit-circuitpython-lidarlite
you get only distance ...

If you read
https://static.garmin.com/pumac/LIDAR_L ... ations.pdf
Velocity address 0x09 ...
you can also get the velocity with the LIDAR

I'm not familiar with I2C.
Can I access directly the LIDAR from a Python-program with a Raspberry PI 3 or ZERO ?
Which code do I need ?
Which import do I need ?
Thanks in advance

User avatar
dastels
 
Posts: 15817
Joined: Tue Oct 20, 2015 3:22 pm

Re: LIDAR_Lite_v3 Velocity measurements with Raspberry PI

Post by dastels »

I suggest adding velocity support to the adafruit_lidarlite module, and submit your work as a pull request to get it in the official library. The code lives here on Github https://github.com/adafruit/Adafruit_Ci ... _LIDARLite. You can use the existing distance API as an example of interacting with the sensor.

Dave

User avatar
xa_rob
 
Posts: 4
Joined: Thu Jan 06, 2022 5:33 am

Re: LIDAR_Lite_v3 Velocity measurements with Raspberry PI

Post by xa_rob »

Thanks, I will try to change the code

User avatar
xa_rob
 
Posts: 4
Joined: Thu Jan 06, 2022 5:33 am

Re: LIDAR_Lite_v3 Velocity measurements with Raspberry PI

Post by xa_rob »

I’m not familiar with I²C, register and bytes.
Need I only to change read_distance(self, bias=False) ?
Is Velocity not only 1 byte ? not 2 ?
Can you help me ?

Code: Select all

    def read_distance(self, bias=False):
        """Perform a distance reading with or without 'bias'. It's recommended
        to take a bias measurement every 100 non-bias readings (they're slower)"""
        if bias:
            self._write_reg(_REG_ACQ_COMMAND, _CMD_DISTANCEWITHBIAS)
        else:
            self._write_reg(_REG_ACQ_COMMAND, _CMD_DISTANCENOBIAS)
        dist = self._read_reg(0x8F, 2)
        if self._status & (STATUS_NO_PEAK | STATUS_SECOND_RETURN):
            raise RuntimeError("Measurement failure")
        if (self._status & STATUS_SYS_ERROR) or (not self._status & STATUS_HEALTHY):
            raise RuntimeError("System failure")
        return dist[0] << 8 | dist[1]
Last edited by dastels on Fri Jan 07, 2022 6:50 pm, edited 1 time in total.
Reason: add code block

User avatar
dastels
 
Posts: 15817
Joined: Tue Oct 20, 2015 3:22 pm

Re: LIDAR_Lite_v3 Velocity measurements with Raspberry PI

Post by dastels »

The velocity output is in a single 8-bit register (distance is in 2). So you just need to get the value from register 9 (VELOCITY).

See https://cdn-shop.adafruit.com/product-f ... ations.pdf, specifically the Velocity section at the bottom of page 5. You'll need to have it free running mode so it will take distance measure ments at a fixed rate in order to have the velocity mean something.

Dave

User avatar
xa_rob
 
Posts: 4
Joined: Thu Jan 06, 2022 5:33 am

Re: LIDAR_Lite_v3 Velocity measurements with Raspberry PI

Post by xa_rob »

Thank you for the information.

I found also 2 other possibilities to get de Velocity :

# https://pypi.org/project/LiDAR-Lite/
# LiDAR_Lite.py
import smbus2 as smbus

OR

# https://raw.githubusercontent.com/Sande ... ar_lite.py
# https://github.com/Sanderi44/Lidar-Lite ... ar_lite.py
# https://github.com/Sanderi44/Lidar-Lite/find/master
# lidar_lite_2.py
import smbus

Locked
Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/

Return to “Adafruit Raspberry Pi® accessories”