added threshold in ball_approch for error prevention

This commit is contained in:
Jonas
2018-06-12 11:45:28 +02:00
parent 83f7604efe
commit 9bc732807a

View File

@@ -74,8 +74,12 @@ class BallFollower(object):
d_yaw, d_pitch = x, 0 d_yaw, d_pitch = x, 0
print(d_yaw) print(d_yaw)
# dont move the head, when the angle is below a threshold
# otherwise function would raise an error and stop
if (abs(d_yaw)>=0.00001):
self.mover.change_head_angles(d_yaw * 0.7, d_pitch, self.mover.change_head_angles(d_yaw * 0.7, d_pitch,
abs(d_yaw) / 2) abs(d_yaw) / 2)
# self.counter = 0 # self.counter = 0
yaw = self.mover.get_head_angles()[0] yaw = self.mover.get_head_angles()[0]
if abs(yaw) > 0.4: if abs(yaw) > 0.4: