Skip to content
Snippets Groups Projects
Commit b48a1559 authored by ft-Demo's avatar ft-Demo
Browse files

commit by robo pro coding

parent 0a387609
No related branches found
No related tags found
No related merge requests found
This diff is collapsed.
......@@ -58,19 +58,22 @@ def checkTimeoutsSetGoalBoth():
def stepOnlyGoal():
global shot, v, ticks, factor_x, state, ts_ball, ts_goal_left, ts_goal_right, cmd, factor_y, goal_width, posx_ball, posx_goal_left, posx_goal_right, x_min, posx_goal_both, posy_ball, posy_goal_left, posy_goal_right, v_slow, x_max, v_var_ball_xpos, y_ball_far, v_fast, y_ball_touch, v_var_ball_ypos, y_ball_near, search_dir_left, ts_deltas
if posx_goal_both >= x_min and posx_goal_both <= x_max:
if goal_width < 130:
fwd(v_slow, 10)
elif goal_width > 40:
bwd(v_slow, 10)
if posx_goal_left != None and posx_goal_right != None:
if posx_goal_both >= x_min and posx_goal_both <= x_max:
if goal_width < 130:
fwd(v_slow, 10)
elif goal_width > 40:
bwd(v_slow, 10)
else:
pass
elif posx_goal_both < x_min:
left(v_slow, 10)
elif posx_goal_both > x_max:
right(v_slow, 10)
else:
pass
elif posx_goal_both < x_min:
left(v_slow, 10)
elif posx_goal_both > x_max:
right(v_slow, 10)
else:
pass
left(v_slow, 10)
def stepBall(shot):
......@@ -315,12 +318,12 @@ while True:
turnSideRight(v_slow, 20)
elif posx_goal_left != None and posx_goal_right == None:
state = 'BALL_GOAL_LEFT'
right(v_slow, 10)
turnSideLeft(v_slow, 10)
right(v_slow, 20)
turnSideLeft(v_slow, 20)
elif posx_goal_left == None and posx_goal_right != None:
state = 'BALL_GOAL_RIGHT'
left(v_slow, 10)
turnSideRight(v_slow, 10)
left(v_slow, 20)
turnSideRight(v_slow, 20)
else:
state = 'BALL_NO_GOAL'
stepBall(False)
......@@ -350,6 +353,9 @@ while True:
ts_deltas = [(time.time() * 1000) - ts_ball, (time.time() * 1000) - ts_goal_left, (time.time() * 1000) - ts_goal_right]
print('{:.1f} {:.1f} {:.1f} {}:{} GOAL left: {} {}, right:{} {}, p:{}, w:{} BALL_pos:{},{} v_x:{} v_y:{}'.format(ts_deltas[0], ts_deltas[1], ts_deltas[2], state, cmd, posx_goal_left, posy_goal_left, posx_goal_right, posy_goal_right, posx_goal_both, goal_width, posx_ball, posy_ball, v_var_ball_xpos, v_var_ball_ypos))
checkTimeoutsSetGoalBoth()
time.sleep(min(ts_deltas) / 1000)
if posx_ball != None and posx_goal_left != None and posx_goal_right != None:
time.sleep(min(ts_deltas) / 1000)
else:
time.sleep(0.01)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment