数字技术 与应用应用研究基于树莓派的红外避障小车戴文翔 孙智勇(无锡职业技术学院,江苏无锡 214100)摘要:基于树莓派的小车实验很多,如通过网页控制小车;利用超声波进行避障....文章主要介绍利用红外进行避障的小车。为实现小车避障功能,需要设计基于树莓派的智能避障小车。把树莓派作为核心程序驱动器,通过L298n电机驱动实现对直流电机的控制以达到控制小车的目的;利用红外避障传感器模块实时监测小车距离障碍物的距离,设计基于红外线反射测距的避障算法以达到避障目的。关键词:避障小车;红外避障;树莓派;L298n;程序实例中图分类号:TP391文献标识码:A文章编号:1007-9416(2018)01-00-021 硬件设计(1)避障小车硬件组成包括:小车底盘、3个车轮(两个前轮一个后轮)、两个直流电机、红外模块、红外避障传感器(2个)、电源盒、移动电源(小型)、无线网卡、树莓派。PS:3个车轮中,两个前轮由直流电机直接驱动,后轮选择万向轮。(2)电源部分:包括四节1.5V (5号)电池,5000毫安移动电源。四节1.5V (5号)电池为L298n提供6V电压,5000毫安移动电源为树莓派提供稳定的5V电压。(3)驱动部分:包括小车底盘、L298n电机驱动、直流电机(2个)、三个车轮(两个前轮和一个万向轮)。L298n驱动前轮,配合万向轮实现前进、后退以及左右转向。(4)主控制部分:树莓派。树莓派通过L298n控制直流电机转动,(1)通道搭建,以及通道位置:L298n电机驱动可以驱动两路直流电电机。控制直流电机需要用到L298n的四个端口:方向端IN1、IN2、IN3、IN4(PS:如果不需要使用使能,切勿将ENA、ENB以及板载5V使能端帽拔掉,让其一直保持在高点平状态)。通过改变IN1、IN2等四个端口的高低电频状态,使直流电机正转或反转。树莓派通过引脚连接IN1、IN2等端口,来控制电机转向。避障小车代码如图1:(2)初始化GPIO端口:不要忘记的在设置完信息交流通道(channel)后,还要定义GPIO端口为输入端还是输出端,代码如下:.com.cn. All Rights Reserved.全方向达到移动的目的。树莓连接红外传感器模块,通过红外线接发器,以达到实时测量与障碍物的距离。从而可以做到小车再碰到障碍物之前能按预设避让方式进行避让。最终实现智能避让。(5)传感器部分:红外避障模块。红外传感器模块连与树莓派,正常工作时,红外避障模块的工作电压为5V左右,但红外避障模块上的红外接发器接受到遇障碍物而折回的红外时,电压会下降0.1V左右。进而产生信号,是树莓派执行避让语句。(3)定义基础方向:避障行为是由基础方向+树莓派选择调用构成,所以需要在此处先定义最基本的基础移动方式。代码如下:2 软件设计图1收稿日期:2018-01-12作者简介:戴文翔,男,江苏南京人,大专在读;孙智勇,男,江苏徐州人,大专在读。应用研究(4)红外避障:数字技术 与应用总的来说红外避障就是,树莓派利用红外避障模块收集来的信息(离障碍物的远近),在靠近过障碍物时,调用基础方向进行躲避。代码如图2:3 结语树莓的实验远不止智能小车这一类,但要熟练进行实验操作需要对树莓派所使用Linux的指令,以及需要对基于Linux的nano和vim编译器进行性学习。同样语言基础必不可少,大多数情况下Python是Linux默认的编译语言(部分树莓派安装的是Windows系统,这时就需要C语言),所以也要加深对Python的学习。适当了解些像WinSCP这一类辅助程序,会减少我们在实验中的麻烦。图2Infrared Obstacle Avoidance Car Based on Raspberry pieDAI Wen-xiang,SUN Zhi-yong(Wuxi Vocational and Technical College, Wuxi Jiangsu 214100)Abstract:There are a lot of small cars based on raspberry pie. Using ultrasound to avoid obstacles... Today we mainly introduce the car withinfrared obstacle avoidance. In order to realize the obstacle avoidance function, we need to design intelligent obstacle avoidance car based on raspberrypie. As the core program driver, the raspberry is controlled by L298n motor to achieve the purpose of controlling the car. Based on the infrared obstacle.com.cn. All Rights Reserved.avoidance sensor module, the distance between the car and the obstacle is monitored in real time, and the obstacle avoidance algorithm based on infraredreflection ranging is designed to avoid the failure.Key words:obstacle avoidance car; Infrared obstacle avoidance; Raspberry pie; L298n; Application instance······上接第88页3 结语本文首先从健康问题出发,阐述了家庭健康智能看护系统设计及实现的重要性和必要性,针对现有家庭健康监护的不足,结合智能硬件、数据挖掘算法及Android/IOS技术,开发一套基于Jetson TK1平台的家庭智能健康看护系统,从家庭健康数据的监护出发,搭建低功耗高性能家庭私有服务器,整合血压、血糖、睡眠质量和心率等数据,对这些数据进行可视化建模,并开发移动端APP对数据进行展示,能让用户更直观更方便的了解自身的健康状况。为其在就医时,能够帮助医生对被监护者的睡眠质量给出有效的评价提供支撑。参考文献[1]Bruce Eckel.Java编程思想(第4版)[M].北京:机械工业出版社,2007.[2]李宁.Android应用开发实战[M]:机械工业出版社,2013.[3]王江伟.Apache服务器配置与使用工作笔记[M]:电子工业出版社,2012.Research and Implementation of Family Intelligent Health Nursing System Based onJetson TK1 PlatformLEI Ya-hui, ZHOU Lin(Changsha University, College of Computer Engineering and Applied Mathematics, Changsha Hunan 410022)Abstract:The article mainly introduces the development of home health intelligent nursing system, expounds the background meaning, researchpurpose, main technique and characteristics of home intelligent nursing system in detail. And it also analyzes the principle of home intelligent health caresystem based on Jetson TK1 platform and its characteristics, Achieved a detailed analysis. The purpose is to implement and implement the combinationof prevention and control of health ideas.Key words:home health intelligent nursing; data collection and transmission; data visualization; Jetson TK190