From 31656dbada335e7e0c7d4273722a529f752712e8 Mon Sep 17 00:00:00 2001 From: Jonas Date: Fri, 1 Jun 2018 14:39:06 +0200 Subject: [PATCH] live_recognition_with_head further improved --- scripts/live_recognition_with_head.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/scripts/live_recognition_with_head.py b/scripts/live_recognition_with_head.py index a4bec52..a5de8a6 100644 --- a/scripts/live_recognition_with_head.py +++ b/scripts/live_recognition_with_head.py @@ -47,9 +47,9 @@ def set_angle_new(x,y): motionProxy = ALProxy("ALMotion", robotIP, PORT) # activiert gelenke - motionProxy.setStiffnesses("Head", 1.0) + motionProxy.setStiffnesses("Head", 0.5) names = ["HeadYaw", "HeadPitch"] - fractionMaxSpeed = 0.05 + fractionMaxSpeed = 0.1 #x_mid=160 #y_mid=120 #x_diff=x-x_mid @@ -62,8 +62,8 @@ def set_angle_new(x,y): #print(ball_angles) ball_angle_x=ball_angles[0] ball_angle_y=ball_angles[1] - #print("ball_angle_x="+str(ball_angle_x)) - print("ball_angle_y="+str(ball_angle_y)) + print("ball_angle_x="+str(ball_angle_x)) + #print("ball_angle_y="+str(ball_angle_y)) #ball_angle_x_diff=ball_angle_x+ #ball_angle_y_diff=ball_angle_y-99 @@ -74,8 +74,11 @@ def set_angle_new(x,y): #[-169.53343200683594, 99.27782440185547] (x_mid,y_mid) #if abs(ball_angle_x)>0.2 and abs(ball_angle_y)>0.01: #angles=[ball_angle_x,0] - #angles=[0,ball_angle_y] - #motionProxy.setAngles(names, angles, fractionMaxSpeed) + angles=[0.5*ball_angle_x,0.5*ball_angle_y] + if abs(ball_angle_x)>0.1 or abs(ball_angle_y)>0.1: + motionProxy.changeAngles(names, angles, fractionMaxSpeed) + elif abs(ball_angle_x)<0.1 and abs(ball_angle_y)<0.1: + print("Ball found")