This repository has been archived by the owner on Jan 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrobot.py
executable file
·73 lines (52 loc) · 1.96 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
#!/usr/bin/env python3
from commandbased import CommandBasedRobot
from wpilib._impl.main import run
from wpilib import RobotBase
from custom import driverhud
import controller.layout
import subsystems
import shutil, sys
from wpilib.command import Subsystem
from subsystems.monitor import Monitor as monitor
from subsystems.drivetrain import DriveTrain as drivetrain
from subsystems.relay import Relay as relay
from subsystems.pneumatics import Pneumatics as pneumatics
from subsystems.turret import Turret as turret
class KryptonBot(CommandBasedRobot):
'''Implements a Command Based robot design'''
def robotInit(self):
'''Set up everything we need for a working robot.'''
if RobotBase.isSimulation():
import mockdata
self.subsystems()
controller.layout.init()
driverhud.init()
from commands.startupcommandgroup import StartUpCommandGroup
StartUpCommandGroup().start()
def autonomousInit(self):
'''This function is called each time autonomous mode starts.'''
# Send field data to the dashboard
driverhud.showField()
# Schedule the autonomous command
auton = driverhud.getAutonomousProgram()
auton.start()
driverhud.showInfo("Starting %s" % auton)
def handleCrash(self, error):
super().handleCrash()
driverhud.showAlert('Fatal Error: %s' % error)
@classmethod
def subsystems(cls):
vars = globals()
print('vars: ' + str(vars.items()))
module = sys.modules['robot']
for key, var in vars.items():
try:
if issubclass(var, Subsystem) and var is not Subsystem:
setattr(module, key, var())
except TypeError:
pass
if __name__ == '__main__':
if len(sys.argv) > 1 and sys.argv[1] == 'deploy':
shutil.rmtree('opkg_cache', ignore_errors=True)
shutil.rmtree('pip_cache', ignore_errors=True)
run(KryptonBot)