-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathK_turn.py
38 lines (29 loc) · 880 Bytes
/
K_turn.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from picarx_improved import picarx_improved
import time
def k_turn(u_turn):
angle1= 35
power1 = 20
if u_turn == 'left':
picarx_improved.set_dir_servo_angle(-angle1)
else:
picarx_improved.set_dir_servo_angle(angle1)
picarx_improved.forward(power1)
time.sleep(1)
if u_turn == 'left':
picarx_improved.set_dir_servo_angle(angle1)
else:
picarx_improved.set_dir_servo_angle(-angle1)
picarx_improved.backward(power1)
time.sleep(1)
if u_turn == 'right':
picarx_improved.set_dir_servo_angle(angle1-5)
else:
picarx_improved.set_dir_servo_angle(-angle1+5)
picarx_improved.forward(power1+5)
time.sleep(1)
picarx_improved.set_dir_servo_angle(0)
picarx_improved.forward(power1)
time.sleep(1)
picarx_improved.stop()
if __name__ == "__main__":
k_turn('right')