File tree Expand file tree Collapse file tree 2 files changed +32
-32
lines changed Expand file tree Collapse file tree 2 files changed +32
-32
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
2
+ #
3
+ # SPDX-License-Identifier: MIT
4
+
5
+ from math import floor
6
+ from adafruit_rplidar import RPLidar
7
+
8
+ # Setup the RPLidar
9
+ PORT_NAME = "/dev/ttyUSB0"
10
+ lidar = RPLidar (None , PORT_NAME , timeout = 3 )
11
+
12
+ # used to scale data to fit on the screen
13
+ max_distance = 0
14
+
15
+
16
+ def process_data (data ):
17
+ print (data )
18
+
19
+
20
+ scan_data = [0 ] * 360
21
+
22
+ try :
23
+ # print(lidar.get_info())
24
+ for scan in lidar .iter_scans ():
25
+ for (_ , angle , distance ) in scan :
26
+ scan_data [min ([359 , floor (angle )])] = distance
27
+ process_data (scan_data )
28
+
29
+ except KeyboardInterrupt :
30
+ print ("Stopping." )
31
+ lidar .stop ()
32
+ lidar .disconnect ()
You can’t perform that action at this time.
0 commit comments