improved approach

This commit is contained in:
Jonas
2018-06-18 15:01:08 +02:00
parent ed98bca9f6
commit e11f268508
2 changed files with 17 additions and 13 deletions

View File

@@ -11,18 +11,19 @@ class NaoMover(object):
[[(0, 1, 'ShoulderRoll', -70, 0.025)], 1], [[(0, 1, 'ShoulderRoll', -70, 0.025)], 1],
[[(0, 1, 'AnkleRoll', -10, 0.05), [[(0, 1, 'AnkleRoll', -9, 0.05),
(1, 1, 'AnkleRoll', -10, 0.05)], (1, 1, 'AnkleRoll', -9, 0.05)],
2], 2],
[[(1, 0, 'KneePitch', 90, 0.05), [[(1, 0, 'KneePitch', 90, 0.05),
(1, 0, 'AnklePitch', -40, 0.05)], (1, 0, 'AnklePitch', -40, 0.05)],
3,], 2,],
[[(1, 0, 'HipPitch', -45, 0.08), [[(1, 0, 'HipPitch', -45, 0.08),
(1, 0, 'KneePitch', 10, 0.20), (1, 0, 'KneePitch', 10, 0.20),
(1, 0, 'AnklePitch', 30, 0.16)], (1, 0, 'AnklePitch', 20, 0.16)],
4] 1],
[[(1, 0, 'HipPitch', -55, 0.08)], 1]
] ]
def __init__(self, nao_ip, nao_port=9559): def __init__(self, nao_ip, nao_port=9559):
@@ -44,8 +45,8 @@ class NaoMover(object):
self.set_arm_stiffness(0.8) self.set_arm_stiffness(0.8)
self.set_hip_stiffness(0.8) self.set_hip_stiffness(0.8)
self.set_knee_stiffness(0.8) self.set_knee_stiffness(0.8)
self.set_ankle_stiffness(0.8) self.set_ankle_stiffness(1)
multiplier = 4 multiplier = 5
if foot == 'L': if foot == 'L':
sides = ['R', 'L'] sides = ['R', 'L']
elif foot == 'R': elif foot == 'R':

View File

@@ -103,15 +103,17 @@ class Striker(object):
if ball_angles is None: if ball_angles is None:
raise ValueError('No ball') raise ValueError('No ball')
x, y = ball_angles x, y = ball_angles
goal_x, goal_y = 0.115, 0.25 goal_x, goal_y = 0.115, 0.32
dx, dy = goal_x - x, goal_y - y dx, dy = goal_x - x, goal_y - y
if abs(dx) < 0.05 and abs(dy) < 0.05: if abs(dx) < 0.05 and abs(dy) < 0.05:
print(x, y) print(x, y)
return True return True
self.mover.move_to(dy * 0.5, 0, 0) if abs(dy) > 0.05:
self.mover.wait() self.mover.move_to(dy * 0.5, 0, 0)
self.mover.move_to(0, -dx * 0.5, 0) self.mover.wait()
self.mover.wait() if abs(dx) > 0.05:
self.mover.move_to(0, -dx * 0.5, 0)
self.mover.wait()
return False return False
def align_to_goal(self): def align_to_goal(self):
@@ -202,7 +204,7 @@ if __name__ == '__main__':
print(ball_in_lower) print(ball_in_lower)
if (ball_in_lower is not None if (ball_in_lower is not None
and ball_in_lower[1] > 0.25): and ball_in_lower[1] > 0.28):
print('Ball is in lower camera, go to align') print('Ball is in lower camera, go to align')
striker.mover.stop_moving() striker.mover.stop_moving()
@@ -216,6 +218,7 @@ if __name__ == '__main__':
sleep(0.5) sleep(0.5)
try: try:
success = striker.align_to_ball() success = striker.align_to_ball()
sleep(0.3)
if success: if success:
state = 'kick' state = 'kick'
except ValueError: except ValueError: