-
Notifications
You must be signed in to change notification settings - Fork 2
/
robot.py
49 lines (30 loc) · 1.25 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
import commands2
import wpilib
from robotcontainer import RobotContainer
# vision setup
class MyRobot(commands2.TimedCommandRobot):
def robotInit(self):
self.container = RobotContainer()
self.autoCommand = self.container.getAutonomousCommand()
def robotPeriodic(self):
commands2.CommandScheduler.getInstance().run()
def autonomousInit(self):
self.autoCommand = self.container.getAutonomousCommand()
if self.autoCommand:
self.autoCommand.schedule()
def autonomousPeriodic(self):
pass
def teleopInit(self):
if self.autoCommand:
self.autoCommand.cancel()
self.drivingMode = self.container.getDrivingMode()
self.container.getSwerveDrive().setDefaultCommand(self.drivingMode)
def teleopPeriodic(self):
if self.drivingMode != self.container.getDrivingMode():
self.container.getSwerveDrive().removeDefaultCommand()
self.container.getSwerveDrive().setDefaultCommand(self.container.getDrivingMode())
self.drivingMode = self.container.getDrivingMode()
def testInit(self):
commands2.CommandScheduler.getInstance().cancelAll()
if __name__ == "__main__":
wpilib.run(MyRobot)