All Projects → lakshmanmallidi → PyLidar3

lakshmanmallidi / PyLidar3

Licence: MIT license
PyLidar3 is python 3 package to get data from Lidar devices from various manufacturers.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to PyLidar3

BtcDet
Behind the Curtain: Learning Occluded Shapes for 3D Object Detection
Stars: ✭ 104 (+197.14%)
Mutual labels:  lidar, autonomous-driving, autonomous-vehicles, lidar-point-cloud
Visualizing-lidar-data
Visualizing lidar data using Uber Autonomous Visualization System (AVS) and Jupyter Notebook Application
Stars: ✭ 75 (+114.29%)
Mutual labels:  autonomous-driving, autonomous-vehicles, lidar-point-cloud
Awesome-3D-Object-Detection-for-Autonomous-Driving
Papers on 3D Object Detection for Autonomous Driving
Stars: ✭ 52 (+48.57%)
Mutual labels:  lidar, autonomous-driving, autonomous-vehicles
LiDAR fog sim
LiDAR fog simulation
Stars: ✭ 101 (+188.57%)
Mutual labels:  lidar, autonomous-driving, lidar-point-cloud
glcapsnet
Global-Local Capsule Network (GLCapsNet) is a capsule-based architecture able to provide context-based eye fixation prediction for several autonomous driving scenarios, while offering interpretability both globally and locally.
Stars: ✭ 33 (-5.71%)
Mutual labels:  autonomous-driving, autonomous-vehicles
SelfDrivingCarsControlDesign
Self Driving Cars Longitudinal and Lateral Control Design
Stars: ✭ 96 (+174.29%)
Mutual labels:  autonomous-driving, autonomous-vehicles
Object-Detection-using-LiDAR
This repo detect objects automatically for LiDAR data
Stars: ✭ 38 (+8.57%)
Mutual labels:  lidar, lidar-point-cloud
pole-localization
Online Range Image-based Pole Extractor for Long-term LiDAR Localization in Urban Environments
Stars: ✭ 107 (+205.71%)
Mutual labels:  lidar, lidar-point-cloud
loco car
Software for LOCO, our autonomous drifting RC car.
Stars: ✭ 44 (+25.71%)
Mutual labels:  autonomous-driving, autonomous-vehicles
LiDAR-GTA-V
A plugin for Grand Theft Auto V that generates a labeled LiDAR point cloud from the game environment.
Stars: ✭ 127 (+262.86%)
Mutual labels:  lidar, lidar-point-cloud
lidar-buster
Collection of Python snippets for processing LiDAR point cloud.
Stars: ✭ 15 (-57.14%)
Mutual labels:  lidar, lidar-point-cloud
JuliaAutonomy
Julia sample codes for Autonomy, Robotics and Self-Driving Algorithms.
Stars: ✭ 21 (-40%)
Mutual labels:  autonomous-driving, autonomous-vehicles
annotate
Create 3D labelled bounding boxes in RViz
Stars: ✭ 104 (+197.14%)
Mutual labels:  lidar, lidar-point-cloud
dig-into-apollo
Apollo notes (Apollo学习笔记) - Apollo learning notes for beginners.
Stars: ✭ 1,786 (+5002.86%)
Mutual labels:  autonomous-driving, autonomous-vehicles
PointCloudSegmentation
The research project based on Semantic KITTTI dataset, 3d Point Cloud Segmentation , Obstacle Detection
Stars: ✭ 62 (+77.14%)
Mutual labels:  lidar, lidar-point-cloud
highway-path-planning
My path-planning pipeline to navigate a car safely around a virtual highway with other traffic.
Stars: ✭ 39 (+11.43%)
Mutual labels:  autonomous-driving, autonomous-vehicles
pyMHT
Track oriented, multi target, multi hypothesis tracker
Stars: ✭ 66 (+88.57%)
Mutual labels:  autonomous-driving, autonomous-vehicles
SelfDrivingRCCar
Autonomous RC Car using Neural Networks, Python and Open CV
Stars: ✭ 102 (+191.43%)
Mutual labels:  autonomous-driving, autonomous-vehicles
autonomous-delivery-robot
Repository for Autonomous Delivery Robot project of IvLabs, VNIT
Stars: ✭ 65 (+85.71%)
Mutual labels:  autonomous-driving, autonomous-vehicles
dreyeve
[TPAMI 2018] Predicting the Driver’s Focus of Attention: the DR(eye)VE Project. A deep neural network learnt to reproduce the human driver focus of attention (FoA) in a variety of real-world driving scenarios.
Stars: ✭ 88 (+151.43%)
Mutual labels:  autonomous-driving, autonomous-vehicles

PyLidar3

Build Status license FOSSA Status
PyLidar3 is python 3 package to get data from Lidar device. Currently supports ydlidar from www.ydlidar.com/.

Source code

Source code is available on github's repository.
https://github.com/lakshmanmallidi/PyLidar3/blob/master/PyLidar3/__init.py__

Dependencies

  • pyserial
  • time
  • math
  • enum

Installation

Using Pip
pip install PyLidar3

You can also install using setup.py file from git repository.

Usage

This package consists of multiple classes representing the version of lidar you are using. The class structure is YdLidarX4 where X4 is version name ydlidar. Further contribution are actively accepted.

Class structure:
YdLidarX4

Arguments: port, chunk_size(default:6000).

port: serial port to which device is connected. Example: com4, /dev/ttyAMC0.

chunk_size: Number of bytes of data read from device. Increase in chunk_size results in more averaged angle:distance pairs but increase response time result in slower data acquisition. For faster data acquisition decrease chunk_size.

Note: Calibrate chunk size depends on your application and frequency of device. 
if the chunk size is not enough not all angles are covered. 
  • Connect -- Begin serial connection with Lidar by opening serial port. Return success status True/False.

  • StartScanning -- Begin the lidar and returns a generator which returns a dictionary consisting angle(degrees) and distance(millimeters).
    Return Format : {angle(0):distance, angle(2):distance,....................,angle(359):distance}

  • StopScanning -- Stops scanning but keeps serial connection alive.

  • GetHealthStatus -- Returns True if Health of lidar is good else returns False

  • GetDeviceInfo -- Returns Information of Lidar version, serial number etc.

  • Reset -- Reboot the lidar

  • Disconnect -- Stop scanning and close serial communication with Lidar.

YdLidarG4

Arguments: port, chunk_size(default:6000).

port: serial port to which device is connected. Example: com4, /dev/ttyAMC0.

chunk_size: Number of bytes of data read from device. Increase in chunk_size results in more averaged angle:distance pairs but increase response time result in slower data acquisition. For faster data acquisition decrease chunk_size.

Note: Calibrate chunk size depends on your application and frequency of device. 
if the chunk size is not enough not all angles are covered. 
  • Connect -- Begin serial connection with Lidar by opening serial port. Return success status True/False.

  • StartScanning -- Begin the lidar and returns a generator which returns a dictionary consisting angle(degrees) and distance(millimeters).
    Return Format : {angle(0):distance, angle(2):distance,....................,angle(359):distance}

  • StopScanning -- Stops scanning but keeps serial connection alive.

  • GetHealthStatus -- Returns True if Health of lidar is good else returns False

  • GetDeviceInfo -- Returns Information of Lidar version, serial number etc.

  • EnableLowPowerMode -- Enable Low Power Consumption Mode(Turn motor and distance-measuring unit off in StopScanning).

  • DisableLowPowerMode -- Disable Low Power Consumption Mode(Turn motor and distance-measuring unit on StopScanning).

  • GetLowPowerModeStatus -- Return True if Low Power Consumption Mode is Enable else return False.

class FrequencyStep(Enum):
    oneTenthHertz=1
    oneHertz=2
  • IncreaseCurrentFrequency -- Increase current frequency by oneTenth or one depends on enum FrequencyStep.

  • DecreaseCurrentFrequency -- Decrease current frequency by oneTenth or one depends on enum FrequencyStep.

import PyLidar3
port = input("Enter port name which lidar is connected:") #windows
Obj = PyLidar3.YdLidarG4(port)
if(Obj.Connect()):
    print(Obj.GetDeviceInfo())
    print(Obj.GetCurrentFrequency())
    Obj.IncreaseCurrentFrequency(PyLidar3.FrequencyStep.oneTenthHertz)
    print(Obj.GetCurrentFrequency())
    Obj.DecreaseCurrentFrequency(PyLidar3.FrequencyStep.oneHertz)
    print(Obj.GetCurrentFrequency())
    Obj.Disconnect()
else:
    print("Error connecting to device")
  • EnableConstantFrequency -- Enables constant frequency default Enable.

  • DisableConstantFrequency -- Disable constant frequency.

  • SwitchRangingFrequency -- Switch between ranging frequencies 4khz, 8khz and 9khz, default 9khz.

  • GetCurrentRangingFrequency -- Returns current Ranging Frequency in khz.

  • Reset -- Reboot the lidar

  • Disconnect -- Stop scanning and close serial communication with Lidar.

Examples

This Example prints data from lidar

import PyLidar3
import time # Time module
#Serial port to which lidar connected, Get it from device manager windows
#In linux type in terminal -- ls /dev/tty* 
port = input("Enter port name which lidar is connected:") #windows
#port = "/dev/ttyUSB0" #linux
Obj = PyLidar3.YdLidarX4(port) #PyLidar3.your_version_of_lidar(port,chunk_size) 
if(Obj.Connect()):
    print(Obj.GetDeviceInfo())
    gen = Obj.StartScanning()
    t = time.time() # start time 
    while (time.time() - t) < 30: #scan for 30 seconds
        print(next(gen))
        time.sleep(0.5)
    Obj.StopScanning()
    Obj.Disconnect()
else:
    print("Error connecting to device")

This Example plot the data. This example needs matplotlib library.

import threading
import PyLidar3
import matplotlib.pyplot as plt
import math    
import time

def draw():
    global is_plot
    while is_plot:
        plt.figure(1)
        plt.cla()
        plt.ylim(-9000,9000)
        plt.xlim(-9000,9000)
        plt.scatter(x,y,c='r',s=8)
        plt.pause(0.001)
    plt.close("all")
    
                
is_plot = True
x=[]
y=[]
for _ in range(360):
    x.append(0)
    y.append(0)

port =  input("Enter port name which lidar is connected:") #windows
Obj = PyLidar3.YdLidarX4(port) #PyLidar3.your_version_of_lidar(port,chunk_size) 
threading.Thread(target=draw).start()
if(Obj.Connect()):
    print(Obj.GetDeviceInfo())
    gen = Obj.StartScanning()
    t = time.time() # start time 
    while (time.time() - t) < 30: #scan for 30 seconds
        data = next(gen)
        for angle in range(0,360):
            if(data[angle]>1000):
                x[angle] = data[angle] * math.cos(math.radians(angle))
                y[angle] = data[angle] * math.sin(math.radians(angle))
    is_plot = False
    Obj.StopScanning()
    Obj.Disconnect()
else:
    print("Error connecting to device")

Testing

A "tesing" branch is maintained in the git repository for testing, debugging and updating the code. Please visit Github repo https://github.com/lakshmanmallidi/PyLidar3 for further information.

License

FOSSA Status

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].