-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from adafruit/adabotify
Renamed example to get rid of unnecessary blank file
- Loading branch information
Showing
2 changed files
with
32 additions
and
32 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries | ||
# | ||
# SPDX-License-Identifier: MIT | ||
|
||
from math import floor | ||
from adafruit_rplidar import RPLidar | ||
|
||
# Setup the RPLidar | ||
PORT_NAME = "/dev/ttyUSB0" | ||
lidar = RPLidar(None, PORT_NAME, timeout=3) | ||
|
||
# used to scale data to fit on the screen | ||
max_distance = 0 | ||
|
||
|
||
def process_data(data): | ||
print(data) | ||
|
||
|
||
scan_data = [0] * 360 | ||
|
||
try: | ||
# print(lidar.get_info()) | ||
for scan in lidar.iter_scans(): | ||
for (_, angle, distance) in scan: | ||
scan_data[min([359, floor(angle)])] = distance | ||
process_data(scan_data) | ||
|
||
except KeyboardInterrupt: | ||
print("Stopping.") | ||
lidar.stop() | ||
lidar.disconnect() |