Let's Make Robots!

Object recognizing

I have written my own coding and got the output in serial terminal window in Program editor for the PART III GET A GRIP. my problem is that how i can differentiate a cup from other object and make the robot understand it. kindly help me i searched the website but i was not able to get it. kindly help me with the code for " how i can make my robot understand that its a cup in front".  i am using PICAXE 28 and SRF005

symbol trig = 3
symbol echo = 6
symbol range = w0
symbol range1 = w1

main:

servo 0,75

pause 10 ' this should not be nesecary, but it was of some reason in my setup

low portc 0 ' this should not be nesecary, but if not, strange things hapened

pause 10 'this should not be nesecary, but that is what makes it all fun

 

pulsout trig,2 ‘ produce 20uS trigger pulse (must be minimum of 10uS)

pulsin echo,1,range ‘ measures the range in 10uS steps

pause 10

range = range*10/58
range1 = range

if range > 10 then

for b1 = 1 to range1
sertxd ("|")
if b1=range1 then
sertxd("+")
endif
next b1
sertxd(13,10)

else
for b1 = 1 to range1
sertxd("n")
if b1=range1 then

sertxd("+")
endif
next b1
sertxd(13,10)
endif



servo 0,85
pause 10
pause 10 ' this should not be nesecary, but it was of some reason in my setup

low portc 0 ' this should not be nesecary, but if not, strange things hapened

pause 10 'this should not be nesecary, but that is what makes it all fun

 

pulsout trig,2 ‘ produce 20uS trigger pulse (must be minimum of 10uS)

pulsin echo,1,range ‘ measures the range in 10uS steps

pause 10

range = range*10/58
range1 = range

if range > 10 then

for b1 = 1 to range1
sertxd ("|")
if b1=range1 then
sertxd("+")
endif
next b1
sertxd(13,10)

else
for b1 = 1 to range1
sertxd("n")
if b1=range1 then

sertxd("+")
endif
next b1
sertxd(13,10)
endif


servo 0,95
pause 10
pause 10 ' this should not be nesecary, but it was of some reason in my setup

low portc 0 ' this should not be nesecary, but if not, strange things hapened

pause 10 'this should not be nesecary, but that is what makes it all fun

 

pulsout trig,2 ‘ produce 20uS trigger pulse (must be minimum of 10uS)

pulsin echo,1,range ‘ measures the range in 10uS steps

pause 10

range = range*10/58
range1 = range

if range > 10 then

for b1 = 1 to range1
sertxd ("|")
if b1=range1 then
sertxd("+")
endif
next b1
sertxd(13,10)

else
for b1 = 1 to range1
sertxd("n")
if b1=range1 then

sertxd("+")
endif
next b1
sertxd(13,10)
endif



servo 0,105
pause 10
pause 10 ' this should not be nesecary, but it was of some reason in my setup

low portc 0 ' this should not be nesecary, but if not, strange things hapened

pause 10 'this should not be nesecary, but that is what makes it all fun

 

pulsout trig,2 ‘ produce 20uS trigger pulse (must be minimum of 10uS)

pulsin echo,1,range ‘ measures the range in 10uS steps

pause 10

range = range*10/58
range1 = range

if range > 10 then

for b1 = 1 to range1
sertxd ("|")
if b1=range1 then
sertxd("+")
endif
next b1
sertxd(13,10)

else
for b1 = 1 to range1
sertxd("n")
if b1=range1 then

sertxd("+")
endif
next b1
sertxd(13,10)
endif



servo 0,115
pause 10
pause 10 ' this should not be nesecary, but it was of some reason in my setup

low portc 0 ' this should not be nesecary, but if not, strange things hapened

pause 10 'this should not be nesecary, but that is what makes it all fun

 

pulsout trig,2 ‘ produce 20uS trigger pulse (must be minimum of 10uS)

pulsin echo,1,range ‘ measures the range in 10uS steps

pause 10

range = range*10/58
range1 = range

if range > 10 then

for b1 = 1 to range1
sertxd ("|")
if b1=range1 then
sertxd("+")
endif
next b1
sertxd(13,10)

else
for b1 = 1 to range1
sertxd("n")
if b1=range1 then

sertxd("+")
endif
next b1
sertxd(13,10)
endif



servo 0,125
pause 10
pause 10 ' this should not be nesecary, but it was of some reason in my setup

low portc 0 ' this should not be nesecary, but if not, strange things hapened

pause 10 'this should not be nesecary, but that is what makes it all fun

 

pulsout trig,2 ‘ produce 20uS trigger pulse (must be minimum of 10uS)

pulsin echo,1,range ‘ measures the range in 10uS steps

pause 10

range = range*10/58
range1 = range

if range > 10 then

for b1 = 1 to range1
sertxd ("|")
if b1=range1 then
sertxd("+")
endif
next b1
sertxd(13,10)

else
for b1 = 1 to range1
sertxd("n")
if b1=range1 then

sertxd("+")
endif
next b1
sertxd(13,10)
endif



servo 0,135
pause 10
pause 10 ' this should not be nesecary, but it was of some reason in my setup

low portc 0 ' this should not be nesecary, but if not, strange things hapened

pause 10 'this should not be nesecary, but that is what makes it all fun

 

pulsout trig,2 ‘ produce 20uS trigger pulse (must be minimum of 10uS)

pulsin echo,1,range ‘ measures the range in 10uS steps

pause 10

range = range*10/58
range1 = range

if range > 10 then

for b1 = 1 to range1
sertxd ("|")
if b1=range1 then
sertxd("+")
endif
next b1
sertxd(13,10)

else
for b1 = 1 to range1
sertxd("n")
if b1=range1 then

sertxd("+")
endif
next b1
sertxd(13,10)
endif


servo 0,145
pause 10
pause 10 ' this should not be nesecary, but it was of some reason in my setup

low portc 0 ' this should not be nesecary, but if not, strange things hapened

pause 10 'this should not be nesecary, but that is what makes it all fun

 

pulsout trig,2 ‘ produce 20uS trigger pulse (must be minimum of 10uS)

pulsin echo,1,range ‘ measures the range in 10uS steps

pause 10

range = range*10/58
range1 = range

if range > 10 then

for b1 = 1 to range1
sertxd ("|")
if b1=range1 then
sertxd("+")
endif
next b1
sertxd(13,10)

else
for b1 = 1 to range1
sertxd("n")
if b1=range1 then

sertxd("+")
endif
next b1
sertxd(13,10)
endif


servo 0,155
pause 10
pause 10 ' this should not be nesecary, but it was of some reason in my setup

low portc 0 ' this should not be nesecary, but if not, strange things hapened

pause 10 'this should not be nesecary, but that is what makes it all fun

 

pulsout trig,2 ‘ produce 20uS trigger pulse (must be minimum of 10uS)

pulsin echo,1,range ‘ measures the range in 10uS steps

pause 10

range = range*10/58
range1 = range

if range > 10 then

for b1 = 1 to range1
sertxd ("|")
if b1=range1 then
sertxd("+")
endif
next b1
sertxd(13,10)

else
for b1 = 1 to range1
sertxd("n")
if b1=range1 then

sertxd("+")
endif
next b1
sertxd(13,10)
endif



servo 0,165
pause 10
pause 10 ' this should not be nesecary, but it was of some reason in my setup

low portc 0 ' this should not be nesecary, but if not, strange things hapened

pause 10 'this should not be nesecary, but that is what makes it all fun

 

pulsout trig,2 ‘ produce 20uS trigger pulse (must be minimum of 10uS)

pulsin echo,1,range ‘ measures the range in 10uS steps

pause 10

range = range*10/58
range1 = range

if range > 10 then

for b1 = 1 to range1
sertxd ("|")
if b1=range1 then
sertxd("+")
endif
next b1
sertxd(13,10)

else
for b1 = 1 to range1
sertxd("n")
if b1=range1 then

sertxd("+")
endif
next b1
sertxd(13,10)
endif


servo 0,175
pause 10
pause 10 ' this should not be nesecary, but it was of some reason in my setup

low portc 0 ' this should not be nesecary, but if not, strange things hapened

pause 10 'this should not be nesecary, but that is what makes it all fun

 

pulsout trig,2 ‘ produce 20uS trigger pulse (must be minimum of 10uS)

pulsin echo,1,range ‘ measures the range in 10uS steps

pause 10

range = range*10/58
range1 = range

if range > 10 then

for b1 = 1 to range1
sertxd ("|")
if b1=range1 then
sertxd("+")
endif
next b1
sertxd(13,10)

else
for b1 = 1 to range1
sertxd("n")
if b1=range1 then

sertxd("+")
endif
next b1
sertxd(13,10)
endif



servo 0,185
pause 10
pause 10 ' this should not be nesecary, but it was of some reason in my setup

low portc 0 ' this should not be nesecary, but if not, strange things hapened

pause 10 'this should not be nesecary, but that is what makes it all fun

 

pulsout trig,2 ‘ produce 20uS trigger pulse (must be minimum of 10uS)

pulsin echo,1,range ‘ measures the range in 10uS steps

pause 10

range = range*10/58
range1 = range

if range > 10 then

for b1 = 1 to range1
sertxd ("|")
if b1=range1 then
sertxd("+")
endif
next b1
sertxd(13,10)

else
for b1 = 1 to range1
sertxd("n")
if b1=range1 then

sertxd("+")
endif
next b1
sertxd(13,10)
endif



servo 0,195
pause 10
pause 10 ' this should not be nesecary, but it was of some reason in my setup

low portc 0 ' this should not be nesecary, but if not, strange things hapened

pause 10 'this should not be nesecary, but that is what makes it all fun

 

pulsout trig,2 ‘ produce 20uS trigger pulse (must be minimum of 10uS)

pulsin echo,1,range ‘ measures the range in 10uS steps

pause 10

range = range*10/58
range1 = range

if range > 10 then

for b1 = 1 to range1
sertxd ("|")
if b1=range1 then
sertxd("+")
endif
next b1
sertxd(13,10)

else
for b1 = 1 to range1
sertxd("n")
if b1=range1 then

sertxd("+")
endif
next b1
sertxd(13,10)
endif



servo 0,205
pause 10
pause 10 ' this should not be nesecary, but it was of some reason in my setup

low portc 0 ' this should not be nesecary, but if not, strange things hapened

pause 10 'this should not be nesecary, but that is what makes it all fun

 

pulsout trig,2 ‘ produce 20uS trigger pulse (must be minimum of 10uS)

pulsin echo,1,range ‘ measures the range in 10uS steps

pause 10

range = range*10/58
range1 = range

if range > 10 then

for b1 = 1 to range1
sertxd ("|")
if b1=range1 then
sertxd("+")
endif
next b1
sertxd(13,10)

else
for b1 = 1 to range1
sertxd("n")
if b1=range1 then

sertxd("+")
endif
next b1
sertxd(13,10)
endif



servo 0,215
pause 10
pause 10 ' this should not be nesecary, but it was of some reason in my setup

low portc 0 ' this should not be nesecary, but if not, strange things hapened

pause 10 'this should not be nesecary, but that is what makes it all fun

 

pulsout trig,2 ‘ produce 20uS trigger pulse (must be minimum of 10uS)

pulsin echo,1,range ‘ measures the range in 10uS steps

pause 10

range = range*10/58
range1 = range

if range > 10 then

for b1 = 1 to range1
sertxd ("|")
if b1=range1 then
sertxd("+")
endif
next b1
sertxd(13,10)

else
for b1 = 1 to range1
sertxd("n")
if b1=range1 then

sertxd("+")
endif
next b1
sertxd(13,10)
endif


servo 0,225
pause 10
pause 10 ' this should not be nesecary, but it was of some reason in my setup

low portc 0 ' this should not be nesecary, but if not, strange things hapened

pause 10 'this should not be nesecary, but that is what makes it all fun

 

pulsout trig,2 ‘ produce 20uS trigger pulse (must be minimum of 10uS)

pulsin echo,1,range ‘ measures the range in 10uS steps

pause 10

range = range*10/58
range1 = range

if range > 10 then

for b1 = 1 to range1
sertxd ("|")
if b1=range1 then
sertxd("+")
endif
next b1
sertxd(13,10)

else
for b1 = 1 to range1
sertxd("n")
if b1=range1 then

sertxd("+")
endif
next b1
sertxd(13,10)
endif
goto main

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Your questions should not be general.  They need to be specific, otherwise they are too difficult to answer. 

How can I differentiate a cup from other objects and make the robot understand it?

This question needs more detail..
What other objects ?  Any objects? (that would be tough - OpenCV & webcam would be a guess, and this is on a visual level...)

OpenCV is not the only way.. there are many ways to differentiate a cup from other "objects" ... it depends on what is important...

How does a blind person differentiate a cup from other objects?  

Your robot is currently blind, but can ping..  So you have a kind-of echo measuring stick..  If you know where your ping sensor is & you know where you are pointing it, you can begin (with a lot of work) to measure things..  When you can measure things, you can find the dimensions of "object" (after a lot of work)..  With more work you can try to program something which scans for the dimension of an object which might match a "cup" ....   This is after more work..  It will work like crap, but then you can put filtering on it (more work)...

OR you can control and simplify the environment, by putting the cup in a specific location - and the ping sensor only knows if the cup is there.. or if it isn't  (much easier) :)

When you begin to ask yourself these questions, you can start trying to solve all the problems that are important....

For object recognition, take a look at another member's work with the Kinect camera setup.

http://letsmakerobots.com/node/31012

Look at the programming he references. I think that will help you get started into object recognition.

I have several dozen books on robotics and in comparison that Kinect material is a fairly straightforward approach. The field of object recognition is not an easy one which can be described in one sentence or that only takes a few seconds to learn. Sit back, relax and give it your full attention.

As was said below, the SRF05 does not give you enough data to get more than a very general outline of obstacles.

For recognition, you really need a camera, and a color camera is the best.

There is a way to use a matrix of light sensors like a rudimentary camera to get basic shapes, but I doubt that will make you happy. 

 

The "pause" after the "servo" command IS useful. It gives the servo time to move to position. I usually do a for-next loop on servos, myself. If the servo command is ended too soon the servo does not finish moving to the right position. The timing needed there depends on what kind (what speed) of servo you are using.

You didn't say if that is a 28X1 or a 28X2 or what, but I am guessing it is one of the latest and the clock is running twice as fast as the old chips. The pulsout command would then only be sending a 10 μSec pulse instead of 20, but that is okay. As you said, as long as it is at least 10 μSec.

Finally, I notice the program is much longer than it needs to be. You are sampling distance pings in several directions. All those sequences could be put into one subroutine with a return at the end of it. Then you move the servo to position, call the subroutine and save the data, then change the servo's position and call the same subroutine again. ...etc...etc

You are only scanning in one direction/dimension (left and right), not all three dimensions, so defining a cup versus another object will not happen. All you can tell is the approximate width of the object it sees, not what it is.  You will need to take the results of each scan and plot it in memory so the robot can tell where the obstacles are for movement purposes.

Hope some of that is helpful.

__________________________________________________

Here is some sample programming to show you how to do the same thing in less memory space:

__________________________________________________

symbol trig = 3
symbol echo = 6
symbol range = w0
symbol range1 = w1

main:

For b6 = 85 to 225 step 10

servo 0, b6
pause 20
low portc 0

pause 10  
gosub measure  
goto main

 

measure:
pulsout trig,2 ‘ produce 20uS trigger pulse (must be minimum of 10uS)

pulsin echo,1,range ‘ measures the range in 10uS steps

pause 10

range = range*10/58
range1 = range

if range > 10 then

for b1 = 1 to range1
sertxd ("|")
if b1=range1 then
sertxd("+")
endif
next b1
sertxd(13,10)

else
for b1 = 1 to range1
sertxd("n")
if b1=range1 then

sertxd("+")
endif
next b1
sertxd(13,10)
endif

return

like Mr Anderson said almost impossible. the best you could get would be to find an object of a certain size, collect and compare all 15 bytes looking for a few that have the same or close values in a cluster , but that wont tell you that it's a cup just an object that's X "Steps " wide

IR beacon would get you to the cup and when your close enough do what ya got to do     

what is best in life ,openCV  computer vision

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

and a code tip

http://www.picaxe.com/docs/picaxe_manual2.pdf

Page 66

for b0 = 75 to 225 {step 10}

servo 0,b0
code

code

code

next b0

goto main

i hope this helps 

 

I would think that object recognition is almost impossible with at ping sensor and a PICAXE. For that you would need a sensor with much higher resolution and something more beefy than that PICAXE.

By looking at your code this would probably be fare beyond your current programming skills.

(you’re doing stuff over and over again, but not a subroutine in sight…)

So take fritsl’s advice. Start with small steps and write some code that works, then build on that.

Hi, First of all, when I kept asking you to post on the project page, when you wrote me by mail and kept on messenging me, you should not post on a seperate forum topic, but as a comment / question on the project page.

Secondly, I'd like to help you, but it is really not possible. You provide a lot of code, and the description of what you'd like as "kindly help me". It is impossible to solve your problem, when I do not know what it is.

The only thing I can say is; Break this down into very.. VERY small bits, and make them work - one at a time.

Once you can document to us that you can scan with the SRF05, and that you have a working version of the project I described (I know I made a full walk through some place, please look for that) - then let me/us know excactly what DETAIL in the project you have a problem with.

Best of all, you should go ahead and try and make your own projects, I think you'd be far better off, and learn a lot more :)

Best of luck.