-
Notifications
You must be signed in to change notification settings - Fork 0
/
robot.py
76 lines (61 loc) · 2.54 KB
/
robot.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import wpilib as wpi
import util.config as config
import util.logging as logging
from Subsystems import Drive, Autonomous
from threading import Timer
class Myrobot(wpi.IterativeRobot):
def robotInit(self):
self.drive = Drive.RobotDrive()
self.drive_type = config.TANK
# only way to get the compressor to start
# config.drop_sole = wpi.Solenoid(0)
# config.shoot_sole = wpi.Solenoid(1)
# only way to get the Encoders to work
# config.encoders = [
# wpi.Encoder(aChannel=0, bChannel=1, reverseDirection=True),
# wpi.Encoder(aChannel=2, bChannel=3, reverseDirection=True),
# wpi.Encoder(aChannel=4, bChannel=5, reverseDirection=True),
# wpi.Encoder(aChannel=6, bChannel=7, reverseDirection=True)]
# for enc in config.encoders:
# enc.reset()
# enc.setMinRate(5)
# enc.setSamplesToAverage(5)
def autonomousInit(self):
logging.write_message("\nTREMBLE, BEFORE ME HUMAN\n")
config.auto_state = 0 # sets the autonomous state var to 0
Autonomous.init_arm()
# sets the timer up
self.bkwd_timer = Timer(1.5, lambda: Autonomous.move_backward())
self.stop_timer = Timer(1.5, lambda: Autonomous.stop())
Autonomous.move_forward()
self.bkwd_timer.start()
def autonomousPeriodic(self):
if config.auto_state > 0:
self.stop_timer.start()
config.auto_state = 0
def teleopInit(self):
logging.write_message("\nYOU MAY CONTROL ME FOR NOW BUT I WILL RETURN\n")
def teleopPeriodic(self):
# drive.drive.drive.drive.drive()
self.drive.drive(self.drive_type)
## to catch button presses
# to shoot, press A
# if XboxButtons.A.poll():
# Shooter.shoot(config.shoot_mtr, config.suck_mtr, config.shoot_sole)
# returns the wheels to the default position
# if XboxButtons.X.poll():
# self.drive.default()
# to suck, press B
# if XboxButtons.B.poll():
# Shooter.suck(config.shoot_mtr, config.suck_mtr, config.shoot_sole)
# else:
# Shooter.suck_stop(config.shoot_mtr, config.suck_mtr)
# raise/lower the arm
# if XboxButtons.Y.poll():
# Shooter.toggle_arm(config.drop_sole)
# to toggle logging to the Driver Station
# press the Select button
# if XboxButtons.Start.poll():
# config.LOGGING = not config.LOGGING
if __name__ == "__main__":
wpi.run(Myrobot)