### Author Topic: Mapping  (Read 8328 times)

0 Members and 1 Guest are viewing this topic.

#### coolshankrocks

• Beginner
• Posts: 3
##### Mapping
« on: September 11, 2007, 12:27:00 PM »
Hi all.
I am making a project. In which i have a sample area. I need to map the area using ir sensors mounted on a robot. The robot navigates in the area and makes a map of the area indicating locations of obstacles. the area comes out to be like a grid with the obstacles marked as 'x' on the grid. Can someone plz help me out with a algorithm which makes the robot travel in the area and create a map.

#### h3ro

• Full Member
• Posts: 110
##### Re: Mapping
« Reply #1 on: September 11, 2007, 12:33:39 PM »
Check out this link:
http://www.societyofrobots.com/programming_wavefront.shtml

Its with source code!

#### coolshankrocks

• Beginner
• Posts: 3
##### Re: Mapping
« Reply #2 on: September 11, 2007, 10:07:00 PM »
hi. thx for da link. but this link contains an algorithm for travelling once the map is made..
my aim is to create a map. and determine where the obstacles are.

• Supreme Robot
• Posts: 11,672
##### Re: Mapping
« Reply #3 on: September 12, 2007, 06:44:09 AM »
Quote
I need to map the area using ir sensors mounted on a robot. The robot navigates in the area and makes a map of the area indicating locations of obstacles. the area comes out to be like a grid with the obstacles marked as 'x' on the grid.

but this link contains an algorithm for travelling once the map is made..
my aim is to create a map. and determine where the obstacles are.

look again, my algorithm does exactly what you need
it creates a map with a sharp IR, adds obstacles to that map, then plans a path accordingly.

you might find this helpful too
http://www.societyofrobots.com/sensors_sharpirrange.shtml

#### cooldog

• Supreme Robot
• Posts: 751
• be nice to nerds, one day they will be your boss
##### Re: Mapping
« Reply #4 on: November 12, 2007, 06:27:53 PM »
so could he use the \$50 robot with sharp Ir upgrade and just put in a new algorithm as easy as that or are there complications
robot will rule the world and i will be building them

favorite web sites
http://www.societyofrobots.com/
http://www.instructables.com/

#### Half Shell

• Robot Overlord
• Posts: 225
##### Re: Mapping
« Reply #5 on: November 13, 2007, 12:51:42 PM »
CoolShank - I am actually doing the same project right now. Contact me so we can trade what we've got codewise so far.

#### Rebelgium

• Supreme Robot
• Posts: 638
• It's called the future ... We like it here
##### Re: Mapping
« Reply #6 on: November 13, 2007, 01:39:42 PM »
Quote
so could he use the \$50 robot with sharp Ir upgrade and just put in a new algorithm as easy as that or are there complications
Yes.
I don't know if the standard 50\$ robot has wheel encoders, (little discs mounted on your wheels, which show your muC if and how fast they are turning) but you need encoders to do mapping.
To relax after some hard work on robotics: A very fun free online text based MMORPG
orgcrime.net

#### Asellith

• Contest Winner
• Supreme Robot
• Posts: 648
• "I'm a leaf on the wind. Watch how I soar"
##### Re: Mapping
« Reply #7 on: November 14, 2007, 02:01:11 PM »
What kind of accuracy do encoders and IR sensors produce? One of my long term goals for my R2-D2 project is to produce a mouse droid that will enter areas ahead of R2 and map for obstacles. Then send that data back to R2 so he has a more ground level view of things and can plan his initial route accordingly.

Johnny B
Jonathan Bowen
CorSec Engineering
www.corseceng.com

• Supreme Robot
• Posts: 11,672
##### Re: Mapping
« Reply #8 on: November 14, 2007, 02:40:51 PM »
Quote
What kind of accuracy do encoders and IR sensors produce?
Depends on how you use them.

The IR sensors depends on your scan resolution, which depends on your servo accuracy.

Lets say you are sensing at 3ft with a servo accuracy of 2 degrees. To calculate error:
2*pi*4ft/(360/2deg) = 0.14 ft or 1.7 inches
This isn't so bad, unless you factor in the scan time to get this accuracy . . . several seconds . . .
Then there is also error in the depth and mcu ADC conversion, which you may or may not find in the sensor datasheets.

Now for encoders . . . depends on the surface and friction and resolution, etc.

So lets say you have a 5% error in each motion your robot makes. To calculate error for a robot that moves 50 feet:
50ft * .05 = 2.5 ft error
(a lot!)

#### benji

• Supreme Robot
• Posts: 832
##### Re: Mapping
« Reply #9 on: November 23, 2007, 11:01:04 AM »
hey guys ,im goin  for this mapping project also, finally i got a sharp IR wich has a range of 150 cm as maximum.
i checked the datasheet of it but no clue if it has a spreading angle beam,
i know it should be little but is it just a striaght line? cause if there is a little spreading then someone should consider this when rotating the servo (how many degrees) (maybe 2 degrees isnt enough)

that means the more the spreading angle the less readings of range we can make,,if there is any spreading angle

good ol' BeNNy

#### paulstreats

• Supreme Robot
• Posts: 1,381
##### Re: Ultrasonic beam narrowing
« Reply #10 on: November 23, 2007, 11:06:19 AM »
the sharp ir does have a spread angle, but i cant remember off the top of my head. its quite a small angle, but obviously the further away the object, the more it appears spread.

This is why the distance detection is so limited, because as the ir light spreads out, it becomes weaker (inverse square law if anyones interested) and the less light is reflected back off the object

#### benji

• Supreme Robot
• Posts: 832
##### Re: Mapping
« Reply #11 on: November 23, 2007, 02:20:19 PM »
Quote
the sharp ir does have a spread angle,

about how many degrees?
turning the servo only 2 degrees would give a different reading than the reading before it's turned?is the beam that small?

in the sharp ir page in this website the beam is drawn as a straight line hitting an object then turning right into the reciever,, is that totally correct?
good ol' BeNNy

#### paulstreats

• Supreme Robot
• Posts: 1,381
##### Re: Mapping
« Reply #12 on: November 23, 2007, 05:13:48 PM »
its only a few degrees, and turning the servo 2 degrees would give a different reading. The important thing to realize is that the closer the object is (within the distance parameters) the more accurate it will be. at 15cm the circle of light would be about 1 cm at 30 cm distance the light circle would be about 2cm at 45 cm distance the circle would be 4cm at 60 cm the circle would be 16 cm.....

#### benji

• Supreme Robot
• Posts: 832
##### Re: Mapping
« Reply #13 on: November 24, 2007, 01:59:06 PM »
i was thinking to send the bytes of one complete scan cycle to the pc and let the software there build the plan, this way i wont need big rams in my microcontroller and i can build big maps over the pc
,the micro should just tell the robot (after it sees the one cycle scan bytes) where to go (lets say where zeros are) and if there are non it turns to get data from another angle.
what do u guys think of  this?
good ol' BeNNy

• Supreme Robot
• Posts: 11,672
##### Re: Mapping
« Reply #14 on: November 24, 2007, 03:10:16 PM »
Remember that an extremely accurate scan as you describe will be very slow. For example, lets say it takes 100ms per data point (because servos are slow, and the Sharp IR takes like ~60ms to get an accurate reading if I remember correctly).

Now lets say your robot scans 120 degrees (1/3 field of view in front of your robot), with 1 degree accuracy.

120 data point resolution * 100ms per scan = 12 seconds!

I don't think you want your robot to stop for 12 seconds every few feet it moves . . .

And this doesn't even factor in transmission to your PC or processing time . . .

Its always a trade between accuracy and speed.

#### paulstreats

• Supreme Robot
• Posts: 1,381
##### Re: Mapping
« Reply #15 on: November 24, 2007, 06:39:35 PM »
or how long it takes for the a/d conversion...

why not have more than 1 scan function such as moving scan/quick scan/deep scan/point scan

#### DomoArigato

• Full Member
• Posts: 54
##### Re: Mapping
« Reply #16 on: November 24, 2007, 10:34:57 PM »
I have code that does a 2d mapping using the 150cm sharp IR rangefinder and ATMega 128 if you would like to work off it.  Looking back I see lots of room for improvement in the code, but the servo and sensor control code is pretty decent.  Let me know if you would like me to send it to you.  I have it setup with a robostix board, one servo, and one IR rangefinder mounted on an rc car.

• Supreme Robot
• Posts: 11,672
##### Re: Mapping
« Reply #17 on: November 24, 2007, 10:52:50 PM »
good idea Domo

I have some code too, go to the very bottom of this page:
http://www.societyofrobots.com/robot_omni_wheel.shtml

It uses 3 sharp IR at the same time to do 2D mapping (because 3 is 3x faster than 1). But I was definitely a noob when I wrote that code so can't promise you how easy it would be to understand it . . .

#### benji

• Supreme Robot
• Posts: 832
##### Re: Mapping
« Reply #18 on: November 25, 2007, 08:53:57 AM »
well admin, do i need to take a reading each 1 degree???
im actually goin to use the 150 cm sharp IR,so saying i will take a reading each 2 degrees then the sensor will sweep 5cm arc each turn ,(lookslike its hard to miss a chair's foot)
but also with that the time would be 6 secs,,still too long,, using 2 sharps, we got 3 secs ,,(good for a hexapod) ,,,,yea right we still want to figure out how long the adc takes to interpret,,mmm, looking to the datasheet you can minimize the conversion time by using a high freq clock source
i think this time is pretty nigligable
good ol' BeNNy

• Supreme Robot
• Posts: 11,672
##### Re: Mapping
« Reply #19 on: November 25, 2007, 10:12:46 AM »
Quote
well admin, do i need to take a reading each 1 degree???
I was under the impression you wanted less than 2 degree accuracy from your previous posts

The way I do it is my robot takes about 10 to 20 readings in under a second without stopping the servo. The angle information has a high error (10+ degrees?) because of this, but it will never miss a chair leg for sure. Then I angle shift my readings in code to make up for that time lag caused by sensor and ADC lag to try to correct for that error (if your sensor repeatedly does the same thing, you can tweak it until it works perfectly).

#### benji

• Supreme Robot
• Posts: 832
##### Re: Mapping
« Reply #20 on: November 25, 2007, 03:32:11 PM »
Quote
I was under the impression you wanted less than 2 degree accuracy from your previous posts
well yea that was when considering a sonar instead of the sharp ir ,you know big ranges draws long arcs at little angles  .

the error should be only starting at specific angles, of what i understood you should only shift the angles of where the error started until the last reading,, this is a lil compicated to do isnt?
good ol' BeNNy

• Supreme Robot
• Posts: 11,672
##### Re: Mapping
« Reply #21 on: November 25, 2007, 04:48:19 PM »
Quote
the error should be only starting at specific angles, of what i understood you should only shift the angles of where the error started until the last reading,, this is a lil compicated to do isnt?
there will always be fudging and guesswork involved . . .

So if my sensor scans clockwise, I would expect say a -10 degree error (caused by lag) on average (determined from testing). So, obviously I would just do +10 in my code to each degree reading.

And when my sensor scans counterclockwise, I would get say +9 degree error, meaning I subtract 9 from my result.

etc.

Of course, the first step would be to determine your error, and if its 'acceptable enough'.

#### benji

• Supreme Robot
• Posts: 832
##### Re: Mapping
« Reply #22 on: November 26, 2007, 10:57:09 AM »
come on Domo,, we eould be glad to take a look at your code
good ol' BeNNy

#### DomoArigato

• Full Member
• Posts: 54
##### Re: Mapping
« Reply #23 on: November 26, 2007, 07:34:42 PM »
I haven't had time to look at this for a while, and I look back and see lots of room for improvement, but here is the code.  Let me know if you have questions. Download the zip file from this link: http://domoarigatoq.googlepages.com/home

#### benji

• Supreme Robot
• Posts: 832
##### Re: Mapping
« Reply #24 on: November 27, 2007, 11:26:48 AM »
thanks Domo for the code, i took a look at it ,it looks pretty neat,but i noticed that you gave 9 msecs
to wait for the servo to settle,, right?
was that enough??

great if it is
good ol' BeNNy

#### DomoArigato

• Full Member
• Posts: 54
##### Re: Mapping
« Reply #25 on: November 27, 2007, 11:54:51 AM »
Looking back.  No I don't think it's enough.  Here is the post we had up when I was working on this:  http://www.societyofrobots.com/robotforum/index.php?topic=1692.0 .  Most of the conclusions I reached were totally wrong.  I just looked back at the time it takes the rangefinder to refresh, and I misread the diagram.  It takes 38.3msą9.6ms for the first read and it looks like roughly 35 ms for the other  reads.  There is a 5ms delay between the read and the analog signal on the output pin.  The 9ms seemed to work at the time, but looking back it is probably bad data.  Things to keep in mind it will take up to 52.9 ms to get the first read, and after that it will settle into a stable mapping frequency.  I would use between 36 and 40 ms delay (including servo and ADC delay) if your looking for accurate mapping,  I think the 9ms would be fine if you just wanted to avoid hitting stuff, however if that were the case a sonar would be a much better choice.
« Last Edit: November 27, 2007, 11:56:10 AM by DomoArigato »

#### benji

• Supreme Robot
• Posts: 832
##### Re: Mapping
« Reply #26 on: November 28, 2007, 06:17:57 AM »
adc convertion time is 13 clocks in the atmegas of the adc clock freq,, so 1 ms is sp enough.
and about the sonars,, i dont think sonars are a good choice for mapping,, their stupid beam angle can make your code a lot harder..
good ol' BeNNy

• Supreme Robot
• Posts: 11,672
##### Re: Mapping
« Reply #27 on: November 28, 2007, 01:37:09 PM »
Depends on which microcontroller you are using, but the first ADC run takes longer because it needs to 'warm up'

Its considered good practice to read from your ADC a few times during robot startup before you start using the ADC values.

#### benji

• Supreme Robot
• Posts: 832
##### Re: Mapping
« Reply #28 on: November 28, 2007, 04:42:48 PM »
in the atmegas datasheet it says only the first conversion takes 25 clocks,, (still nothing)
and after that it goes 13es
good ol' BeNNy

#### benji

• Supreme Robot
• Posts: 832
##### Re: Mapping
« Reply #29 on: December 01, 2007, 04:01:16 PM »
im sending blocks of memory (one array) after one scan to the copmputer to draw the map block after block, so when the robot turns lets say 45 degrees i need my software over the computer to recieve not only the array but also the angle of the block(array)
the problem is that i need some kind of sensor to have this information,, what can i use?

(i need to specify the orientation of the robot )
i need this sensor (or trick) because considering the robot will not be aligned as it should after let5s say 20 turns ........

any help?
good ol' BeNNy