dimanche 12 décembre 2010

The closest target, update

In my previous post, the robot was first looking for the closest target around using the Ping))) sensor, then it aimed this target, drove toward it and stopped at about 2 inches.

Now, what if the target moves ? At this time, my goal is not to deal with moving targets, but programming a robot means dealing with error accumulation. If this accumulation leads the robot to lose its target, the path has to be adjusted.

To do so, the traveled distance is monitored by counting the pulses sent to the servos. On my Boe-Bot, the ratio is around 2 mm/pulse at slowspeed or 0.48 pulses/mm. Comparing the "pulses distance" and the "ping distance" allows to check if the target has been missed and if the whole process has to be started over.

Code sample :

'approche la cible
DO
PULSOUT 12,730
PULSOUT 13,770
GOSUB getdistance
pulsecount=pulsecount+1
IF pulsecount>(minidist*48/10) THEN 'translate the mini distance given by the ping into pulses before comparing it
  FREQOUT 4,100,3000
  GOTO main
ENDIF
PAUSE 15
LOOP UNTIL distance<=10 'approche à 10 cm
END


Aucun commentaire:

Enregistrer un commentaire