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

View File

@@ -197,7 +197,8 @@ class Striker(object):
# sign = 1 if dy > 0 else -1
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:
raise ValueError('No ball')
x, y = ball_angles
@@ -268,7 +269,7 @@ class Striker(object):
def goal_search(self):
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:
self.mover.set_head_angles(angle, 0)
sleep(0.5)
@@ -389,7 +390,7 @@ if __name__ == '__main__':
if state == 'tracking':
# start ball approach when ball is visible
if striker.ball_tracking():
striker.speak("ball_approach")
striker.speak("Ball approach")
state = 'ball_approach'
elif state == 'ball_approach':
@@ -407,33 +408,34 @@ if __name__ == '__main__':
striker.run_to_ball()
state = 'tracking'
elif state == 'simple_kick':
# elif state == 'simple_kick':
# 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
# and it will probably be kicked in the right direction
striker.speak("Simple Kick")
striker.mover.move_to(0.3, 0, 0)
striker.mover.wait()
state = 'tracking'
# striker.speak("Simple Kick")
# striker.mover.move_to(0.3, 0, 0)
# striker.mover.wait()
# state = 'tracking'
elif state == 'goal_align':
# print(striker.ball_and_goal_search())
try:
if striker.align_to_goal():
striker.speak('I am aligning to ball')
state = "align"
except ValueError:
state = 'tracking'
elif state == 'align':
striker.speak('I am aligning to ball')
striker.mover.set_head_angles(0, 0.25, 0.3)
sleep(0.5)
try:
success = striker.align_to_ball()
sleep(0.3)
if success:
striker.speak('I am going. To kick ass')
state = 'kick'
except ValueError:
striker.mover.set_head_angles(0, 0, 0.3)