Go Down

Topic: Obstacle avoidance with an UGV -HELP PLEASE- (Read 6 times) previous topic - next topic

sora628

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?
-Matt-

PaulS

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?

oric_dan

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.

sora628

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?
-Matt-

wildbill


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.

Go Up