Introduction: Gesture Based Raspberry Pi Robot With Arduino

About: scientist,Robot lover

This is my very funfull project in we are going to make a robot with raspberry pi and arduino with sensors that enables us to control that robot with keyboard or with gesture over wifi network.

Step 1:

SHOPPING FOR PROJECT

  • 4 wheels for motor
  • Plastic case for making the body of Robot'
  • Any model of raspberry pi ( I have used pi a+)
  • Arduino uno
  • Ultrasonic sensor
  • 2 infrared sensor
  • Bluetooth hc 05(optional if you want to control wirelessly from p.c)
  • 2 D.C motors
  • l329d motor driver
  • usb wifi adapter(for raspberry pi if you have built in wifi raspberry pi of all ready have one then skip it)jumper

Some extra tools

  • Hot glue or some rubber based adhesive like fevibond
  • few screw with bolts
  • screw driver
  • wires
  • female to female jumper wires

Step 2: Softwere Requirements

  • Arduino IDE
  • Vnc viewer
  • Rashbian os(installed on raspberry pi)
  • python 2.+ version
  • pyserial library
  • pyauto gui library

First install required softwere

setup the the WiFi on Raspberry pi and vnc on raspberry pi you can get the setup process on google

then open terminal in pi and type if-config and get the IP address of pi server

Now setup the required library for python

open the cmd window

and type

pip install pyserial

then

pip install pyautogui

The pyserial helps the python to comunicate with arduino over serial ports either usb or bluetooth

The pyautogui used to control pc from python script.

Step 3: Making the Body of Robot

Fix the wheels motor and as illustrated in pic above and apply the hot glue with glue gun.

or if you have all ready robot kit you can use it or you can also buy from online store like amazon to skip these time taking steps.

But I like to make these stuffs from items find at home so I made it myself .

Step 4:

Now to make the l329d motor driver ready by soldering as given below pin config or you can buy a ready to use motor driver module if you want to save your time you just need to connect the jumper wire in motor driver module .


pin connection of motor driver

  • Enable 1,2,3,4 pin of motor driver goes to 5volt pi pin
  • output 1 and 2 goes to motor1 -ve and +ve
  • Gnd goes to ground pin of pi and the motor driver battery
  • input 1 and 2 goes to pin of pi according to python script you can change it according to python script.
  • input 3 and 4 goes to pi Gpio pin input according to python script
  • output 3 and 4 goes to motor2 +ve nad -ve
  • vcc 2 and ground goes to motor driver battery for powering it

Step 5:

Now connect the Raspberry pi to pc with vnc if you dont know how to do it you can search it on google and go through the instructions ,

Then copy the bot.py that you can get from the link attached to it ,to the desktop of raspberry pi

then run this python script in terminal .

now test the robot by pressing the up down and left right key the robot move accordingly.

congratulations you have made the robot part with raspberry pi.

Now we need to make gesture part to control it using hand gesture.

Step 6: Now We Are Going to Make the Gesture Sensor for Controlling Our Robot

First setup the sensors and wires as in pic above and fis this setup in cardboard box as in pic

Now t connect the wires according to given instructions

VCC(all sensors)--->5v (arduinio)

GND(all sensors)---->GND(arduino)

echo(ultrasonic sensors)---->Gpio 6 (arduino)

trig(ultrasonic sensor)--->pin 7 (arduino)

proximity sensors out pin to ---->pin 2 and 3 respectively(arduino)

Now our hardware part of gesture sensor is ready now we need to upload sketch to arduino

upload the given code to arduino

or you can downlode control.ino from link given and upload to arduino

int x=0;
int y=0;

int sen1=2;

int sen2=3;

int len=0;

int dis=0;

#define echopin 7 //

echo pin #define trigpin 6// Trigger pin long duration, distance;

void setup() {

// put your setup code here, to run once: Serial.begin(9600);

pinMode (trigpin,OUTPUT); pinMode (echopin,INPUT );

pinMode (sen1,INPUT);

pinMode(sen2,INPUT);

}

void loop() { // put your main code here, to run repeatedly:

digitalWrite(trigpin,LOW);

delayMicroseconds(2);

digitalWrite(trigpin,HIGH);

delayMicroseconds(10);

duration=pulseIn (echopin,HIGH);

distance= duration/58.2; delay (50); x=digitalRead(sen1); y=digitalRead(sen2);

//uncomment the below to see the sensor value // Serial.print("\t"); // Serial.print("first output = "); //Serial.println(y); // // Serial.print("\t"); // Serial.print("second output = "); //Serial.print(x); // // Serial.print("\t"); // Serial.print("distance cm = "); //Serial.print(distance);

if (x==1){ Serial.println("left");

} if (y==1){ Serial.println("right"); } if (distance<=16 ) { Serial.println("s"); delay(200); } if (distance>=16 && distance<=25) { Serial.println("f"); delay(200); }

}

Step 7: Running the Python for Getting Gesture

Downlode all codes from here

https://github.com/ASHWINISINHA/gesture-pi-robot

Now power on the pi robot and

connect the pi and over wifi network and open the VNC and open pi display in vnc on pc

then open the terminal in pi and run the robo.py script that you have copied from link

then open the

run control,py script in pc then click on pi vnc window that you open

now you are ready to control robot with your hand gesture just wave your hand over proximity sensors to run the robot.

sorry for any typing mistake .

Please do connections and wiring correctly and on your own risk