The run from the video

This commit is contained in:
2018-06-24 17:55:52 +02:00
parent c2866d4b5f
commit 770f4bdd52
2 changed files with 16 additions and 14 deletions

View File

@@ -11,6 +11,7 @@
255 255
] ]
], ],
"cam": 1,
"goal": [ "goal": [
[ [
0, 0,
@@ -23,12 +24,11 @@
255 255
] ]
], ],
"fps": 10,
"res": 2, "res": 2,
"ball_min_radius": 0.01, "ball_min_radius": 0.01,
"field": [ "field": [
[ [
19, 24,
51, 51,
60 60
], ],
@@ -38,7 +38,7 @@
255 255
] ]
], ],
"cam": 1, "fps": 10,
"ip": "192.168.0.11", "ip": "192.168.0.11",
"port": 9559 "port": 9559
} }

View File

@@ -197,7 +197,8 @@ class Striker(object):
# sign = 1 if dy > 0 else -1 # sign = 1 if dy > 0 else -1
def align_to_ball(self): def align_to_ball(self):
ball_angles = self.get_ball_angles_from_camera(self.lower_camera) ball_angles = self.get_ball_angles_from_camera(self.lower_camera,
mask=False)
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
@@ -268,7 +269,7 @@ class Striker(object):
def goal_search(self): def goal_search(self):
goal_center_x = None goal_center_x = None
angles = [0, -pi/6, -pi/3, pi/6, pi/3] angles = [0, -pi/6, -pi/4, -pi/3, -pi/2, pi/6, pi/4, pi/3, pi/2]
for angle in angles: for angle in angles:
self.mover.set_head_angles(angle, 0) self.mover.set_head_angles(angle, 0)
sleep(0.5) sleep(0.5)
@@ -389,7 +390,7 @@ if __name__ == '__main__':
if state == 'tracking': if state == 'tracking':
# start ball approach when ball is visible # start ball approach when ball is visible
if striker.ball_tracking(): if striker.ball_tracking():
striker.speak("ball_approach") striker.speak("Ball approach")
state = 'ball_approach' state = 'ball_approach'
elif state == 'ball_approach': elif state == 'ball_approach':
@@ -407,33 +408,34 @@ if __name__ == '__main__':
striker.run_to_ball() striker.run_to_ball()
state = 'tracking' state = 'tracking'
elif state == 'simple_kick': # elif state == 'simple_kick':
# striker.mover.set_head_angles(0,0.25,0.3) # striker.mover.set_head_angles(0,0.25,0.3)
print('Doing the simple kick') # print('Doing the simple kick')
# just walk a short distance forward, ball should be near # just walk a short distance forward, ball should be near
# and it will probably be kicked in the right direction # and it will probably be kicked in the right direction
striker.speak("Simple Kick") # striker.speak("Simple Kick")
striker.mover.move_to(0.3, 0, 0) # striker.mover.move_to(0.3, 0, 0)
striker.mover.wait() # striker.mover.wait()
state = 'tracking' # state = 'tracking'
elif state == 'goal_align': elif state == 'goal_align':
# print(striker.ball_and_goal_search()) # print(striker.ball_and_goal_search())
try: try:
if striker.align_to_goal(): if striker.align_to_goal():
striker.speak('I am aligning to ball')
state = "align" state = "align"
except ValueError: except ValueError:
state = 'tracking' state = 'tracking'
elif state == 'align': elif state == 'align':
striker.speak('I am aligning to ball')
striker.mover.set_head_angles(0, 0.25, 0.3) striker.mover.set_head_angles(0, 0.25, 0.3)
sleep(0.5) sleep(0.5)
try: try:
success = striker.align_to_ball() success = striker.align_to_ball()
sleep(0.3) sleep(0.3)
if success: if success:
striker.speak('I am going. To kick ass')
state = 'kick' state = 'kick'
except ValueError: except ValueError:
striker.mover.set_head_angles(0, 0, 0.3) striker.mover.set_head_angles(0, 0, 0.3)