Arduino Forum

Topics => Robotics => Topic started by: sora628 on Nov 24, 2012, 07:48 pm

Title: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: sora628 on Nov 24, 2012, 07:48 pm
Hello SFE hackers, programmers, builders and all!!! I've been working on my robot a bit lately and I've been trying to attempt to perfect my obstacle avoidance algorithm. Basically for my robot (I call it the ASRB) I'm using 5 SHARP sensors and servo to detect objects and avoid them. Also on the ASRB I have 5 battery packs, an Arduino Mega, and Uno, an electronic compass, a GPS, and a piezo speaker. There are a bunch of other random things too, but I'll just upload a few pictures later. I've included my code below--

Inside my main loop is my problem:
I've attempted to make an obstacle avoidance algorithm using if statements, but I want to make it more gradual so when the SHARP sensors detect an object 25 Inches away, it turns the servo a degree. Then when it goes to 24, turns the servo 2 degrees and so on and so forth. I've attempted to use for loops and while loops, but I've had no success---Can anyone help? Thanks!!

-Matt



Code: [Select]
/* Using the 5 IR Distance to control the servo to avoid obstacles

Created August 13th, 2012

Edited last on November 23rd, 2012
--made turns less jerky

*/

#include "pitches.h"

#include <Servo.h>  //include the Servo library

#include <DistanceGP2Y0A21YK.h>  //includes the proximity sensor's library

Servo Steering;  //Creates the servo object named "Steering"
Servo Motor;     //Creates the servo object for the motor

DistanceGP2Y0A21YK Dist01;  //defines Dist01 as the sharp GP2Y0A21YK
DistanceGP2Y0A21YK Dist02;  //defines Dist02 as the sharp GP2Y0A21YK
DistanceGP2Y0A21YK Dist03;  //defines Dist03 as the sharp GP2Y0A21YK
DistanceGP2Y0A21YK Dist04;  //defines Dist04 as the sharp GP2Y0A21YK
DistanceGP2Y0A21YK Dist05;  //defines Dist05 as the sharp GP2Y0A21YK

int Prox01;  //creates the integer for the first IR sensor
int Prox02;  //creates the integer for the second IR sensor
int Prox03;  //creates the integer for the third IR sensor
int Prox04;  //creates the integer for the fourth IR sensor
int Prox05;  //creates the integer for the fifth IR sensor

int spd = 100;  //sets the speed of the dc motor

int melody[] = {
 NOTE_F6, 0, NOTE_F6, 0, NOTE_F6, 0, NOTE_F6, 0};  //melody to be played when backing the car up
int noteDurations[] = {
  2,6,2,6,2,6,2,6 };

int ResetLed = 12;    //Reset LED
int ReverseLed = 11;  //Reverse LED
int AlertLed = 13;    //Alert (Backwards) LED

void setup()
{
 Serial.begin(9600);  //opens the serial monitor at 9600 baud
 Dist01.begin(A0);    //tells program "Dist01" will be used by the serial monitor
 Dist02.begin(A1);    //tells program "Dist02" will be used by the serial monitor
 Dist03.begin(A2);    //tells program "Dist03" will be used by the serial monitor
 Dist04.begin(A3);    //tells program "Dist04" will be used by the serial monitor
 Dist05.begin(A4);    //tells program "Dist05" will be used by the serial monitor


 Steering.attach(7);  //attaches the steering servo to pin 10
 Motor.attach(9);      //attached the motor to PWM pin 9

 
 Serial.println("\n  --Sensor01--Sensor02--Sensor03--Sensor04--Sensor05--");

 pinMode(ReverseLed, OUTPUT);
 digitalWrite(ReverseLed, LOW);

 pinMode(AlertLed,OUTPUT);
 digitalWrite(AlertLed, LOW);

 pinMode(ResetLed, OUTPUT);
 digitalWrite(ResetLed, HIGH);
 delay(300);
 digitalWrite(ResetLed, LOW);
 delay(300);
 digitalWrite(ResetLed, HIGH);
 delay(300);
 digitalWrite(ResetLed, LOW);
 delay(300);
 digitalWrite(ResetLed, HIGH);
 delay(300);
 digitalWrite(ResetLed, LOW);
 delay(300);
 digitalWrite(ResetLed, HIGH);
 delay(300);
 digitalWrite(ResetLed, LOW);
 delay(300);
 digitalWrite(ResetLed, HIGH);
 delay(300);
 digitalWrite(ResetLed, LOW);
 Motor.write(spd);



}

/*

Although below, it says "getDistanceCentimeter", it really converts the data into Inches---make a very big note for this!!

*/




void loop()
{
 Prox01 = Dist01.getDistanceCentimeter();  //Obtains and converts the voltage from the sensor to Inches (Dist01)
 Prox02 = Dist02.getDistanceCentimeter();  //Obtains and converts the voltage from the sensor to Inches (Dist02)
 Prox03 = Dist03.getDistanceCentimeter();  //Obtains and converts the voltage from the sensor to Inches (Dist03)
 Prox04 = Dist04.getDistanceCentimeter();  //Obtains and converts the voltage from the sensor to Inches (Dist04)
 Prox05 = Dist05.getDistanceCentimeter();  //Obtains and converts the voltage from the sensor to Inches (Dist05)

Serial.print(" ------");
Serial.print(Prox01);
Serial.print("--------");
Serial.print(Prox02);
Serial.print("--------");
Serial.print(Prox03);
Serial.print("--------");
Serial.print(Prox04);
Serial.print("--------");
Serial.print(Prox05);
Serial.println("------");


if ((Prox01 <= 10) || (Prox02 <= 10))
 Steering.write(125);
else if ((Prox04 <= 10) || (Prox05 <= 10))
 Steering.write(65);
else if ((Prox01 <= 15) || (Prox02 <= 15))
 Steering.write(115);
else if ((Prox04 <= 15) || (Prox05 <= 15))
 Steering.write(75);
else if ((Prox01 <= 20) || (Prox02 <= 20))
 Steering.write(110);
else if ((Prox04 <= 20) || (Prox05 <= 20))
 Steering.write(90);
else if ((Prox01 <= 25) || (Prox02 <= 25))
 Steering.write(105);
else if ((Prox04 <= 25) || (Prox05 <= 25))
 Steering.write(85);
else if ((Prox01 >15) && (Prox02 >15) && (Prox03 >15) && (Prox04 >15) && (Prox05 >15))
 Steering.write(95);

/*else if (Prox03 <= 20)
 FrontAlert();

delay(100);
*/


/*
else if ((Prox03 <= 15) || ((Prox01 >15) && (Prox02 >15) && (Prox03 >15) && (Prox04 >15) && (Prox05 >15)) || ((Prox01 <=15) && (Prox02 <=15) && (Prox04 <=15) && (Prox05 <=15)))  //If the distance is less then 15 inches
 Steering.write(105);                       //Go Straight
else if (((Prox01 <=15) && (Prox02 <=15)) || ((Prox01 <=15) && (Prox03 <=15)) || ((Prox01 <=15) && (Prox04 <=15)))
 Steering.write(140);
else if (((Prox01 <=15) && (Prox05 <=15)) || ((Prox02 <=15) && (Prox04 <=15)))
 Steering.write(105);
else if (((Prox05 <=15) && (Prox04 <=15)) || ((Prox05 <= 15) && (Prox03 <=15)) || ((Prox05 <=15) && (Prox02 <=15)))
 Steering.write(50);
*/

//delay(100);
}


void BackUpNoise() {                                   //Makes the "Backing Up" noise
 for (int thisNote = 0; thisNote < 9; thisNote++) {
   int noteDuration = 1000/noteDurations[thisNote];
   tone(8, melody[thisNote], noteDuration);
   int pauseBetweenNotes = noteDuration * 1.30;
   delay(pauseBetweenNotes);
   noTone(8);
 }
}


void REVERSE() {                                        //Throws the car in reverse and turns left
 Motor.write(140);
 digitalWrite(ReverseLed, HIGH);
 delay(500);
 Steering.write(95);
 Motor.write(130);
 delay(500);
 Motor.write(110);
 delay(500);
 Motor.write(115);
 BackUpNoise();
 Motor.write(110);
 Steering.write(120);
 delay(1500);
 Steering.write(60);
 Motor.write(100);
 delay(500);
 Motor.write(spd);
 digitalWrite(ReverseLed, LOW);

}

void FrontAlert() {                                     //Warns that the car senses something in front of it
 Steering.write(95);
 digitalWrite(AlertLed, HIGH);
 delay(100);
 digitalWrite(AlertLed, LOW);
 delay(100);
 digitalWrite(AlertLed, HIGH);
 delay(100);
 digitalWrite(AlertLed, LOW);
 delay(100);
 digitalWrite(AlertLed, HIGH);
 delay(100);
 digitalWrite(AlertLed, LOW);
 delay(100);
 REVERSE();

}


/*  Serial.println("\nDistance in Inches Sensor 1: ");  //Prints the line "Distance in Inches Sensor 1:"
 Serial.print(Prox01);                               //Prints the data from Prox01
 Serial.println("\nDistance in Inches Sensor 2: ");  //Prints the line "Distance in Inches Sensor 2:"
 Serial.print(Prox02);                               //Prints the data from Prox02
 Serial.println("\nDistance in Inches Sensor 3: ");  //Prints the line "Distance in Inches Sensor 3:"
 Serial.print(Prox03);                               //Prints the data from Prox03
 Serial.println("\nDistance in Inches Sensor 4: ");  //Prints the line "Distance in Inches Sensor 4:"
 Serial.print(Prox04);                               //Prints the data from Prox04
 Serial.println("\nDistance in Inches Sensor 5: ");  //Prints the line "Distance in Inches Sensor 5:"
 Serial.print(Prox05);                               //Prints the data from Prox05
 Serial.println("\n-------------------------------");
*/
Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: patduino on Nov 25, 2012, 04:28 am
Hi Matt,

Sorry, but I didn't read all of your code...  I just jumped to your comment:

Quote
detect an object 25 Inches away, it turns the servo a degree. Then when it goes to 24, turns the servo 2 degrees and so on and so forth


Why not use a simple formula to calculate the avoidance angle? Something simple like the following: 26 degrees - Distance in inches, although this may not work at the extremes. 

You could alternatively use if statements to divide the problem up.  If 20 to 25 inches away, do what I said earlier... else if 10 to 20 inches away, turn closer to 90 degrees... else go in reverse. 

That, or shoot a Nerf gun at it!
Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: wildbill on Nov 25, 2012, 01:24 pm
How are your five sensors oriented? Ignoring code for a moment, what's your navigation algorithm for using the data from them? If you can describe that, it'll likely make it easier to translate into your sketch.
Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: sora628 on Nov 25, 2012, 03:29 pm
Sorry about that--what better way to describe it than show pictures??

Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: patduino on Nov 25, 2012, 04:38 pm
Very cool.  Giraffe might be a better name for it!

I forget... what exactly are you asking about?  Are you looking for help writing the algorithm, or for help controlling the motors?

Pat.
Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: sora628 on Nov 25, 2012, 06:17 pm
Haha thanks!  I'm looking to improve the algorithm for obstacle avoidance, but I'm not sure how to do it.  Instead of listing a million if statements, I wasn't sure if I could accomplish this with a few for or while loops.  Can it be done?
Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: PaulS on Nov 25, 2012, 09:02 pm
Code: [Select]
DistanceGP2Y0A21YK Dist01;  //defines Dist01 as the sharp GP2Y0A21YK
Really? I'd never have guessed.  :)

Code: [Select]
  Dist01.begin(A0);    //tells program "Dist01" will be used by the serial monitor
That statement does NOT do what the comment says.

You should look at arrays for similar things.

Code: [Select]
/*

Although below, it says "getDistanceCentimeter", it really converts the data into Inches---make a very big note for this!!

*/

Or get smart and rename the function.

Code: [Select]
if ((Prox01 <= 10) || (Prox02 <= 10))
  Steering.write(125);
else if ((Prox04 <= 10) || (Prox05 <= 10))
  Steering.write(65);
else if ((Prox01 <= 15) || (Prox02 <= 15))
  Steering.write(115);

This collection of if tests is way too complicated. There has to be a simpler way.

How are the sensors oriented?
Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: oric_dan on Nov 25, 2012, 09:37 pm
On non-program matters, you might want to try mounting the IR rangers in vertical
orientation, rather than horizontal, see page 6 here,

http://sharp-world.com/products/device/lineup/data/pdf/datasheet/gp2y0a21yk_e.pdf

Also note, these devices take 50-msec to average a bunch of readings, so if your bot is
moving or especially rotating, you can get flukey results. It's always best to use different
kinds of sensors on robots for best results, eg adding sonars.
Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: sora628 on Nov 26, 2012, 03:35 am
well, I probably should have looked at that before I mounted them....the readings seem to be fine though.......and Paul, sorry about that...I'm a bit lazy with commenting and stuff.....And aren't sonars a lot of money?  Do they make cheap ones?  And I'm going to end up buying longer ranged sensors to go along with these, probably mounted higher up--and the whole reason I posted on the forum was to make the algorithm better Paul!! :)   Any ideas?
Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: wildbill on Nov 26, 2012, 01:10 pm

Haha thanks!  I'm looking to improve the algorithm for obstacle avoidance, but I'm not sure how to do it.  Instead of listing a million if statements, I wasn't sure if I could accomplish this with a few for or while loops.  Can it be done?


It seems that the fundamental thing you need to decide is what you want to do with the data from the sensors. Steer towards the one that sees no obstacle? SLAM? Build a more rudimentary map of your surroundings? Turn towards the biggest gap when the forward sensor sees an obstacle? Learning and mapping will be hard to do given the limited memory the Arduino has of course.
Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: sora628 on Nov 26, 2012, 10:46 pm
The end goal for this robot is for it to be able to navigate threw an "obstacle course" getting from point a to b using the gps, compass, and sensors.
Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: rgallant on Nov 26, 2012, 11:16 pm
Hi,

Just to make sure I understand what you what the sensors to do, no code thoughts here.

You are using the sensors strictly to determine how close you are to an object and ideal stay a given distance away to avoid collisions, or to stay centered in a "lane" between obstacles.

If I am correct, try mapping the sensor cones on paper.  Then put obstacles in to the cones figure out what you would need to do to avoid the collision.  In most cases it will be nothing, I think your approach will result in constant left / right servo movements that will result in a net nothing.

I agree with PaulS that there has to be a simpler way to code it.  I think you are over thinking the collision sensors.

Start with the front, left and right, ignore the two corner sensors.  Set a given distance where you think a collision is likely to occur for each group, all you initially do is check if you are over that range, if you are keep on motoring.  At the point any of the groups goes under the range then deal with the problem.  I would also set a dead stop range, where you know there is no way to avoid a hit easily. Get the code for the 3 sensors working then deal with the corners.

I may be telling you how to suck an egg, in which case I apologize. But when I look at it I think of driving down nasty little roads in my 4 wheel drive. If in doubt stop look and hedge to one side.  Move ahead slow and easy, with small corrections,and always remember hit the mountain don't go over the cliff.
Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: wildbill on Nov 26, 2012, 11:18 pm
Given the gps and compass, I'd be tempted to start there, assuming that points a and b are known gps coordinates. Solve it for the simple case where there are no obstacles and simply drive along the rhumb line until you arrive. Then add obstacle avoidance algorithms.
Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: sora628 on Nov 26, 2012, 11:53 pm
The reason I posted here was to get help improving the algorithm!!  Is it possible to use for loops to improve the algorithm?  My current setup with this algorithm works well with hallways and enclosed spaces with walls.  I'm going to have to buy longer ranged sensors soon, but my main provider is out of stock!  And I'm not entirely sure where I will mount them.....that block of wood in the front actually adds a lot of weight and makes it hard for the car to steer if it isn't moving--maybe I'll buy a more powerful servo while I'm at it.....

And wildbill, I've tried starting there, and I've also made a post about that, but I've had no one really help me with that, and everyone is saying my GPS will not be accurate enough, and that I'll need to set up GPS differential--but I plan on saving that for the next model of the robot.   Is there any way you'd be able to start me off with the basics of going from point a to b?  And doesn't that require the use of interrupts? I started to use interrupts and I've not been very successful--Is it possible to have all the statements in the same main loop instead of having to use interrupts?

-Matt-
Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: wildbill on Nov 27, 2012, 01:16 am
What I've been trying to suggest is that you're confusing the algorithm with the code. There are very likely more efficient ways to write the code, but the real problem is figuring out how to use the information the sensors are giving you and the code follows from that. Assuming that you were wearing a blacked out motorcycle helmet with the compass, gps and five ping sensor data on a heads up display, what would you do to navigate between your waypoints using that info?

Having said that, what scale is your course? You mention walls and enclosed spaces, so I'm guessing not very big, and likely has no gps reception, so my previous suggestion seems moot. You're down to dead reckoning now, so encoders on the wheels would be nice. Without that, how do you plan to tell where you are and where your destination is? How nasty will the obstacle course be - will you need to navigate a little maze or is it just avoiding a few small cushions strewn along the way?

Depending on the answers to the above, this could turn out to be very hard and likely require additional storage for mapping data, or reasonably easy but with no guarantee that the robot will always be able to find its way.
Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: sora628 on Nov 27, 2012, 01:36 am
It isn't really a set made course, most likely going to be a local park (with trees) and another test using this algorithm specifically would be inside my high school hallways, which are about 10 feet from wall to wall.  It won't be navigating through tiny obstacles, most likely large courses to get from point a to b, and there will most likely be a large gap between the two points.  I'm thinking of using some rotary encoders on the wheels not to see how far the car has traveled, rather to see how fast it is going.  I want to keep this as simple as I can, without spending too much.  Have you ever heard of the AVC by sparkfun?
Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: oric_dan on Nov 27, 2012, 05:55 am
Quote
well, I probably should have looked at that before I mounted them....the readings seem to be fine though.......and Paul, sorry about that...I'm a bit lazy with commenting and stuff.....And aren't sonars a lot of money?  Do they make cheap ones?


Ping sonars cost $25 or so. Rather than spend a lot on many fixed sensors, I've usually mounted
one [of each type] on a panning servo head. The reason I mentioned the measurement problem
with the Sharp IR rangers is that I once built a robot to test that device, although it only had a
single ranger, and a lot of times it tried to climb up the wall instead of turning at it. And it wasn't
my algorithm was the problem either.

The thing about robot sensors is that the people who have the most experience with them realize
they are the real Achille's Heel of robotics, and you need to use multiple redundant types for
best results. Jo Jones goes on and on about this in his book, good read,

http://www.amazon.com/Robot-Programming-Practical-Behavior-Based-Robotics/dp/0071427783
Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: wildbill on Nov 27, 2012, 01:25 pm
Quote
It isn't really a set made course, most likely going to be a local park (with trees) and another test using this algorithm specifically would be inside my high school hallways


These are two very different requirements. If the ultimate goal is the park and the distances are large enough, gps and the compass can play a major part. The moment you go indoors though for testing, all that's changed. Can you test outside instead at your school? You can of course do both - use the gps if it's getting signal and revert to dead reckoning if not, but then you've made everything significantly harder.
Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: sora628 on Nov 28, 2012, 10:50 pm
I usually do testing outside, but given the season and the weather in New York, U.S., it's rather difficult to do that kind of testing---And I don't dare take those electronics outside unless everything is dry and the parts have been somewhat warmed up.   The reason I want the longer ranged sensors as well is so I can work the code both inside and out, with accurate results.  But the mainly they'll be used outside.  And are there any good tutorials on how to get an arduino rc car to work the way I want it to with a GPS?  I've definitely seen tens of hundreds of AGV's, but no real tutorials on how to get an AGV from point "a" to "b"
Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: oric_dan on Nov 28, 2012, 11:39 pm
I suspect the longer-range Sharp IR rangers will do even less well than the shorter
range ones with a moving/turning robot, for the reasons mentioned = triangulation
and 50-msec sampling times with multiple samples. OTOH, sonars should do a little
better, especially if you get the ones with larger beam patterns. Check out Maxsonars.
Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: rgallant on Nov 28, 2012, 11:46 pm
It does all seem to be flight based that's for sure.  But can you define your parameters a bit better, when you say navigate via gps do you mean move from known starting point to a known waypoint ?  Or from a known start point to a waypoint that is identified by a system other than gps coordinates ?

If it is the 1st option try this link http://letsmakerobots.com/node/19554 (http://letsmakerobots.com/node/19554) you may have found it already but there is some useful info there.
Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: PaulS on Nov 29, 2012, 12:03 am
Quote
And are there any good tutorials on how to get an arduino rc car to work the way I want it to with a GPS?

First, explain how the GPS will see any satellites when indoors? Do you have several satellites on your ceiling?
Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: sora628 on Nov 29, 2012, 12:29 am
Sorry--I'm not planning on using the robot indoors, only to test the IR sensors.  I wish I had that kind of money to install satellites in my ceiling  :P

But seriously, are there any tutorials for OUTDOOR use and what I explained earlier?
Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: sora628 on Nov 29, 2012, 12:33 am

It does all seem to be flight based that's for sure.  But can you define your parameters a bit better, when you say navigate via gps do you mean move from known starting point to a known waypoint ?  Or from a known start point to a waypoint that is identified by a system other than gps coordinates ?


Sorry--didn't see your post!

what do you mean flight based? And navigating for starters will consist of the Arduino knowing its current position and the coordinates of the goal it want to get to.  Later programming might involve other waypoints, but right now I'm sticking with going from point "a" (current position) to "b" (another, known position--but not the current position)

Also a next revision is probably going to include GPS differential, but that's a bit out of my reach currently
Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: rgallant on Nov 29, 2012, 12:37 am
Sorry that was badly worded most of the examples are for some form of aircraft.  But that link I added should give you a start on navigating from waypoint to waypoint.
Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: sora628 on Nov 29, 2012, 12:43 am
I cannot tell you how much this is really going to help me!! The GPS library is the same one I use, but for a different GPS, and I have the same digital compass!  Thanks a bunch!!  But back to the obstacle avoidance---any advice/ ideas to get me going?
Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: rgallant on Nov 29, 2012, 01:01 am
I have some ideas, but currently I have just started playing with ping sensors ,the mail man was good to me today.

I will play around a bit and see what I can come up, I want to build an autonomous tank so it fits in.

The big issue I see with the small servo movements, is sort of a constant left/right turn effect if the the range and time is too small.

If your current code gets you down halls pretty centered then perhaps the problem is more defining a minimum distance.  So if we are with in X distance on the left side adjust to steer right a bit and move forward.  You have a forward arc set up it should be possible to tweak the settings to curve away from or around obstacles.  Which is what you want to accomplish in general terms.

Let me put some thought into this, I need to scrawl some stuff on paper and scan it so it makes sense. I can see in my mind what you want to do, but it is the end of a long work day and I keep coming up the gibberish.

Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: oric_dan on Nov 29, 2012, 03:02 am
Do a search on "robomagellan" for background material on GPS and
outdoors travel.
Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: sora628 on Nov 29, 2012, 06:04 pm
So the whole reason I started this project was for a program in my high school called the Authentic Science Research Program.   I'm not sure if you've heard of it or not--we apply to the Intel talent search senior year.  I'm currently a junior.  Currently, I want to do a study on something in the robotics category, but it looks like I'm going to study obstacle avoidance.  Does anyone have any ideas for a research topic for me?  I need some sort of "question" that hasn't been answered or something that has never been done before.  Maybe create a new obstacle avoidance method, I'm not sure---but any ideas?
Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: AntR on Nov 29, 2012, 06:26 pm
For algorithms, consider using a Braitenberg "algorithm" for you avoidance mechanism.  This works well as a "background" always on behaviour.

http://en.wikipedia.org/wiki/Braitenberg_vehicle

Also consider Potential fields - might work better with your multiple sonar setup:

http://www.cs.mcgill.ca/~hsafad/robotics/index.html
Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: sora628 on Dec 01, 2012, 01:15 am
I've seen the potential field method before, and it seems to have its various drawbacks.  Maybe improving one of these methods might make a good research topic.......also, would I have to use interrupts to make the GPS tell the car to go from point "a" to "b" and have the car avoid obstacles along the way?
Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: PaulS on Dec 01, 2012, 01:30 am
Quote
also, would I have to use interrupts to make the GPS tell the car to go from point "a" to "b" and have the car avoid obstacles along the way?

Do you understand what interrupts are? A ringing phone is an interrupt. It occurs at random times, needs pretty much immediate attention, and is externally caused. Which of those attributes applies to you (not the the GPS) telling the car to go from point a to point b? How will you define point b? All the the GPS does is tell the car where it currently is. It still needs to figure out where point b is in relationship to where it is now, and make the appropriate turn(s) to move in the direction of point b, until "here" is point b.
Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: oric_dan on Dec 01, 2012, 01:34 am
For background on pathfinding, look up the A* Algorithm.

Quote
something that has never been done before.


Good luck. Do you know how many grad students there have been at MIT and CMU
trying everything and its cousins in regards robotics. Zillions upon zillions.

OTOH, to me, to a large extent robotics bogged down in the 90s, when a lot of people
started using subsumption and really went nowheres. AI-robotics kind of stalled, although
there have been some "minor" advances in the 2000s. For many years, people in robotics
clubs did little more than build line-followers and mini-sumos. At least robot soccer and
robomagellan were a huge step up.

If you're interested in following up robotics in your future education, learn AI and apply it
to robotics. There are too many dumb robots around.
Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: sora628 on Dec 01, 2012, 02:15 am

Do you understand what interrupts are? A ringing phone is an interrupt. It occurs at random times, needs pretty much immediate attention, and is externally caused. Which of those attributes applies to you (not the the GPS) telling the car to go from point a to point b? How will you define point b? All the the GPS does is tell the car where it currently is. It still needs to figure out where point b is in relationship to where it is now, and make the appropriate turn(s) to move in the direction of point b, until "here" is point b.



Yes, I understand interrupts and I created a program which was originally going to use interrupts for the car, but stopped because I needed the algorithm and GPS code first.  I thought I would have to use interrupts to constantly check the IR sensors, and when they detect something within a certain range, avoid the obstacle, then get back on course.   Point a is the starting location and point b is the goal location.  I didn't mean use interrupts in the GPS literally---maybe my wording is just bad.......but I thought in order to read from sensors and go to a place, I would need interrupts.  Does this still hold true?
Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: sora628 on Dec 01, 2012, 02:17 am

If you're interested in following up robotics in your future education, learn AI and apply it
to robotics. There are too many dumb robots around.


I'm sorry but just for clarification AI is artificial intelligence right?  Just want to make sure---and what exactly would it do for robots? I'm not fully understanding what you mean.... :-/
Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: PaulS on Dec 01, 2012, 03:31 am
Quote
but I thought in order to read from sensors and go to a place, I would need interrupts.  Does this still hold true?

I don't think so. If the car/robot/UGV is moving at 60 mph, you might. At more reasonable speeds, polling is usually good enough.
Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: sora628 on Dec 01, 2012, 03:42 am
So just run through a loop of checking GPS data, updating servo, check IR sensors(in a while loop), and if there is a "problem" (ie--obstacle in the way) avoid the obstacle, then go back to the gps?
Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: oric_dan on Dec 01, 2012, 03:56 am
Quote
I'm not fully understanding what you mean


AI is about intelligence. Most robots are not very intelligent.
Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: cr0sh on Dec 01, 2012, 06:48 am

Quote
I'm not fully understanding what you mean


AI is about intelligence. Most robots are not very intelligent.


Actually, AI today seems to be more focused on statistics and probabilities than anything else.

For the OP: If you are serious about this project, you'll want to take a few online (but free) classes. They will teach you a lot; also - if your knowledge/understanding of probabilities, statistics, and linear algebra is lacking, you'll want to brush up on those, first - ask me how I know...

Anyhow - here are the classes:

http://www.udacity.com/course/st101 - Intro to Stats
http://www.udacity.com/course/cs271 - Intro to AI
http://www.udacity.com/course/cs373 - AI for Robotics
https://www.coursera.org/course/ml - Machine Learning

You might also check out some of the other offerings; there are many other classes which could be beneficial from a robotics and AI/ML standpoint.

The "CS271 - Intro to AI" is a recent addition to Udacity's lineup; it was only recently announced. It, along with the Machine Learning course from Coursera, were the two original "free online" courses brought out by Stanford last fall/winter of 2011. I took both, but I ended up having to drop out of the AI class about halfway through due to personal issues related to my employment. I went on to complete the ML class, then earlier this year (spring 2012) I took the "CS373 - AI for Robotics" class from Udacity (Coursera and Udacity both were spinoffs that grew out of those original two Stanford classes; this was done so as not to dilute the Stanford brand and recognition, while being able to bring more courses and such to a wider audience).

I found the CS373 class to be very challenging - you basically learn enough in it to "build" (well, program) a simplified version of a self-driving, path-planning robotic vehicle, much like Google's self-driving car (take a guess as to who Prof Sebastian Thrun is, and what his relationship is to robotics and Google's car)...

The "Intro to AI" and "Machine Learning" courses are more generalized; geared toward a broad overview and application of AI/ML algorithms to computing problems in general - but I found them very interesting, and one guy in the ML course created this based on his learning and study:

http://blog.davidsingleton.org/nnrccar

...so you can see that all of these courses have application and knowledge which can transfer to robotics, path-planning, navigation, etc.

I'm personally glad that Udacity brought back the "Intro to AI" course; many people were wanting it back, and when I had to drop out, it was during a very difficult time for me, and I hated having to do it. I intend to go back and take the course again, as I found it very instructive and informative (and it wasn't easy, either - I'm also going to take that intro to stats course as well - if there is one thing these courses have taught me, it's that I am very lacking in my understanding of statistics and probabilities, and understanding of both are needed for modern AI/ML algorithm implementations).

Oh - one other thing - that CS373 course offers one of the best explanations of the PID algorithm I have ever seen; you go from zero understanding of PID, to implementing the P, then the D, then the I (they do it this way to prove a point about the algorithm) - and having a real solid understanding of it at the end. The coding was done in Python (whereas the coding for the ML class was done in Octave/MatLab - which is a very cool language all on its own, but takes a bit to wrap your head around the primitives of vectors and matrices - but once you understand how to vectorize an algorithm, the possibility of immense processing power understanding is unleashed; if only I had access to a Beowulf cluster, or a nVidia Tesla machine!)...
Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: oric_dan on Dec 01, 2012, 07:12 am
]Might be a bit much for one sitting.
OP is 16-YO.
Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: wildbill on Dec 01, 2012, 10:40 am

]Might be a bit much for one sitting.
OP is 16-YO.


Perhaps, but that CS373 course is excellent. Even if the OP doesn't take it all in on the first sitting, it's worth doing because it'll be an eye opener on just how hard the problem domain is.
Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: sora628 on Dec 01, 2012, 12:43 pm
I looked at the course with Sebastian Thrun recently, and I'll look into them in the future.  So if I understand, A robot has artificial intelligence if bases its movements on probability, as well as the real world interface and sensing?  And I would also assume that it is programmed to react to every possible scenario that could ever happen--am I correct?
Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: oric_dan on Dec 01, 2012, 07:46 pm
Quote
So if I understand, A robot has artificial intelligence if bases its movements on probability, as well as the real world interface and sensing?  And I would also assume that it is programmed to react to every possible scenario that could ever happen--am I correct?


Well, this is a little optimistic. Thrun wrote a book called Probabilistic Robotics, and his
robot driving course material comes straight out of this book [except for the Python
programming stuff]. He believes the best way to interpret sensor data is probabilistically.

Also, one of the prime areas of AI research is currently in Bayesian Networks, which are
also a probabilistic fabrication. However, there are many many many other methodologies
at use in AI, which would be covered in an introductory course.

Also, the idea of "react to every possible scenario" is a deeply philosophical question, that
has been discussed for decades. Practically speaking, most AI systems function in a
relatively limited domain, and would fail immediately if loosed upon the world in general.
Even humans cannot deal with every possible scenario very well, so it might be a while
before AI systems and robots are able to.

Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: sora628 on Dec 02, 2012, 02:30 pm
Well, I have to say thanks to everyone for the help, and I'm going to start a new post today about working the GPS and compass together into the robot to make it go to specific waypoints--Hope to see you all there!
Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: cr0sh on Dec 02, 2012, 09:56 pm

I looked at the course with Sebastian Thrun recently, and I'll look into them in the future. 


If, as another has stated, you are really only 16 years old, you will likely -not- want to jump into the Udacity CS373 course on first go; I would say do the courses in roughly the order I placed them in (although I would place the machine learning one from Coursera at the same level or slightly below that of the CS271 course from Udacity).

If you don't have at least a good basic level of understanding of probability and statistics, you will get lost very quickly. I found that out myself when I took the ML course and the CS373 course; I had to do some remedial cramming over at the Khan Academy (highly recommended, btw) to brush up on those skills. You'll also want a good base level of understanding of linear algebra, and vector/matrix math.

I don't know what your level of understanding is on any of these; I know when I was your age (a couple of decades ago), such concepts were given fairly short amounts of time for learning, then on to the next thing (IIRC, the vector/matrix stuff was taught far more than the other topics). Your experience might be different.


So if I understand, A robot has artificial intelligence if bases its movements on probability, as well as the real world interface and sensing? 


No - the basic concepts behind probabilistic robotics is that a robot can't know where it is in an environment until it takes a measurement, and when it does, it can't trust that measurement implicitly, because all sensors have an range of error. Also - if you set a robot down in an unknown environment, and it takes a measurement of it's environment, that doesn't give it much knowledge about where it is at in the environment. It must "move" in some manner, and take another measurement. Of course, this movement may not be exact either (it has it's own error range) - so that has to be taken into account as well. On the second measurement, though, it can then compare what it has to what was measured before, and thus build up a "confidence map" of where it is located in the environment. Do this kind of thing over and over, and you ultimately can build a map of the environment (to a certain level of confidence - it will /never/ be exact, but merely a good model/interpretation) and know (again, to a certain level of confidence) where in that environment the robot is located.

That is the basic idea behind the concept of SLAM (Simultaneous Localization And Mapping) - see this wikipedia article (and also check the link to "SLAM for Dummies" in the external links):

http://en.wikipedia.org/wiki/Simultaneous_localization_and_mapping

...it should be noted that SLAM is a problem far from being solved. Professor Thrun makes this point several times in the Udacity CS373 course (though looking at how well the Google self-driving car handles, you would think it was!)...


And I would also assume that it is programmed to react to every possible scenario that could ever happen--am I correct?


That's the point behind probabilistic robotics - you /can't/ program a robot to react to every possible scenario. Instead, through using various machine learning algorithms (it should also be noted that you can't just "pick one" and stick with it - real robots using PR systems utilize many/multiple systems in a collaborative fashion - sometimes even these are linked in a probabilistic fashion so that one system can't always override another), you can (hopefully) give the robot enough tools to sense and learn about the environment on the fly, and come up with solutions to unique or novel situations that present themselves, on the fly.
Title: Re: Obstacle avoidance with an UGV -HELP PLEASE-
Post by: sora628 on Dec 03, 2012, 01:04 am
Thanks cr0sh!