SLAMTEC RPLIDAR A1接口

adafruit-rplidar的Python项目详细描述


简介

提供与SLAMTEC RPLIDAR A1的接口。

最终目标是让单个模块同时使用Linux(通过/dev/usb0等)和CircuitPython(通过UART实例)

用法示例

import os
from math import cos, sin, pi, floor
import pygame
from adafruit_circuitpython_rplidar import RPLidar

# Set up pygame and the display
os.putenv('SDL_FBDEV', '/dev/fb1')
pygame.init()
lcd = pygame.display.set_mode((320,240))
pygame.mouse.set_visible(False)
lcd.fill((0,0,0))
pygame.display.update()

# Setup the RPLidar
PORT_NAME = '/dev/ttyUSB0'
lidar = RPLidar(None, PORT_NAME)

# used to scale data to fit on the screen
max_distance = 0

def process_data(data):
    # Do something useful with the data
    pass

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('Stoping.')
lidar.stop()
lidar.disconnect()

贡献

欢迎投稿!请阅读我们的Code of Conduct 在帮助这个项目保持热情之前。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
算法图形。路径方向Java枚举方向问题无法使用EAST   Java:将字符串转换为特定语言环境   javaspringboot&Thymeleaf为后续调用保存搜索表单的最佳方法   mapreduce程序中未调用java reducer   java如何将url中的Gif文件保存到手机中?   如何在JavaSwing中使用[Esc]键最小化JInternalFrame?   java创建了一个包含100个按钮、80个空按钮和20个随机按钮的网格布局   如何在java中使用数组对2d字符串数组中的每一行进行排序。分类   java无法识别的SSL消息,纯文本连接?例外   为什么Java编译器允许在抛出部分列出方法无法抛出的异常   java将预测数组添加到训练数组   java从Ajax调用获取响应文本   使用改型2的java应用程序等待一分钟后退出