Let's Make Robots!

built a robot

hai friends

iam trying to built a robot like eddie(http://www.parallax.com/eddie).

im have following things kinect, arduino , ultrasonic sensors 4 n.o , stepper motor(im not having encoder for dc motor or i should buy it)

i want to implement touch screen & joystick control, obstacle avoidance and "follow me" application.

ishould go for ROS or MICROSOFT ROBOTIC STUDIO

if any body done similar work, give the links to download the code ,hardware assembly instruction , kinect caliberation and its code

thank you in advance

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Go to Rocket Brand Studios and, on the left hand side, there is a click called "I want to make a robot..."

This video will let you know what it is going to take to get a robot going.

now i have a chasis, 2  hc sr 04 sensor and uno rev3 so ithought to start coding

i edited this code for obstacle avoidance

"#define trigPin 13

#define echoPin 12

#define TIMEOUT 40000 // 40ms timeout (the HC-sr04 has 38 ms timeout)

 

void setup()

{

Serial.begin (19200);

pinMode(trigPin, OUTPUT);

pinMode(echoPin, INPUT);

digitalWrite(trigPin, LOW); // Ensure triger is starting with low befre any pulse

delayMicroseconds(20); // Delay before first pulse

}

 

void loop()

{

long duration, distance;

 

digitalWrite(trigPin, HIGH); // Start the High Pulse

 

delayMicroseconds(10); // Delay 10 micros

 

digitalWrite(trigPin, LOW); // End the Pulse

duration = pulseIn(echoPin, HIGH, TIMEOUT);

distance = (duration/2) / 29.1;

 

if (distance >= 400 || distance <= 0)

{

Serial.println("Out of range");

}

else

{

Serial.print(distance);

Serial.println(" cm");

}

delay(50);

} "

into this

//my code

 

#define ta 13   //trig pin of A ultrasonic sensor

#define ea 12   //eco pin of A ultrasonic sensor

#define tb 11    //trig pin of Bultrasonic sensor

#define eb 10   //trig pin of B ultrasonic sensor

#define lp 9  // pin to l293 to control left motor

#define ln 8  //pin to l293 to control left motor

#define rp 7  //pin to l293 to control rightmotor

#define rn 6  //pin to l293 to control right motor

 

#define TIMEOUT 40000     // 40ms timeout (the HC-sr04 has 38 ms timeout)

 

void setup()

{

Serial.begin (19200);

pinMode(lp, OUTPUT);

pinMode(ln, OUTPUT);

pinMode(rp, OUTPUT);

pinMode(rn, OUTPUT);

pinMode(ta, OUTPUT);

pinMode(ea, INPUT);

pinMode(tb, OUTPUT);

pinMode(eb, INPUT);

digitalWrite(ta, LOW);    // Ensure triger is starting with low before any pulse

delayMicroseconds(20);  // Delay before first pulse

digitalWrite(tb, LOW);

delayMicroseconds(20);

}

 

void loop()

{

long dua, da,dub,db;    // dua duration of A sensor// da distance by A sensor// in the same way dub//db

 

digitalWrite(ta, HIGH); // Start the a  High Pulse

 

delayMicroseconds(10); // Delay 10 micros

 

digitalWrite(ta, LOW);    // End the Pulse

dua = pulseIn(ea, HIGH, TIMEOUT);

da = (dua/2) / 29.1;

 

digitalWrite(tb, HIGH); // Start the b High Pulse

 

delayMicroseconds(10); // Delay 10 micros

digitalWrite(tb, LOW); // End the Pulse

dub = pulseIn(eb, HIGH, TIMEOUT);

db = (dub/2) / 29.1;

if ((da >=10) && (db >=10))

{

digitalWrite(lp, HIGH);

digitalWrite(ln, LOW);  \\ turning right concidering obstacle in left sensor A with in 10 cm

digitalWrite(rp, HIGH);

digitalWrite(rn, LOW);

}

 

if ((da <=10) && (db >=10))

{

digitalWrite(lp, HIGH);

digitalWrite(ln, LOW);

digitalWrite(rn, HIGH); //turning left concidering obstacle in left sensor A with in 10 cm

digitalWrite(rp, LOW);

}

 

if ((db <=10)&& (da >=10))

{

digitalWrite(ln, HIGH);

digitalWrite(lp, LOW);

digitalWrite(rn, HIGH);

digitalWrite(rp, LOW);

}

if ((da <=10) && (db <=10))

{

digitalWrite(lp, HIGH);

digitalWrite(ln, LOW); // turning right concidering obstacle in both A and B sensor  with in 10 cm

digitalWrite(rn, HIGH);

digitalWrite(rp, LOW);

delay(7000); // giving some delay thinking that robot will turn enough from the obstacle

digitalWrite(lp, HIGH);

digitalWrite(ln, LOW);// ten left turn to robot to travel stright always

digitalWrite(rp, HIGH);

digitalWrite(rn, LOW);

 

 

}

 

delay(50);

}

insteag of testing this with real robot i planned for apre check using serial monitor to print direction of robot travelling

code below

#define ta 13   //trig pin of A ultrasonic sensor

 

#define ea 12   //eco pin of A ultrasonic sensor

#define tb 11    //trig pin of Bultrasonic sensor

#define eb 10   //trig pin of B ultrasonic sensor/trig pin of A ultrasonic sensor

.#define TIMEOUT 40000 // 40ms timeout (the HC-sr04 has 38 ms timeout)

 

void setup()

{

Serial.begin (19200);

 

pinMode(ta, OUTPUT);

pinMode(ea, INPUT);

pinMode(tb, OUTPUT);

pinMode(eb, INPUT);

digitalWrite(ta, LOW); // Ensure triger is starting with low before any pulse

delayMicroseconds(20);// Delay before first pulse

digitalWrite(tb, LOW);

delayMicroseconds(20);

}

 

void loop()

{

long dua, da, dub, db;  // dua duration of A sensor// da distance by A sensor// in the same way dub//db

 

digitalWrite(ta, HIGH); // Start the a  High Pulse

 

delayMicroseconds(10); // Delay 10 micros

 

digitalWrite(ta, LOW); // End the Pulse

dua = pulseIn(ea, HIGH, TIMEOUT);

da = (dua/2) / 29.1;

 

digitalWrite(tb, HIGH); // Start the b High Pulse

 

delayMicroseconds(10); // Delay 10 micros

digitalWrite(tb, LOW); // End the Pulse

dub = pulseIn(eb, HIGH, TIMEOUT);

db = (dub/2) / 29.1;

 

if ((da >=10)&& (db >=10 ))

{

Serial.println(" go straight");

}

 

 

if ((da <=10)&&(db >=10))

{

Serial.println(" right turn");

}

 

if ((db <=10)&&(da >=10))

{

Serial.println("left turn ");

}

if ((da <=10) && (db <=10))

{

Serial.println(" right turn");

delay(50000);

Serial.println(" left turn ");

 

 

}

 

delay(50);

then  i tested the above code with only two sensor...... i left both sensor unintreuptted so o/p should be printing only "go stright" statment but the output is mixed with "right turn" and "left turn" statment i dont no why...

help me to fix this and i like to go for pwm speed control(for that i have only l293 not arduino motor sheild ) so direct me, having lots of idea about add on like bluethoot contol using android app and add navigation capability 

#define ta 13   //trig pin of A ultrasonic sensor
#define ea 12   //eco pin of A ultrasonic sensor
#define tb 11    //trig pin of Bultrasonic sensor
#define eb 10   //trig pin of B ultrasonic sensor/trig pin of A ultrasonic sensor
#define TIMEOUT 40000 // 40ms timeout (the HC-sr04 has 38 ms timeout)
#define DANGER 10 //range that is too close

void setup() {
  Serial.begin (19200);
  pinMode(ta, OUTPUT);
  pinMode(ea, INPUT);
  pinMode(tb, OUTPUT);
  pinMode(eb, INPUT);
  digitalWrite(ta, LOW); // Ensure triger is starting with low before any pulse
  delayMicroseconds(20);// Delay before first pulse
  digitalWrite(tb, LOW);
  delayMicroseconds(20);
}

void loop() {
  float da, db;
  da = distanceCheck(ta, ea);
  db = distanceCheck(tb, eb);
  
  if ((da >= DANGER) && (db >= DANGER)) {
    Serial.println("go straight");
  }
  if ((da <= DANGER) && (db >= DANGER)) {
    Serial.println("right turn");
  }
  if ((da >= DANGER) && (db <= DANGER)) {
    Serial.println("left turn");
  }
  if ((da <= DANGER) && (db <= DANGER)) {
    Serial.println("right turn");
    delay(50000);//why do you wait 50 seconds here?
    Serial.println("left turn");
  }
  delay(50);
}

float distanceCheck(int trig, int echo) {
  digitalWrite(trig, HIGH);
  delayMicroseconds(10);
  digitalWrite(trig, LOW);
  return ((pulseIn(echo, HIGH, TIMEOUT)) / 2) / 29.1;
}

Let me know if this works for you.