From 3cd67a783ac614fa2c3be5e6b51e51e8c580d3f8 Mon Sep 17 00:00:00 2001 From: Jonas Date: Sun, 27 May 2018 18:05:39 +0200 Subject: [PATCH] added scan_for_ball.py --- scripts/scan_for_ball.py | 60 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 scripts/scan_for_ball.py diff --git a/scripts/scan_for_ball.py b/scripts/scan_for_ball.py new file mode 100644 index 0000000..726e7a5 --- /dev/null +++ b/scripts/scan_for_ball.py @@ -0,0 +1,60 @@ +# -*- encoding: UTF-8 -*- +# syntax +# python setangles.py x y + +import sys +from naoqi import ALProxy +import time + +def main(robotIP): + PORT = 9559 + + try: + motionProxy = ALProxy("ALMotion", robotIP, PORT) + except Exception,e: + print "Could not create proxy to ALMotion" + print "Error was: ",e + sys.exit(1) + + # activiert gelenke + motionProxy.setStiffnesses("Head", 1.0) + + # Example showing how to set angles, using a fraction of max speed + names = ["HeadYaw", "HeadPitch"] + + # go into left direction + i=0 + while i<2: + angles = [i,0] + fractionMaxSpeed =0.5 + motionProxy.setAngles(names, angles, fractionMaxSpeed) + i=float(i)+3.14/4 + time.sleep(0.3) + + # go back to middle position + angles = [0,0] + fractionMaxSpeed =0.5 + motionProxy.setAngles(names, angles, fractionMaxSpeed) + print "head set back" + time.sleep(0.3) + + # go into the right direction + i=0 + while i > -2: + angles = [i,0] + fractionMaxSpeed =0.5 + motionProxy.setAngles(names, angles, fractionMaxSpeed) + i=i-3.14/4 + time.sleep(0.3) + + # go back to middle position + angles = [0,0] + fractionMaxSpeed =0.5 + motionProxy.setAngles(names, angles, fractionMaxSpeed) + print "head set back" + time.sleep(1) + +if __name__ == "__main__": + robotIp = "192.168.0.11" + + main(robotIp)