Une vidéo du robot MRPiZ avec le capteur de gestes 3D Flick:
Le programme en langage python:
#!/usr/bin/env python import sys from mrpiZ_lib import * import time import flicklib from copy import copy import subprocess def message(value): print value @flicklib.move() def move(x, y, z): global xyz xyz = [x,y,z] def main(): time_PasDetection = 0 global xyz xyz = [0,0,0] old_xyz = [0,0,0] deplacement_axeX = 0 print "Exemple" while True: if old_xyz != xyz: deplacement_axeX = xyz[0] deplacement_axeY = xyz[1] print "X", deplacement_axeX print "Y", deplacement_axeY if(deplacement_axeX < 0.35): print "avancer" forward(25) if(deplacement_axeX > 0.75): print "reculer" back(25) if((deplacement_axeY > 0.75)and(deplacement_axeX > 0.35)and(deplacement_axeX < 0.75)): print "tourner droite" turnRight(25) if((deplacement_axeY < 0.5)and(deplacement_axeX > 0.35)and(deplacement_axeX < 0.75)): print "tourner gauche" turnLeft(25) time.sleep(0.5) #stop() else: print "pas de detection" time_PasDetection = time_PasDetection + 1 if(time_PasDetection > 5): stop() time_PasDetection = 0 old_xyz = copy(xyz) time.sleep(0.2) if __name__ == "__main__": main()