forked from peprolinbot/EV3D4-ssh_control
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conbot.py
62 lines (50 loc) · 1.51 KB
/
conbot.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env python3
# so that script can be run from Brickman
import subprocess
import termios, tty, sys
from ev3dev.ev3 import *
# attach large motors to ports B and C, medium motor to port A
motor_left = LargeMotor('outC')
motor_right = LargeMotor('outB')
#==============================================
print("\n============To the order!============\n\n\n\n============LOG============\n")
#==============================================
def getch():
fd = sys.stdin.fileno()
old_settings = termios.tcgetattr(fd)
tty.setcbreak(fd)
ch = sys.stdin.read(1)
termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
return ch
def marchaimp():
subprocess.call(['python3', 'marchaImperial'])
#==============================================
def fire():
motor_a.run_timed(time_sp=3000, speed_sp=600)
#==============================================
def forward():
motor_left.run_forever(speed_sp=450)
motor_right.run_forever(speed_sp=450)
#==============================================
def back():
motor_left.run_forever(speed_sp=-450)
motor_right.run_forever(speed_sp=-450)
#==============================================
def stop():
motor_left.run_forever(speed_sp=0)
motor_right.run_forever(speed_sp=0)
motor_a.run_forever(speed_sp=0)
#==============================================
while True:
k = getch()
print(k)
if k == 'm':
marchaimp()
if k == 'g':
forward()
if k == 'w':
back()
if k == ' ':
stop()
if k == 'q':
exit()