又一个Roomba控制器

yarc的Python项目详细描述


yarc:又一个roomba控制器

这是一个python库,允许您使用串行连接从irobot控制roomba和create。这需要python 3和pyserial库。这可以在许多设备上运行,如覆盆子PIS和普通PC。在Create2上测试,一些旧设备可能不支持所有操作或传感器。

这实现了iRobot的开放接口规范:http://www.irobot.com/~/media/MainSite/PDFs/About/STEM/Create/create_2_Open_Interface_Spec.pdf

这个库实现了规范中的每个操作码,并在一个易于使用的系统中提供了每个传感器。所有单个传感器都可以作为yarc.Roomba对象和all_sensors对象的属性使用,后者是所有传感器的namedtuple其他组可以用sensor()方法获得,自定义组可以用query_list()方法获得单个值返回为ints或bools,位字段返回为IntFlag类型,值集合返回为namedtuple实例

这可以从Github源或通过pip:pip install yarc从源安装

示例

importyarc# Make the Roomba objectbot=yarc.Roomba('/dev/ttyUSB0')# Start the OI connection - must be the first callbot.start()# Switch to 'safe' mode# In this mode we can completely control the robot unless it 'senses danger'# in which case it will switch back to 'passive' mode. Danger could be# detection of a cliff, detection of a wheel drop, or charger plugged in.bot.safe()# Commandsbot.drive_distance(100)# drives 100 mm forwardbot.turn_angle(45)# rotates 45 degrees in-place...# more instructionsprint(bot.battery_charge/bot.battery_capacity)# print battery charge percentprint(bot.all_sensors)# print out all sensor data# Stop the OI connection - must be the last callbot.stop()

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

推荐PyPI第三方库


热门话题
Java Eclipse当我选择File/New时,我没有看到“Android应用程序”   java按位And for Int[]一行   Java中的regex重用模式实例   java使服务始终运行,即使在重新启动后也是如此   java游戏中的音频在播放声音时冻结   java IsChcked()不响应复选框状态(安卓 studio)   如果互联网不可用,Android会将服务器请求排队吗?   Junit5中的java忽略测试   java Vaadin JPA容器筛选器以多个关系连接   java无法在SeleniumWebDriver中选择Iframe   java从文本文件中提取JSON字符串,其中JSON字符串不以逗号分隔   java如何在应用程序中定义空列表。弹簧靴中的yml   带有EditText字符串的java SharedReference   java在MacOs Sierra上安装Tomcat   java如何向dialogflow发送响应   尝试使用DataflowRunner时java ClassNotFound异常   为什么我要关闭java。util。扫描仪变量?