树莓派3b+_AlphaBot2模块列表

Arduino控制程序:

 Run-Test                       电机测试
 Joystick 程序                  五向摇杆
 IR 程序                        红外遥控器控制
 Infrared-Obstacle-Avoidancec   红外避障
 Ultrasionc-Obstacle-Avoidance  超声波避障
 Ultrasionc-Infrared-Obstacle-Avoidance  超声波红外避障
 Ultrasionc_Ranging             超声波测距
 TRSensors                      寻迹传感器测试
 Infrared-Line-Tracking         红外寻迹
 W2812                          RGB彩灯
 OLED                           绘图操作demo
 Line-Tracking                  综合程序
 MazeSolver                     迷宫程序
 Bluetooth                      蓝牙控制
 Bluetooth-json                 蓝牙控制(json格式)

树莓派控制程序(AlphaBot2.tar.gz):

 wget <span class="hljs-symbol">http:</span>/<span class="hljs-regexp">/www.waveshare.net/w</span><span class="hljs-regexp">/upload/e</span><span class="hljs-regexp">/ee/</span><span class="hljs-constant">AlphaBot2</span>-<span class="hljs-constant">Demo</span>.<span class="hljs-number">7</span>z
 wget <span class="hljs-symbol">http:</span>/<span class="hljs-regexp">/www.waveshare.net/w</span><span class="hljs-regexp">/upload/c</span><span class="hljs-regexp">/c3/</span><span class="hljs-constant">Rpi_ws281x</span>-master.zip

gpio

 git <span class="hljs-built_in">clone</span> git://git.drogon.net/wiringPi
 <span class="hljs-built_in">cd</span> wiringPi
 ./build
 gpio -v
 gpio readall

红外遥控器控制

 <span class="hljs-built_in">cd</span> ~/AlphaBot2/python
 python IRremote.py

电机测试

 <span class="hljs-built_in">cd</span> ~/AlphaBot2/python
 python AlphaBot2.py

五向摇杆

 <span class="hljs-built_in">cd</span> ~/AlphaBot2/python
 python Joystick.py

红外避障

 <span class="hljs-built_in">cd</span> ~/AlphaBot2/python
 python Infrared_Obstacle_Avoidance.py

超声波测距(树莓派 3B 套餐不包含超声波模块)

 <span class="hljs-built_in">cd</span> ~/AlphaBot2/python
 python Ultrasonic_Rangeing.py

超声波测距(树莓派 3B 套餐不包含超声波模块)

 <span class="hljs-built_in">cd</span> ~/AlphaBot2/python
 python Infrared_Obstacle_Avoidance.py

RGB 彩灯

 rpi_ws281x-master.zip
 unzip rpi_ws281x-master.zip

 apt-get install build-essential python-dev scons swig

 <span class="hljs-built_in">cd</span> rpi_ws281x-master
 scons

 ./<span class="hljs-built_in">test</span>

 <span class="hljs-built_in">cd</span> python
 python setup.py install

 <span class="hljs-built_in">cd</span> examples
 python lowlevel.py

 <span class="hljs-built_in">cd</span> ~/AlphaBot2/python
 python ws2812.py

循迹传感器测试

 <span class="hljs-built_in">cd</span> ~/AlphaBot2/python
 python TRSensors.py

红外循迹程序

 <span class="hljs-built_in">cd</span> ~/AlphaBot2/python
 python LineFollow.py

舵机

 <span class="hljs-built_in">cd</span> ~/AlphaBot2/python
 python PCA9685.py

mjpg-streamer 软件实时监控

 a,raspi-config 开启摄像头
 b,<span class="hljs-regexp">/etc/modules</span> 添加一行<span class="hljs-symbol">:bcm2835-v4l2</span>
 c,重启后,ls -ltr /dev/video<span class="hljs-number">0</span>
 (若无,rpi-update)

 cd <span class="hljs-constant">AlphaBot2</span>/lib/mjpg-streamer
 ./start
 <span class="hljs-symbol">http:</span>/<span class="hljs-regexp">/ip:8080/</span>

通过 webiopi 实现远程遥控

 <span class="hljs-built_in">cd</span> AlphaBot2/lib/WebIOPi-<span class="hljs-number">0.7</span>.<span class="hljs-number">1</span>-raspi2
 ./setup.sh
 webiopi -h
 webiopi <span class="hljs-operator">-d</span> -c /etc/webiopi/config
 http://ip:<span class="hljs-number">8000</span>

 mjpg-AlphaBot 目录,修改视频源 IP:
 <span class="hljs-built_in">cd</span> ./AlphaBot2/mjpg-AlphaBot/
 vim index.html
 http://x.x.x.x:<span class="hljs-number">8080</span>/?action=stream

 <span class="hljs-built_in">cd</span> ./AlphaBot2/mjpg-AlphaBot
 webiopi -c config
 http://x.x.x.x:<span class="hljs-number">8000</span>/

 ./AlphaBot2/mjpg-AlphaBot/mjpg-AlphaBot
 webiopi -c config

 设置开机启动:
 <span class="hljs-built_in">cd</span> ./AlphaBot2/mjpg-AlphaBot
 cp config /etc/webiopi/config
 update-rc.d webiopi defaults
 vim /etc/rc.local:
     <span class="hljs-built_in">cd</span> /home/pi/AlphaBot2/lib/mjpg-streamer
     ./start.sh &

通过 Bottle 实现远程遥控

 a.apt-<span class="hljs-keyword">get</span> install python-bottle
 b.cd ~/AlphaBot2/Web-RGB
   python main
 c. http:<span class="hljs-comment">//ip:8000</span>
   (手机端)
 d.cd ~/AlphaBot2/Web-Control
   vim index.html,修改真实ip:
   <img width=<span class="hljs-string">"320"</span> height=<span class="hljs-string">"240"</span> src=<span class="hljs-string">"http://192.168.10.235:8080/?action=stream"</span>>
 e.python main
 f.http:<span class="hljs-comment">//ip:8000</span>
 g.开机启动:
   vim /etc/rc.local:
     cd /home/pi/AlphaBot2/lib/mjpg-streamer
     ./start.sh &
     cd /home/pi/AlphaBot2/Web-Contrl
     python main &
 h.vim /etc/dhcpcd.comf 设置静态 IP
     <span class="hljs-keyword">interface</span> <span class="hljs-title">wlan0</span>
     <span class="hljs-title">static</span> <span class="hljs-title">ip_address</span> = <span class="hljs-number">192.168</span>.1.114/<span class="hljs-number">24</span>
     <span class="hljs-keyword">static</span> routers = <span class="hljs-number">192.168</span>.1.1

通过软件远程遥控小车

 a.cd ~/AlphaBot2/App-Control
 b.vim main.py:
   Host = <span class="hljs-string">'192.168.10.235'</span>
 c.python main

 d.运行mjpg-streamer

 e.打开 AlphaBot.exe 程序,输入 IP 地址,mjpg-stream 的端口号,小车 Soket 服务端的端口号
 f.开机启动, vim /etc/rc.local:
   <span class="hljs-built_in">cd</span> /home/pi/AlphaBot/lib/mjpg-streamer
   ./start.sh &
   <span class="hljs-built_in">cd</span> /home/pi/AlphaBot/App-Contrl
   python main &
 g.可开启树莓派无线网络适配器的AP功能(不用连接WIFI)

通过树莓派蓝牙遥控小车

 a.升级蓝牙软件包
   apt-get <span class="hljs-operator"><span class="hljs-keyword">update</span>
   apt-<span class="hljs-keyword">get</span> <span class="hljs-keyword">upgrade</span> -y
   apt-<span class="hljs-keyword">get</span> dist-<span class="hljs-keyword">upgrade</span> -y
   apt-<span class="hljs-keyword">get</span> <span class="hljs-keyword">install</span> <span class="hljs-keyword">pi</span>-bluetooth bluez bluez-firmware blueman
 b.<span class="hljs-keyword">pi</span>用户到蓝牙组 
   usermod –G Bluetooth –a <span class="hljs-keyword">pi</span>
 c.reboot
 d.启动/增加 SPP,开启蓝牙设备:
   vim /etc/systemd/system/dbus-org.bluez.service
     ExecStart=/usr/lib/bluetooth/bluetoothd
     ExecStartPost=/usr/<span class="hljs-keyword">bin</span>/sdptool <span class="hljs-keyword">add</span> SP
   reboot
 e.hciconfig
   (如果/boot/config.txt 文件中有 dtoverlay=pi3-miniuart-bt 这语句需要注释掉)
 f.bluetoothctl
   agent <span class="hljs-keyword">on</span>
   agent <span class="hljs-keyword">on</span>
   <span class="hljs-keyword">default</span>-agent
   pair XX:XX:XX:XX:XX:XX ( XX:XX:XX:XX:XX:XX 替换为你自己设备的地址)
   trust XX:XX:XX:XX:XX:XX (配对之后把设备添加到信任列表)
   <span class="hljs-keyword">connect</span> XX:XX:XX:XX:XX:XX
   (注意:如果命令行下链接不成功可以在图形界面下连接。)
 g.cd /AlphaBot2/Bluetooth-Control
   rfcomm watch hci0 <span class="hljs-number">1</span> python bluetooth.py
 h.下载APP(只有安卓, page <span class="hljs-number">45</span>)
   https://fir.im/hysk
 i.bluetoothctl
   discoverable <span class="hljs-keyword">on</span>
   quit</span>