JD
Created September 9, 2018

Depth Sensing Aid for the Blind

This belt conveys locations of objects around users by varying the intensity of vibration in an array of vibration motos.

65
Depth Sensing Aid for the Blind

Things used in this project

Hardware components

Walabot Developer Pack
Walabot Developer Pack
×1
Raspberry Pi 3 Model B
Raspberry Pi 3 Model B
×1
Arduino Mega 2560
Arduino Mega 2560
×1
9V battery (generic)
9V battery (generic)
×1
9V Battery Clip
9V Battery Clip
×1
Waist Trimmer Belt
×1
Android device
Android device
×1
Micro-USB to USB Cable (Generic)
Micro-USB to USB Cable (Generic)
×1
USB-A to B Cable
USB-A to B Cable
×1

Story

Read more

Schematics

Full Belt Image

Code

Code For Raspberry Pi

Python
Python Code
import WalabotAPI as wlbt
import serial
import numpy as np
from bluetooth import *

#UPDATE FOR DESIRED ARENA VALUES
# WalabotAPI.SetArenaX - input parameters
RArenaMin, RArenaMax, RArenaRes = 0, 0, 0
# WalabotAPI.SetArenaY - input parameters
TArenaMin, TArenaMax, TArenaRes = 0, 0, 0
# WalabotAPI.SetArenaZ - input parameters
PArenaMin, PArenaMax, PArenaRes = 0, 0, 0

#UPDATE FOR ARDUINO PORT ON YOUR DEVICE
#arduino data
ard_port="/dev/ttyUSB0"
rate=9600

#create empty belt
belt = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

#r and c vales
#Insert column and row values seperating grid spaces based upon walabot area parameters (no need for last column or row values, just assumed end
#UPDATE COLUMN AND ROW VALUES FOR YOUR WALABOT PARAMETERS
c1 = 0
c2 = 0

r1 = 0
r2 = 0
r3 = 0


#UPDATE FOR BLUETOOTH INFO ON YOUR DEVICE
base_dir = '/sys/bus/w1/devices/'
device_folder = glob.glob(base_dir + '28*')[0]
device_file = device_folder + '/w1_slave'


def read_temp_raw():
    f = open(device_file, 'r')
    lines = f.readlines()
    f.close()
    return lines


def read_temp():
    lines = read_temp_raw()
    while lines[0].strip()[-3:] != 'YES':
        time.sleep(0.2)
        lines = read_temp_raw()
    equals_pos = lines[1].find('t=')
    if equals_pos != -1:
        temp_string = lines[1][equals_pos + 2:]
        temp_c = float(temp_string) / 1000.0
        temp_f = temp_c * 9.0 / 5.0 + 32.0
        return temp_c


#wait for start command from app
#UPDATE FOR BLUETOOTH INFO ON YOUR DEVICE
server_sock = BluetoothSocket(RFCOMM)
server_sock.bind(("", PORT_ANY))
server_sock.listen(1)

port = server_sock.getsockname()[1]

uuid = "94f39d29-7d6d-437d-973b-fba39e49d4ee"

advertise_service(server_sock, "PiServer",
                  service_id=uuid,
                  service_classes=[uuid, SERIAL_PORT_CLASS],
                  profiles=[SERIAL_PORT_PROFILE],
                  #                   protocols = [ OBEX_UUID ]
                  )
while True:
    client_sock, client_info = server_sock.accept()

    try:
        data = client_sock.recv(1024)
        if len(data) == 0:
            pass

        if data == 'Start':
            client_sock.close()
            server_sock.close()
            break

    except IOError:
        pass

#connect to Arduino
sock = serial.Serial(port=ard_port, baudrate=rate)

#connect to Walabot
wlbt.Init()  # load the WalabotSDK to the Python wrapper
wlbt.Initialize()  # set the path to the essetial database files
wlbt.ConnectAny()  # establishes communication with the Walabot

wlbt.SetProfile(wlbt.PROF_TRACKER)  # set scan profile out of the possibilities

wlbt.SetArenaR(RArenaMin, RArenaMax, RArenaRes)
wlbt.SetArenaTheta(TArenaMin, TArenaMax, TArenaRes)
wlbt.SetArenaPhi(PArenaMin, PArenaMax, PArenaRes)

wlbt.SetDynamicImageFilter(wlbt.FILTER_TYPE_MTI)  # specify filter to use

wlbt.Start()  # starts Walabot in preparation for scanning

#start depth sensing aid
while True:
    belt = [255.0, 255.0, 255.0, 255.0, 255.0, 255.0, 255.0, 255.0, 255.0, 255.0, 255.0, 255.0] # create belt list for motors

    wlbt.Trigger()  # initiates a scan and records signals
    targets = wlbt.GetTrackerTargets()  # provides a list of identified targets

    for i, t in enumerate(targets):

        print('Target #{}\nx = {}\ny = {}\nz = {}\n'.format(
            i + 1, t.xPosCm, t.yPosCm, t.zPosCm))

        if(t.yPosCm < c1):
            if(t.xPosCm < r1):
                belt[0] = t.zPosCm
            elif (t.xPosCm < r2):
                belt[1] = t.zPosCm
            elif (t.xPosCm < r3):
                belt[2] = t.zPosCm
            else:
                belt[3] = t.zPosCm
        elif (t.yPosCm < c2):
            if (t.xPosCm < r1):
                belt[4] = t.zPosCm
            elif (t.xPosCm < r2):
                belt[5] = t.zPosCm
            elif (t.xPosCm < r3):
                belt[6] = t.zPosCm
            else:
                belt[7] = t.zPosCm
        else:
            if (t.xPosCm < r1):
                belt[8] = t.zPosCm
            elif (t.xPosCm < r2):
                belt[9] = t.zPosCm
            elif (t.xPosCm < r3):
                belt[10] = t.zPosCm
            else:
                belt[11] = t.zPosCm

    sock.write(np.array(belt).tostring().encode())
    sock.readline()

sock.close()
wlbt.Stop()  # stops Walabot when finished scanning
wlbt.Disconnect()  # stops communication with Walabot

Android APK

Java
App APK
No preview (download only).

Arduino Code

Arduino
Controlling Vibration Motors
float grid[12];
void setup() {
  // initialize digital pin 13 as an output.
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);
  Serial.begin(9600);
}

// the loop function runs over and over again forever
void loop() {
  while (Serial.available()==0){ }  //Wait for User Input
  //getgrid data
  for(int i=0; i<12; i++){
    grid[i] = Serial.parseFloat();
  }
  //apply vibration intensity
  for(int i=2; i<14; i++){
    analogWrite(i,(255-(int)grid[i-2]);
  }
  
  Serial.println("Done");
}

Credits

JD

JD

2 projects • 0 followers

Comments