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.
birdmun's picture
#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.

vikirobot's picture

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 

Chris the Carpenter's picture

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.

Maxhirez's picture
First off, ChickenParmi is right-this is probably a little more advanced than you can expect to pull off as a first robot, and having someone do all the work for you will not only not teach you anything but won't be much fun.

Second, while it should be possible to build something very like this Propellor based robot using an Arduino, you seem to be missing a few things-what kind of laptop do you intend to use? What do you intend to use as a controller for the touch screen and joystick controls? What kind of motors specifically do you have, and what do you plan to mount them on?

The question of ROS vs. MS Robot Studio depends on what you have experience with. Both have pretty good support for the Kinect from what I've read. Neither really suggests itself as a turnkey solution for a cobbled-together project like this.

The level of complexity to a build like this is going to preclude anyone from doing a step-by-step tutorial on how to build just what you're asking for, so unless you have the great good fortune to find it already done floating around in the wild, you're probably going to have to piece it together.

To summarize, start smaller (much smaller) and build your skill set before you build his robot. Learn in modules-how to use your Arduino, then how to use Arduino as a serial physical interface, then how to interface with motors and sensors on the Arduino. By this time, you'll understand obstacle avoidance programming. Maybe next you'll want to learn how to build the mechanical aspects, then how to interface with the Kinect and make your programming choices. Then you'll want to learn to code in Android or xCode (assuming you want to use a smart phone for touch screen) or you'll want to choose your hardware standalone option for touchscreen and joystick control and build it, possibly necessitating a second Arduino. Finally, you'll pull it all together and implement the follow-me routine.

On the other hand, there are lots of blogs describing robot builds step by step and you might Ickes into one. You'll have better luck googling "Arduino Kinect laptop robot" than asking for someone to do it for you in these forums.

vikirobot's picture

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 

 

 

chickenparmi's picture

Ummm. You want all instructions and code? Wheres the fun in that!

If this is your first time making a robot I highly suggest taking a look at the Start Here Robot and starting with that, if not, then I suggest playing around with the components and getting to know them yourself. Building something to instructions and not programming it is not that much of a learning experience, don't get me wrong there is something there, but if you did it all yourself you would get much more out of it. 

Thats just how I feel, sorry if that was rough.