Robot head following poeple.....

pjl83

Member
Where to begin!

Hi all, I've recently dug out my picaxe stuff and started playing again. It's amazing how long its been but I've picked it back up and been making a few random projects purely for fun.

I'd like to make robot head that can follow a human. I've had a good search but can't find anything recent. I think what I want is very basic with the use of a "camera" but am struggling to find anything similar. Imagine a head (and shoulders I guess) sat on a desk, when somebody walks close enough it "sees" them and follows them across the room. What hardware do I need? I've seen a couple of threads about moving eyes using 2 servos and 2 sensors looking for extreme edges but I want it as simple as possible. I am happy with the servos and the sensors (sensing proximity and making the movement), just cant find what I can use to control the movement and the object recognition/tracking.

p.s. Face recognition would be brilliant if possible! As in, focussing on the face area rather than actually recognising people.

Thanks in advance. Any ideas welcome. :cool:
 

bpowell

Senior Member
I think there's a camera out there with a serial interface that you can use to track colors...but I don't think shapes.

Maybe a couple of sonar sensors, or PIR sensors? When something gets close, the head turns towards the object, and then tracks the object for as long as it's able. Or making use of IR sensors? There are many simple (and cheap) "wing levelers" for RC airplanes that use 4 IR sensors to keep "cold" (sky) facing up, and keeping "warm" (ground) out of either of the left/right sensors...
 

goom

Senior Member
Had to try it. 20 minutes with paper and scissors.
It is going to save a lot of time and expense with moving things. No more servos, batteries, bearings, linkages and Picaxes. Just paper.
 

rq3

Senior Member
Had to try it. 20 minutes with paper and scissors.
It is going to save a lot of time and expense with moving things. No more servos, batteries, bearings, linkages and Picaxes. Just paper.
And tape. And scissors. Have to build a Picaxe robot to do that part ;-)
 

Bill.b

Senior Member
HI

I used this circuit to control a head that followed an individual.
The circuit used two IR distance measuring GP2Y0A21s slightly offset to detect the direction of a moving body and stop when the
output of both are equal. A single servo was used to rotate the head.

unfortunately I do not have the unit anymore so no photos.

movinghead2.jpg

Code:
'program Scanner14m2a.bas
'picaxe 14m2
'30/7/12   WB (Bill.B)
' follow object until 
'object moves out of range.


#picaxe 14m2
#No_Data
pause 1000
setfreq m8

symbol LeftOffSet		= b0		'positive Offset
symbol counter1 		= b1		'counter
symbol TempCount		= b2		'Temperary Counter
symbol RightOffSet	= b3		'Negstive Offset
symbol LoopCount		= b4
Symbol range            = w3		'Left range sensor register
SYMBOL range2		= w4		'Right range sesor register
symbol TempRange		= w8
symbol TempRange2		= w9
		'animation LED 1
symbol LED2			= b.2		'animation LED 2
Symbol trig 		= b.3		'Left range sensor ADC input	
symbol trig2		= b.4		'Right range sensor ADC input
Symbol SERVO1           = b.1		'Servo Output
symbol Bell 		= b.5		'bell output
symbol LED3			= c.0

dirsB=%11111111
dirsC=%00000001

high led3
servo servo1,75
RightOffSet = 40		'set Right max position
LeftOffSet = 90		'Set Left max position
tempcount = 75

main:
	ServoPos SERVO1,off
	gosub distance
	if range > 20 or range2 > 20 then 'if object found goto follow object routine
		gosub follow
	endif
	pause 150


goto main  


follow:			'Follow object subroutine. 
	servo servo1,55
	tempcount = 55	'preset servo position
	low led3		'Turn on LED sequence
	high led2		'Turn on found LED
	high bell		'Ring Bell - operate motor for 600ms
	counter1 = 0
	pause 600
	low bell
	do
		gosub distance
		if range < 20 and range2 > 20 then  'follow object if it moves to the right
			TempCount = TempCount + 2
			counter1 = 0		
		endif
		if range > 20 and range2 < 20 then	'follow object if it moves to the left
			TempCount = TempCount - 2
			counter1 = 0
		endif
		if TempCount < RightOffSet then			'do not pass end limits.
			TempCount = RightOffSet
		endif
		if TempCount > LeftOffSet then
		  	TempCount = LeftOffSet
		endif
'	debug 
		pause 200
		 ServoPos SERVO1, TempCount			'servo position
  		counter1 = counter1 + 1
	loop until range < 20 and range2 < 20 and counter1 > 20	'Loop until object moves out of range
	TempCount = 60
	ServoPos SERVO1, TempCount
	high led3				'Turn off LED sequencer
	low led2				'Turn off found LED
	pause 200
	return
	
	
distance:			'Routine to average 5 readings from the IR sensors.
	TempRange2=0
	TempRange=0

	for LoopCount = 1 to 5   
		readadc trig,Range 	'
   		TempRange = TempRange + range
  		pause 20
   		readadc trig2,Range2 	 
    		TempRange2 = TempRange2 + range2
    		pause 40
    	next LoopCount
    	TempRange2 = TempRange2/5
   	TempRange = TempRange/5
    	range = TempRange
    	range2 = TempRange2
  	' debug

	pause 100
    	return

Bill
 

pjl83

Member
Hi, Thanks everyone for the replies. I have had a look at the raspberry pi and may use this with a webcam for the face following. I will still use picaxe for other parts. Maybe to give it moving arms too :p
 

rossko57

Senior Member
As an approximation to the face location that you want (as opposed to facial recognition), it is fairly safe to assume "it's at the top of the moving body". The previous IR example could be expanded to inculde an elevation movement, and code to find by go/nogo the top of the the moving target. No pi, no webcam.
 

pjl83

Member
That looks good. Thanks for the idea of the object tracker also. I think I will use this an an excuse to get myself the pi and have a play. I'm sure I can get the pi and the picaxe to play nicely together somehow!
 
Top