added goal approach detection

This commit is contained in:
Jonas
2018-06-30 12:11:37 +02:00
parent 1c6910cbe5
commit a4ba0bdd57

View File

@@ -83,9 +83,19 @@ if __name__ == '__main__':
striker.mover.set_head_angles(0, 0) striker.mover.set_head_angles(0, 0)
striker.speak("Start the Ball tracking") striker.speak("Start the Ball tracking")
striker.ball_tracking(tol=0.05) striker.ball_tracking(tol=0.05)
# goal_center = striker.goal_search() striker.speak("I have found the Ball, starting with. Goal search")
# approach = 1 if goal_center < 0 else -1 goal_center = striker.goal_search()
approach = 1 if goal_center <0:
striker.speak("I have found the. goal on the right")
approach = 1
else:
striker.speak("I have found the. goal on the left")
approach = -1
striker.mover.set_head_angles(0, 0)
#approach = 1 if goal_center < 0 else -1
#approach = 1
sleep(0.5)
state = 'ball_approach' state = 'ball_approach'
elif state == 'tracking': elif state == 'tracking':
@@ -101,7 +111,7 @@ if __name__ == '__main__':
# ) # Ball in lower # ) # Ball in lower
# print('Ball in lower', bil) # print('Ball in lower', bil)
striker.speak("I have found the ball. Starting ball approach") #striker.speak("I have found the ball. Starting ball approach")
try: try:
d = striker.distance_to_ball() d = striker.distance_to_ball()
except ValueError: except ValueError:
@@ -123,7 +133,7 @@ if __name__ == '__main__':
elif state == 'goal_align': elif state == 'goal_align':
try: try:
if striker.align_to_goal(): if striker.align_to_goal():
striker.speak('I am aligning to ball') striker.speak('Why am I in align. This makes no sense')
state = "align" state = "align"
except ValueError: except ValueError:
state = 'tracking' state = 'tracking'
@@ -161,8 +171,8 @@ if __name__ == '__main__':
striker.mover.stand_up() striker.mover.stand_up()
sleep(0.3) sleep(0.3)
striker.mover.kick(fancy=True, foot='L') striker.mover.kick(fancy=True, foot='L')
striker.speak("Nice kick. Let's do a dance") ##striker.speak("Nice kick. Let's do a dance")
striker.mover.dance() #striker.mover.dance()
break break
loop_end = time() loop_end = time()