Locking on objects

UPDATE: Mintvelt has made a remarkable new invention in this field, you want to check that out after reading the below!


If you want 2 robots to detect and find each other:

2 Robots tracking is a completely different ballgame than the topic below, in this posting.. Or a robot following something that omits a signal.. These things are quite easy.

Buy a kit and get going: http://www.pololu.com/catalog/product/701

- or DIY: http://www.wichitabuggywhip.com/robots/ir.html

 


Often it could be nice to have your robot lock on an object, or a person.

And sometimes it is seen done - but how? The cheap IR & Ultra Sound sensors that are common when writing this can only detect distance in front of it.

Trick is, to put it short;Put the sensor on something that can turn (like a servo), and focus on the edge / start / end edge of the object - not the object itself.

Your code can detect when there is a sudden drop - and there is the edge.

If you then focus on 2 sides while scanning, you can determine the middle of the object.

 

By going for the edge or perhaps middle, you can have your robot follow another, look at your finger when moving it in front etc..

But you should know; This is a very unsteady technology. If a scan just misses once, all can be lost, if it is driving off etc. This happens specially if the object is moving fast / is close or far away etc.

Also be aware that some sensors have a very broad and wide detection area in front of them (such as the SRF05) - this makes it harder to this kind of tracking. Sort of like feeling around with a numb finger :)

More narrow sensors makes it easier - this could bea reason for buying something more expansive than the SRF05 - something with a more pencil-shaped detection area - like the SRF325 LinkI LinkII

 

Here is a link to a nice tutorial, with some very good tracking on a video. You should not expect to get your robot better tracking than this!

 

If you really want your robot to lock, and do a good job, you should either start investing in cameras etc, or if it is locking on a person, this might have your interest. I have not tried any of these methods.

If you start thinking on PIR's this is the place.

 

I wish I had more time to try this…

Unfortunately when I connect both my servo and my sharp IR to War Pig (my robot), servo gets crazy and stops working… while If I connect them singularly they work well… No idea if it’s jus a code problem or even an hardware one…

Some time to debug is needed before starting with locking algorithms!

Sharp IR

I have been thinking about using some Sharp IR sensors too. You may need to add a capacitor to prevent voltage spikes/drops on the power line. See http://www.robotroom.com/DistanceSensor3.html

I’d be very interested to know if this helps.

I’m using this for my robot

I’m using the same kit for My OFR robot.

Still waiting for it to arrive though. I think it’s very great for making robots that follow or track things.

sharp ir tracking like stampy

hi im new to all this but i have built your $85 robot and added line sensors but i now want it to follow the cat and run away when it gets to close, i want to use the sharp ir sensor it already has but every attempt to try and write some code for this seems to fail. could someone post an examlpe or give me a clue where to start i have read the post on stampy and looked at his c code but this hasnt helped me to program my picaxe 28x1

 

thanks

lance

Can you be more specific;

Can you be more specific; What is it that you want helpt with? The sharp? Or following your cat?

If it is the cat, you are going to have a hard time. Perhaps have a look at the project / robot called "Big Chaser" by the user "Base Over Apex"… He is trying to make it follow him, and even that is not easy. So a cat…

Beacon
You could put an IR beacon on the cat’s collar, and then write code that has your bot seek the beacon UNTIL a certain distance …

Sharp IR?

If you are using the Sharp GP2D12, you might be able to modify Fritsl code on the $85 to go towards objects rather than away from, which it currently does now. But the robot will go towards any object, not just the cat, and will be stuck trying to push wall over, or move a chair it found with the sensor. More sensors, or different use of the data those sensors give might allow you to chase some objects, but not others. I can only think that adding a PIR sensor would allow the robot to see a cat (or person) and differentiate that from a wall.

I looked up the Stampy robot, and it seems to be set up as a sumo robot, to push other robots around. If you notice the videos, it is always out in the middle of the floor, where it can’t get a sensor hit from a wall or chair, but only the other robot that gets close enough. So it is working in a “highly restricted” environment of operation, not the open one we live in.

"to go towards objects

"to go towards objects rather than away from" - just a note on that; Yes, Robologist, you are so very right!

I use that as a “mode” myself quite often, in many ways, it is good thinking by you :slight_smile:

Oh - and on a second note;

Oh - and on a second note; Apart from the "inversing ordinary obstacle avoidance" mentioned above by robologist, one can ALSO make special code that will filter an object from a background / not see a background as an object.

The more narrow your beacon is (and the SRF05 and Sharp IR are both NOT very narrow) the easier it is. I would imagine some laser-distance sensor would make it a breeze.

However, it CAN be done with an SRF05, just take a look at this robot: https://www.robotshop.com/letsmakerobots/node/466

It does not get confused by the surroundings, only a cup is a cup (or anything else with that size of "eccho", not moving around)

sharp ir tracking like stampy

thanks for all your help, i need to keep it quite simple at the moment so i think il go with robologist plan to get the robot just to head towards objects but i want it to turn and run when it gets to close to an object so im hoping it should always end up somewhere in the middle of the room where it will wait for something to come close again. im planning to hide some catnip on the robot to keep the cat interested and stop it bothering me lol.

thanks again

 

Pseudocode

Programming statements, I have no idea if this is like either the "Start Here" or Stampy robots :

if (IR-distance > Chase-level) AND (IR-distance < Flee-level) then Go_Forward

if (IR-distance > Chase-level) AND (IR-distance > Flee-level) then Go_Back

Just an idea to start, but have a variable called IR-distance that takes the measured distance from the ADC pin the sensor is tied to. Have a couple constants Chase-level and Flee-level that are set values for the robot to compare the IR-distance varialbe to. So if the IR-distance reads 125 and the Chase-level is set to 100 but the Flee-level is set to 180, the robot will go forward using something like the above pseudocode. Note the numbers of the IR-distance get bigger as the robot gets closer (Sharp IRs output a higher voltage as the detected object gets closer). So eventually the IR-distance number will get higher than the Flee-level too and the robot will then run away. Note hte use of AND which means both tests must be true for thethen operation tooccur.

sharp ir tracking like stampy

hi iv came up with this code which works fine when the robot is sitting on a cup (wheels off the ground) but when i put it on the floor and its searching by spinning on the spot it doesn’t move forward when i put my hand in front of it, it seems to be spinning to fast to react to my hand. is there a better sensor i could use or does my code just need tweaking a bit.

thanks again for all your help

symbol close = 12
symbol tclose = 50
symbol time = 100
main:
servo 0,150
readadc 1, b1 ’ read eyes
if b1>close and b1<tclose then chase ’ if object close then chase
if b1>close and b1>tclose then flee ’ if object too close then flee
if b1<close then search ’ if no object search



chase:
readadc 1, b1 ’ read eyes
low 5 high 4 low 6 high 7 ’ move forward
if b1>close and b1>tclose then flee ’ if object too close then flee
if b1<close then search ’ if odject gets away then search
goto chase


flee:
high 4 low 5 low 7 high 6 ’ turn left
pause 1500 ’ pause
high 4 low 5 high 7 low 6 ’ go forward
readadc 1, b1 'read eyes
if b1>close and b1<tclose then chase ’ if object close then chase
if b1>close and b1>tclose then flee ’ if object too close then flee
pause 3000 ’ pause
goto search


search:
low 5 high 4 high 6 low 7 ’ turn left
readadc 1, b1 ’ read eyes
let b2 = b2 +1 ’ start counting
pause 200
if b1>close and b1<tclose then chase ’ if object close then chase
if b1>close and b1>tclose then flee ’ if odject too close then flee
if b2>time then wander ’ when count = time then wander
goto search


wander:
high 4 low 5 high 7 low 6 ’ go forward
readadc 1, b1 ’ read eyes
if b1>close and b1>tclose then flee ’ if object too close then flee
pause 3000 ’ pause
high 4 low 5 low 7 high 6 ’ turn left
if b1>close and b1>tclose then flee ’ if odject too close then flee
pause 500 ’ pause
high 4 low 5 high 7 low 6 ’ go forward
readadc 1, b1 ’ read eyes
if b1>close and b1>tclose then flee ’ if object too close then flee
pause 3000 ’ pause ’
let b2=0 ’ reset count
goto search ’ go back to search

Sharp Sensor timing
You most likely are right in thinking your turns may be too fast for the sensor to give a good reading. So I’d say tweak your code a little. Add a few more pause statements here and there, to see if you get your motors to slow down a bit. You might even need a STOP statement in between pauses, sort like making a very low frequency PWM. Give it a shot, good sleuthing.

Would a IR object detection
Would a IR object detection or tracling work on something as basic as a Picaxe 28X1 ?

Yes.
Yes.

cool i want that feature on

cool i want that feature on my bot…hope the code on that is simple…is it possible that it can do that while moving? i am going to update my bot very soon…

 

i am going to adapt that technique and make a "scout robot" basically it patrols a certain place then if he sees a moving object it will beep or maybe flash a LED or maybe use sertxd function and let it say "hey i see a moving object" but the problem is the lenght of the cable :slight_smile: