From 85f7a22da268267d6a8dc912c9b5804fce5f6df0 Mon Sep 17 00:00:00 2001 From: "lakshman.mallidi" Date: Tue, 21 May 2019 00:01:24 +0530 Subject: [PATCH] in scan function list out of range in corner cases is eliminated --- PyLidar3/__init__.py | 17 ++++++++++------- setup.py | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/PyLidar3/__init__.py b/PyLidar3/__init__.py index 8fa6553..b0f23ad 100644 --- a/PyLidar3/__init__.py +++ b/PyLidar3/__init__.py @@ -120,13 +120,16 @@ def StartScanning(self): distdict.update({i:[]}) data = self._s.read(self.chunk_size).split(b"\xaa\x55")[1:-1] for e in data: - if(e[0]==0): - if(YdLidarX4._CheckSum(e)): - d = YdLidarX4._Calculate(e) - for ele in d: - angle = floor(ele[1]) - if(angle>=0 and angle<360): - distdict[angle].append(ele[0]) + try: + if(e[0]==0): + if(YdLidarX4._CheckSum(e)): + d = YdLidarX4._Calculate(e) + for ele in d: + angle = floor(ele[1]) + if(angle>=0 and angle<360): + distdict[angle].append(ele[0]) + except Exception as e: + pass for i in distdict.keys(): distdict[i]=self._Mean(distdict[i]) yield distdict diff --git a/setup.py b/setup.py index 39ddbd8..4b18b82 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="PyLidar3", python_requires=">=3.4", - version="1.4", + version="1.5", author="Lakshman mallidi", author_email="lakshman.mallidi@gmail.com", description="Library for Lidar. Currently supports YdLidar(X4,G4) from http://www.ydlidar.com",