go_away

Author Topic: Identifying a geometrical shape  (Read 2967 times)

0 Members and 1 Guest are viewing this topic.

Offline ukeshTopic starter

  • Full Member
  • ***
  • Posts: 107
  • Helpful? 0
Identifying a geometrical shape
« on: July 25, 2009, 07:53:21 AM »
hi!

Im building a bot for a college competition. its basically a line follower event, but with more complexities. The bot must traverse the path and along the path there will be certain geometrical shapes which the bot must traverse through and also identify the shapes.

The track definition:
The central track comprises of a circle (a smooth, closed curve to be frank). A
number of lines normal to the curve will feature on the circumference. These lines
would be terminated by geometrical figures (square/rectangle/triangle/circle). The
task given to the bot is to recognize all the geometrical figures that branch off from
the given central track. A discontinuity in the main track will serve as the start/stop
point.

So, is it possible to identify the shapes just with the IR sensors or do i have top use a camera??



Offline jka

  • Full Member
  • ***
  • Posts: 78
  • Helpful? 4
Re: Identifying a geometrical shape
« Reply #1 on: July 25, 2009, 09:23:28 AM »
That is a very interesting task. I think it might be possible to do it with just the IR sensor.

To check if I understand the drawing correct. You have a large circle that you move along. On this circle there are paths going out, which you have to follow. At the end of the path there is a shape, that you have to follow round, return to the path and back to the large circle and continue to the next path. During this, you have to say what shape the object and the end of the path is. Correct?

The first task is to make sure that you go through all paths. Lets say that you traverse the large circle clockwise. Each time you have a path to your left, you follow that. This way, you should be able to traverse the whole path.

Second, you have to know when you are traversing the geometrical shape and when you are moving between shapes. Since you start on the big circle, the first time you find a new path on you left is the path to the shape. Next time, it's the shape, so set a flag in your program that tells the bot that you are traversing the object. Fourth time, you are going back down the path, so you should reset the flag, until you come to the next object (which you will know by counting left turns).

Third, is the hard one. Identifying the objects. You should be able to do this, by looking at how much you have to turn right, whenever you are inside the shape. If it's a small amount, you are on a circle. If it's > 90 degrees, you are at a triangle and if it's 90 degrees, you are at a box. You can also count the number of right turns as a backup measurement. To tell the two boxes apart, you have to time how long the sides are, to know if it's the square or not.

Hope this helps and good luck. Please remember to post information and video on how you are progressing.

Offline ukeshTopic starter

  • Full Member
  • ***
  • Posts: 107
  • Helpful? 0
Re: Identifying a geometrical shape
« Reply #2 on: July 25, 2009, 09:55:48 AM »
Quote
To check if I understand the drawing correct. You have a large circle that you move along. On this circle there are paths going out, which you have to follow. At the end of the path there is a shape, that you have to follow round, return to the path and back to the large circle and continue to the next path. During this, you have to say what shape the object and the end of the path is. Correct?
Absolutely correct man.
Quote
Second, you have to know when you are traversing the geometrical shape and when you are moving between shapes. Since you start on the big circle, the first time you find a new path on you left is the path to the shape. Next time, it's the shape, so set a flag in your program that tells the bot that you are traversing the object. Fourth time, you are going back down the path, so you should reset the flag, until you come to the next object (which you will know by counting left turns).
Hmm..How do i set the flag? And what is the use of this actually? Sorry..i didnt understand this step.
Quote
Third, is the hard one. Identifying the objects. You should be able to do this, by looking at how much you have to turn right, whenever you are inside the shape. If it's a small amount, you are on a circle. If it's > 90 degrees, you are at a triangle and if it's 90 degrees, you are at a box. You can also count the number of right turns as a backup measurement. To tell the two boxes apart, you have to time how long the sides are, to know if it's the square or not.
So..If im in a box and im turning right, so the angle would be 90degrees. How do i calculate the degrees turned and use it in my program?
Quote
Hope this helps and good luck. Please remember to post information and video on how you are progressing.
Thnx a ton mate!

Offline jka

  • Full Member
  • ***
  • Posts: 78
  • Helpful? 4
Re: Identifying a geometrical shape
« Reply #3 on: July 25, 2009, 10:03:49 AM »
Quote
Hmm..How do i set the flag? And what is the use of this actually? Sorry..i didnt understand this step.

It's just a variable in the code. I don't know what programming language you are using, but if it is C you can do something like

int inside_shape;

When you enter the shape, you go

inside_shape = 1;

and when you leave, you go:

inside_shape = 0;

Then later in your code you can look at the inside_shape variable to check if you are inside the shape. If you are outside the shape (the inside_shape flag is 0), you don't need to consider the angles etc.

Quote
So..If im in a box and im turning right, so the angle would be 90degrees. How do i calculate the degrees turned and use it in my program?
That depends on your robot. If you are using step-motors, you can count the number of steps you need for your robot to turn 90 degrees. If you are using regular motors, you need to time how long time it takes for the robot to make the turn.

What you basically need to do is, when you discover that the line is not longer in front of you, how long time (or how many step motor steps) does it take to turn the robot, until it is in front of you again.


Offline ukeshTopic starter

  • Full Member
  • ***
  • Posts: 107
  • Helpful? 0
Re: Identifying a geometrical shape
« Reply #4 on: July 25, 2009, 10:41:00 AM »
thnx for the help man.
Quote
What you basically need to do is, when you discover that the line is not longer in front of you, how long time (or how many step motor steps) does it take to turn the robot, until it is in front of you again.
I will be using DC motors for my bot. how can the time taken be found?


Offline jka

  • Full Member
  • ***
  • Posts: 78
  • Helpful? 4
Re: Identifying a geometrical shape
« Reply #5 on: July 25, 2009, 12:10:52 PM »
Quote
I will be using DC motors for my bot. how can the time taken be found?

A stopwatch? :)

Draw a box and a triangle on some paper and try to measure the time spend rotating.

Remember that your robot might move left/right, if it is not going along the line to get back to the line. This is of course not considered as turning, so you should consider that a turn should only "count" if it is larger than a certain value (that you have to find by trying) so going left-right-left-right... to stay on the line does not count as turning a corner when you try to decide what shape you are going round.

Offline ukeshTopic starter

  • Full Member
  • ***
  • Posts: 107
  • Helpful? 0
Re: Identifying a geometrical shape
« Reply #6 on: July 25, 2009, 09:28:34 PM »
Quote
I will be using DC motors for my bot. how can the time taken be found?

A stopwatch? :)

Draw a box and a triangle on some paper and try to measure the time spend rotating.

Remember that your robot might move left/right, if it is not going along the line to get back to the line. This is of course not considered as turning, so you should consider that a turn should only "count" if it is larger than a certain value (that you have to find by trying) so going left-right-left-right... to stay on the line does not count as turning a corner when you try to decide what shape you are going round.

cool man. thnx:) and hey could you help me out with the programming part. Il be using C language. I guess the program for this will use a lot of if else loops. So can u give me some ideas for using functions for specific tasks like identifying shapes etc.

Offline jka

  • Full Member
  • ***
  • Posts: 78
  • Helpful? 4
Re: Identifying a geometrical shape
« Reply #7 on: July 26, 2009, 12:43:09 AM »
Quote
cool man. thnx:) and hey could you help me out with the programming part. Il be using C language. I guess the program for this will use a lot of if else loops. So can u give me some ideas for using functions for specific tasks like identifying shapes etc.

Since you mentioned in the first post, that this is a competition, I think it would be unfair if you got too much help. The best thing you can do is to start out and then if you get stuck, ask questions here on the board and see if someone can help you.

Offline ukeshTopic starter

  • Full Member
  • ***
  • Posts: 107
  • Helpful? 0
Re: Identifying a geometrical shape
« Reply #8 on: July 26, 2009, 04:40:22 AM »
Quote
cool man. thnx:) and hey could you help me out with the programming part. Il be using C language. I guess the program for this will use a lot of if else loops. So can u give me some ideas for using functions for specific tasks like identifying shapes etc.

Since you mentioned in the first post, that this is a competition, I think it would be unfair if you got too much help. The best thing you can do is to start out and then if you get stuck, ask questions here on the board and see if someone can help you.

 ;D ;D ;DSure:) il start preparing and get back here if i stuck up somewhere.

Offline wil.hamilton

  • Robot Overlord
  • ****
  • Posts: 207
  • Helpful? 6
  • rtfm
Re: Identifying a geometrical shape
« Reply #9 on: July 26, 2009, 09:41:04 AM »
Quote
So..If im in a box and im turning right, so the angle would be 90degrees. How do i calculate the degrees turned and use it in my program?
That depends on your robot. If you are using step-motors, you can count the number of steps you need for your robot to turn 90 degrees. If you are using regular motors, you need to time how long time it takes for the robot to make the turn.

No!  Do not use timing.  This is BAD!  Will it work? Maybe.  Will it work all the time? No! 
using timing in robotics for motion control is generally a bad idea because it can change.  As your robots battery drains the motors get less and less power and your timing will get thrown off.

if you need to keep track of how much your robot turns use encoders which count how far/how many times a wheel has turned.  This value would never change.
use the google.  it's your friend.

Offline ukeshTopic starter

  • Full Member
  • ***
  • Posts: 107
  • Helpful? 0
Re: Identifying a geometrical shape
« Reply #10 on: July 27, 2009, 08:02:24 AM »
Quote
So..If im in a box and im turning right, so the angle would be 90degrees. How do i calculate the degrees turned and use it in my program?
That depends on your robot. If you are using step-motors, you can count the number of steps you need for your robot to turn 90 degrees. If you are using regular motors, you need to time how long time it takes for the robot to make the turn.

No!  Do not use timing.  This is BAD!  Will it work? Maybe.  Will it work all the time? No! 
using timing in robotics for motion control is generally a bad idea because it can change.  As your robots battery drains the motors get less and less power and your timing will get thrown off.

if you need to keep track of how much your robot turns use encoders which count how far/how many times a wheel has turned.  This value would never change.

Im tight on budget mate. :-[ Can modified servos be used?Will those might be useful?

Offline jka

  • Full Member
  • ***
  • Posts: 78
  • Helpful? 4
Re: Identifying a geometrical shape
« Reply #11 on: July 27, 2009, 08:12:23 AM »
Quote
if you need to keep track of how much your robot turns use encoders which count how far/how many times a wheel has turned.  This value would never change.
Unless the surface is too smooth or slippery. If the wheels skip, you will get a different count each time.

Quote
Im tight on budget mate. :-[ Can modified servos be used?Will those might be useful?
Yes, but they don't have encoders, so you need to use time. If you can get your hand on an old computer mouse of the kind that use a ball to track the movement, you can take it apart and find the encoder wheels and sensors that you need. Or you can just use a timer, which I think for this purpose is accurate enough.

Offline MangoBot

  • Robot Overlord
  • ****
  • Posts: 185
  • Helpful? 1
Re: Identifying a geometrical shape
« Reply #12 on: July 27, 2009, 08:34:23 AM »
what if you made a system that measured the agles where it turns because if they are all normal shapes then each shape will have the same angle on everyone of its vertices.

Offline jka

  • Full Member
  • ***
  • Posts: 78
  • Helpful? 4
Re: Identifying a geometrical shape
« Reply #13 on: July 27, 2009, 08:42:43 AM »
Measuring the angle is done by measuring how long time it takes to turn the corner. The time it takes can be measured by time, wheel encoders or steps if using stepper motors.

Another idea.

Use a lot of the ir sensors that you use to see if you are on a line or not. Arrange them in a grid. When you are on top of a corner, the sensors will detect an "image" of the corner, which you can use to identify the shape. It's like a very small resolution camera.

Offline ukeshTopic starter

  • Full Member
  • ***
  • Posts: 107
  • Helpful? 0
Re: Identifying a geometrical shape
« Reply #14 on: July 27, 2009, 10:27:00 AM »
Quote
Use a lot of the ir sensors that you use to see if you are on a line or not. Arrange them in a grid. When you are on top of a corner, the sensors will detect an "image" of the corner, which you can use to identify the shape. It's like a very small resolution camera.
I dont get it dude. the IR sensors just show an variation in the voltage, when exposed to white and black colors rite? what do u mean by "the sensors will detect an "image" of the corner"?

Offline jka

  • Full Member
  • ***
  • Posts: 78
  • Helpful? 4
Re: Identifying a geometrical shape
« Reply #15 on: July 27, 2009, 01:21:20 PM »
Quote
I dont get it dude. the IR sensors just show an variation in the voltage, when exposed to white and black colors rite? what do u mean by "the sensors will detect an "image" of the corner"?

If you have a 5x5 array of sensors, you will get a 5x5 pixel image. If you are at a 90degree corner, the center sensor + the two down + the two to the right will detect a line, while the others won't.

Try to take a piece of paper and draw 5x5 dots 5 times. Then draw the corner of each of the 5 shapes through the 5 dot-arrays and see the difference in which dots (=sensors) are on top of the shape.

Of course there is a lot more to it than this. For example, the robot is moving, so the corner will "come into" the array from the top and not just "be there". Also, the corner will not go through the center each time, but you will have a very low res camera type of sensor with this array, where you can do some image recognition. Of course, you could also take a regular webcam and place it on the bottom of the robot, but that would be overkill.

Offline wil.hamilton

  • Robot Overlord
  • ****
  • Posts: 207
  • Helpful? 6
  • rtfm
Re: Identifying a geometrical shape
« Reply #16 on: July 27, 2009, 08:07:54 PM »
as for the cost of encoders, if you use the GM17 from solarbotics you can get an encoder for $10
if you use GM2/3/8/9 you can get a pair of encoders for 42 (you would need at least 2 for this application)
I'm a budget bot builder and I don't find either of those options terribly expensive
use the google.  it's your friend.

Offline ukeshTopic starter

  • Full Member
  • ***
  • Posts: 107
  • Helpful? 0
Re: Identifying a geometrical shape
« Reply #17 on: July 28, 2009, 09:56:24 AM »
Quote
I dont get it dude. the IR sensors just show an variation in the voltage, when exposed to white and black colors rite? what do u mean by "the sensors will detect an "image" of the corner"?

If you have a 5x5 array of sensors, you will get a 5x5 pixel image. If you are at a 90degree corner, the center sensor + the two down + the two to the right will detect a line, while the others won't.

Try to take a piece of paper and draw 5x5 dots 5 times. Then draw the corner of each of the 5 shapes through the 5 dot-arrays and see the difference in which dots (=sensors) are on top of the shape.

Of course there is a lot more to it than this. For example, the robot is moving, so the corner will "come into" the array from the top and not just "be there". Also, the corner will not go through the center each time, but you will have a very low res camera type of sensor with this array, where you can do some image recognition. Of course, you could also take a regular webcam and place it on the bottom of the robot, but that would be overkill.

hm thnx mate. I'll keep this idea and try developing it.

Quote
as for the cost of encoders, if you use the GM17 from solarbotics you can get an encoder for $10
if you use GM2/3/8/9 you can get a pair of encoders for 42 (you would need at least 2 for this application)
I'm a budget bot builder and I don't find either of those options terribly expensive

I live in India. All these with the international shipping rate would cost around an 100$ which is sort of expensive when compared with Indian currency!

Offline wil.hamilton

  • Robot Overlord
  • ****
  • Posts: 207
  • Helpful? 6
  • rtfm
Re: Identifying a geometrical shape
« Reply #18 on: July 28, 2009, 11:47:44 AM »
the GM series motors are fairly popular, i'm sure you could fine a distributor closer to you geographically.  I know there are some out of china you might be able to order from.
use the google.  it's your friend.

Offline Ro-Bot-X

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,431
  • Helpful? 25
  • Store: RoBotXDesigns.ca
Re: Identifying a geometrical shape
« Reply #19 on: July 28, 2009, 09:21:59 PM »
Another option is to use geared DC motors with built in encoders, like this one: http://www.goldmine-elec-products.com/prodinfo.asp?number=G16279 and they have it on sale for just $8! Can't beat that price...

Edit: here is a review of the motor: http://www.robotroom.com/FaulhaberGearmotor.html
« Last Edit: July 28, 2009, 09:23:10 PM by Ro-Bot-X »
Check out the uBotino robot controller!

Offline jka

  • Full Member
  • ***
  • Posts: 78
  • Helpful? 4
Re: Identifying a geometrical shape
« Reply #20 on: July 29, 2009, 02:05:07 AM »
The only problem is that goldmine-electric only ships to

Australia
Brazil
Canada
Hong Kong
Japan
Republic of Korea (South Korea)
Mexico
New Zealand
South Africa
United States (including U.S. protectorates)

http://www.goldmine-elec.com/International.htm

A shame. They have a lot of nice products.

Offline ukeshTopic starter

  • Full Member
  • ***
  • Posts: 107
  • Helpful? 0
Re: Identifying a geometrical shape
« Reply #21 on: July 29, 2009, 09:39:18 AM »
hey! Thnx a lot for ur help guys.:)
i tried writing an pseudo code and i ended up with the following one. these are my conditions i'm using in my code.
I will be using 5 IR sensors. For convenience I am naming the 1st sensor as A, 2nd sensor as B, 3rd as C, 4th as D & finally 5th as M. I am planing to arrange the sensors in the following manner.

{A}{B}    {C}{D}
        
         {M}

I am assuming the direction of the path as clockwise.

pseudo code:

i=0, j=0, k=0; // variables used to check conditions later in the program
while(1)
{
smooth turns(); // function to turn on smooth curves ie the main track
{
if(c<(A&&B))
turn right// at certain speed
else if(B<(C&&D))
turn left// at certain speed
}
tight turns(); // function to turn on tighter track ie. on geometric shapes
{
if((C&&D)<(A&&B))
turn right// at certain speed
j++; // for identifying shapes, i haven't finished that part
display1(); // function to display the identified shape
else if((A&&B)<(C&&D))
turn left
k++;
display2(); // function to display the identified object
else if((A&&C)==M&&(i==0||i==1))
go right // to take right to reach the 1st object
else if((A&&C==M)&&(i>=2)
go left // to reach main track after traversing 2nd shape

display1()
{
if(j==2)
display shape as circle
if(j==9)
display shape as rectangle
}

display2()
{
if((j==9)&&(k==2))
display shape as triangle
if((j==14)&&(k==4))
display shape as square
if(k==6)
display shape as circle
}
}}


Okay guys, this is what i ended up with. I know its very confusing to understand. Now i want to know whether this idea will work out?
« Last Edit: July 30, 2009, 05:02:37 AM by ukesh »

Offline jka

  • Full Member
  • ***
  • Posts: 78
  • Helpful? 4
Re: Identifying a geometrical shape
« Reply #22 on: July 29, 2009, 02:21:59 PM »
I'm not sure what you mean by statements like

if((C&&D)<(A&&B))

Do you mean "If sensor C and D receive less light than A and B"? And if that is the case, is "less light" = detecting the line?

Offline ukeshTopic starter

  • Full Member
  • ***
  • Posts: 107
  • Helpful? 0
Re: Identifying a geometrical shape
« Reply #23 on: July 30, 2009, 05:01:36 AM »
I'm not sure what you mean by statements like

if((C&&D)<(A&&B))

Do you mean "If sensor C and D receive less light than A and B"? And if that is the case, is "less light" = detecting the line?

yea mate

Offline jka

  • Full Member
  • ***
  • Posts: 78
  • Helpful? 4
Re: Identifying a geometrical shape
« Reply #24 on: July 31, 2009, 03:53:19 AM »
It's hard to tell if it works or not. If I was to do this, I would build the robot and try with different sensor placements and different algorithms to see what works best.

Offline ukeshTopic starter

  • Full Member
  • ***
  • Posts: 107
  • Helpful? 0
Re: Identifying a geometrical shape
« Reply #25 on: August 01, 2009, 09:42:51 AM »
k man. thanks for ur help. IL get back with the results.

 


Get Your Ad Here

data_list