You are viewing an older revision! See the latest version

Obstacle Detection Robot

Obstacle Detection Robot

Project By Mayuresh Bandekar and Pankit Shah

Purpose

Designed an autonomous robot which when detects any obstacles in its path, would change direction to avoid collision.

Description

We have designed a simple robot which detects obstacles and correspondingly changes its direction to avoid collisions. We have used the mbed controller and interfaced it with an LCD display and 3 Infra-Red sensors. The LCD display indicates the distance of the robot from the obstacle when the robot is in the range of 80 cm to 10 cm and it also displays the direction in which the robot will turn when it sees an obstacle. The 3 infra-red sensors are used to detect obstacles in the front, right and left direction. The front sensor is the primary sensor which keeps checking if there are any obstacles in its path in the front direction. Simultaneously the right and left sensors also keep checking for obstacles in the right and left direction respectively. Whenever there is any obstacle detected in the range of 10 centimeters by the front sensor, the robot will stop and take a turn in either the right or left direction depending on which side is clear and free from obstacles. If both the right and left side are free from obstacles, we have made the robot turn right (One could make it turn left by choice). When the front sensor and left sensor both detect obstacles within the range of 10 centimeters, the robot is made to turn right. Similar logic is used to make the robot left turn. If all the 3 sensors detect obstacles within the range of 10 centimeters, the robot moves in the reverse direction.

Equipment

  • Mbed NXP LPC1768
  • Magician Chassis Robot
  • Sharp IR sensor GP2Y0A21YK0F
  • Dual H-Bridge md08a
  • 16x2 LCD Text Display HD44780

Images

{{}} /media/uploads/simon/mbed.gif

Demo

       
#include "mbed.h"
#include "motordriver.h"
#include "TextLCD.h"
 DigitalOut myled(LED1);
 AnalogIn ain1(p20);
 AnalogIn ain2(p18);
 AnalogIn ain3(p19);
 TextLCD lcd(p15, p16, p17, p11, p12, p13); // rs, e, d4-d7
 

Motor left(p21, p22, p23, 1); // pwm, fwd, rev, has brake feature
Motor right(p26, p25, p24, 1);

int main() {
   
   float temp,temp2,temp3; 
   while (1) {       
   temp=100*(1- ain1);
   if(temp>40){  
   lcd.printf("distance=%f",temp);
   left.speed(0.4);
   right.speed(0.4);
   wait(0.5);
   left.stop(0.5);
   right.stop(0.5);
   wait(0.005);
   temp2=100*(1- ain2);
   temp3=100*(1- ain3);
   if(temp2<40){
   lcd.printf("Take right turn");
   left.speed(0.4);
   right.stop(1);
   wait(0.1);
   left.stop(1);
   right.stop(1);
   wait(0.1);
    }
   if(temp3<40)
   {
   lcd.printf("Take left turn");
   left.stop(1);
   right.speed(0.4);
   wait(0.1);
   left.stop(1);
   right.stop(1);
   wait(0.1);
    } 
   if(temp2<40 && temp3<40){
   float s;
   s=(-1)*(0.5);
   lcd.printf("Take reverse turn");
   left.speed(s);
   right.speed(s);
   wait(2);
   left.stop(1);
   right.stop(1);
   wait(0.5);
    }
   lcd.cls();
}
else
{
   temp2=100*(1- ain2);
   temp3=100*(1- ain3);
   
   if(temp2<40 && temp3>=40){
   lcd.printf("Take right turn");
   left.speed(0.4);
   right.stop(1);
   wait(0.6);
   left.stop(1);
   right.stop(1);
   wait(0.5);
    }
     
   if(temp2>=40 && temp3 <40){
   lcd.printf("Take left turn");
   left.stop(1);
   right.speed(0.4);
   wait(0.6);
   left.stop(1);
   right.stop(1);
   wait(0.5);
    }
   if(temp2 >40 && temp3 >40){
   lcd.printf("Take right turn by default");
   left.speed(0.4);
   right.stop(1);
   wait(0.6);
   left.stop(1);
   right.stop(1);
   wait(0.5);
    }
   }
  }
}


All wikipages