Complete tutorial on how to build an autonomous raspberry pi robot - Website maintained by haikal
Don't wanna be here? Send us removal request.
Link
0 notes
Text
Shell code for autostart
Auto launch thermal camera and pi camera
save as start.sh at cd ~
#!/bin/bash cd Desktop/SeniorDesign && sudo python camera.py & cd ~ && cd Adafruit_AMG88xx_python/examples && sudo python thermal_cam.py &
Scripts are running in parallel and you might have some difficulties to end the processes
0 notes
Text
Installing thermal camera
Follow this tutorial
https://learn.adafruit.com/adafruit-amg8833-8x8-thermal-camera-sensor/raspberry-pi-thermal-camera
Do a modification on thermal_cam.py for window size and positioning
from Adafruit_AMG88xx import Adafruit_AMG88xx import pygame import os import math import time
import numpy as np from scipy.interpolate import griddata
from colour import Color
#low range of the sensor (this will be blue on the screen) MINTEMP = 26
#high range of the sensor (this will be red on the screen) MAXTEMP = 32 lolx = 0 loly = 550 #how many color values we can have COLORDEPTH = 1024
os.putenv('SDL_FBDEV', '/dev/fb1') os.environ['SDL_VIDEO_WINDOW_POS'] = "%d,%d" % (lolx,loly) pygame.init()
#initialize the sensor sensor = Adafruit_AMG88xx()
points = [(math.floor(ix / 8), (ix % 8)) for ix in range(0, 64)] grid_x, grid_y = np.mgrid[0:7:32j, 0:7:32j]
#sensor is an 8x8 grid so lets do a square height = 500 width = 500
#the list of colors we can choose from blue = Color("indigo") colors = list(blue.range_to(Color("red"), COLORDEPTH))
#create the array of colors colors = [(int(c.red * 255), int(c.green * 255), int(c.blue * 255)) for c in colors]
displayPixelWidth = width / 30 displayPixelHeight = height / 30
lcd = pygame.display.set_mode((width, height))
lcd.fill((255,0,0))
pygame.display.update() pygame.mouse.set_visible(False)
lcd.fill((0,0,0)) pygame.display.update()
#some utility functions def constrain(val, min_val, max_val): return min(max_val, max(min_val, val))
def map(x, in_min, in_max, out_min, out_max): return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min
#let the sensor initialize time.sleep(.1) while(1):
#read the pixels pixels = sensor.readPixels() pixels = [map(p, MINTEMP, MAXTEMP, 0, COLORDEPTH - 1) for p in pixels] #perdorm interpolation bicubic = griddata(points, pixels, (grid_x, grid_y), method='cubic') #draw everything for ix, row in enumerate(bicubic): for jx, pixel in enumerate(row): pygame.draw.rect(lcd, colors[constrain(int(pixel), 0, COLORDEPTH- 1)], (displayPixelHeight * ix, displayPixelWidth * jx, displayPixelHeight, displayPixelWidth)) pygame.display.update()
run
cd Adafruit_AMG88xx_python/examples sudo python thermal_cam.py
0 notes
Text
Installing raspberry pi camera
sudo raspi-config
enable camera
reboot
test camera by taking a picture (picture will be saved in cd directory)
raspistill -o output.jpg
Install picamera through pip
$ sudo apt-get install python-pip $ sudo pip install picamera
create python code for preview camera
camera.py
import time import picamera
with picamera.PiCamera() as camera: camera.start_preview(fullscreen=False, window = (100,20,640,480)) time.sleep(10800) camera.stop_preview() camera.close()
Save and cd to the directory.
python camera.py
0 notes
Text
dnsmasq failed to create listening socket
fixed by editing dnsmasq.conf setting from previous post and #´d out
#bind-interfaces
0 notes
Text
RTL8188CUS Hotspot Setup
Follow this blog post setup (https://pimylifeup.com/raspberry-pi-wifi-extender/)
Below is the summarize version from the pimylifeup blog post. This tutorial works on raspbian jessie. (You can check by running cat /etc/os-release)
PRETTY_NAME="Raspbian GNU/Linux 8 (jessie)" NAME="Raspbian GNU/Linux" VERSION_ID="8" VERSION="8 (jessie)" ID=raspbian ID_LIKE=debian HOME_URL="http://www.raspbian.org/" SUPPORT_URL="http://www.raspbian.org/RaspbianForums" BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
sudo apt-get update
sudo apt-get upgrade
sudo reboot
sudo apt-get install dnsmasq hostapd
unplug RTL8188CUS adapter
ifconfig
check the name of the raspberry pi´s wifi (in this case, we´re using wlan0)
wlan0 Link encap:Ethernet HWaddr b8:27:eb:3d:e6:db inet addr:10.0.0.188 Bcast:10.0.0.255 Mask:255.255.255.0 inet6 addr: fe80::8d98:8d59:292f:61af/64 Scope:Link inet6 addr: 2601:47:4001:3771::e54a/128 Scope:Global inet6 addr: 2601:47:4001:3771:1d57:3121:3db7:1b3e/64 Scope:Global UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:48674 errors:0 dropped:4 overruns:0 frame:0 TX packets:45313 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:47747864 (45.5 MiB) TX bytes:22043723 (21.0 MiB)
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
add wifi information that wlan0 need to be connected to
network={ ssid="networkname" psk="networkpassword" }
plug in back RTL8188CUS adapter
this time check the name of the adapter
ifconfig
wlan1 Link encap:Ethernet HWaddr 28:f3:66:aa:34:59 inet addr:192.168.220.1 Bcast:192.168.220.255 Mask:255.255.255.0 inet6 addr: fe80::2336:9660:2d7:cdce/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:33489 errors:0 dropped:665 overruns:0 frame:0 TX packets:19398 errors:0 dropped:10 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:20465494 (19.5 MiB) TX bytes:15935029 (15.1 MiB)
sudo nano /etc/dhcpcd.conf
write wlan1 static ip setting as follows
interface wlan1 static ip_address=192.168.220.1/24 static routers=192.168.220.0
sudo service dhcpcd restart
sudo nano /etc/hostapd/hostapd.conf
write the following setting into hostapd.conf. change DELICOUS and lolwut to your desired ssid and password.
interface=wlan1 driver=nl80211
hw_mode=g channel=6 ieee80211n=1 wmm_enabled=1 ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40] macaddr_acl=0 ignore_broadcast_ssid=0
auth_algs=1 wpa=2 wpa_key_mgmt=WPA-PSK rsn_pairwise=CCMP
ssid=DELICIOUS wpa_passphrase=lolwut
sudo nano /etc/default/hostapd
change this
#DAEMON_CONF=""
to this
DAEMON_CONF="/etc/hostapd/hostapd.conf"
sudo nano /etc/init.d/hostapd
do the same thing, change this
#DAEMON_CONF=""
to this
DAEMON_CONF="/etc/hostapd/hostapd.conf"
sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
sudo nano /etc/dnsmasq.conf
add this to dnsmasq.conf
interface=wlan1 # Use interface wlan1 listen-address=192.168.220.1 # Specify the address to listen on bind-interfaces # Bind to the interface server=8.8.8.8 # Use Google DNS domain-needed # Don't forward short names bogus-priv # Drop the non-routed address spaces. dhcp-range=192.168.220.50,192.168.220.150,12h # IP range and lease time
sudo nano /etc/sysctl.conf
change this
#net.ipv4.ip_forward=1
to this
net.ipv4.ip_forward=1
sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
moving on to the best part, this is how we route packet to/from wlan0 to wlan1
sudo iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
sudo iptables -A FORWARD -i wlan0 -o wlan1 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlan1 -o wlan0 -j ACCEPT
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
sudo nano /etc/rc.local
Find:
exit 0
Add ABOVE:
iptables-restore < /etc/iptables.ipv4.nat
sudo service hostapd start
sudo service dnsmasq start
sudo reboot
If you have problem with dnsmasq: failed to create listening socket for 192.168.220.1: Cannot assign requested address
sudo nano /etc/network/interfaces
remove all wlan0 and wlan1 configuration
add this
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
allow-hotplug wlan1
sudo dnsmasq
check if adapter broadcast the ssid, try to connect to the wifi ssid
0 notes
Text
Initial Setup
-Raspberry Pi 3 (with debian jessie)
-RTL8188CUS 802.11n WLAN Adapter (for hotspot to SSH or remote desktop connection)
-Thermal Sensor (ADAFRUIT AMG8833 IR THERMAL CAMERA BREAKOUT for victim search process)
-Raspberry pi camera module
-Lidar sensor (XV-11 Neato for environmental mapping using SLAM)
-3 Ultrasonic sensor (for distance measuring and navigation)
0 notes