-
Notifications
You must be signed in to change notification settings - Fork 0
/
robot.py
57 lines (41 loc) · 1.71 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
from phoenix6.signals import NeutralModeValue
from wpilib import TimedRobot, Timer
from commands2 import Command, CommandScheduler
from robotContainer import RobotContainer
class Robot(TimedRobot):
autonomousCommand: Command = None
robotContainer: RobotContainer
coastTime = Timer()
def robotInit(self) -> None:
# Instantiate our RobotContainer. This will perform all our button bindings,
# and put our autonomous chooser on the dashboard.
self.robotContainer = RobotContainer()
def robotPeriodic(self) -> None:
CommandScheduler.getInstance().run()
def autonomousInit(self) -> None:
self.autonomousCommand = self.robotContainer.getAutonomousCommand()
if self.autonomousCommand is not None:
self.autonomousCommand.schedule()
def autonomousPeriodic(self) -> None:
pass
def teleopInit(self) -> None:
if self.autonomousCommand is not None:
self.autonomousCommand.cancel()
self.robotContainer.getSwerve().setNeutralModes(
NeutralModeValue.BRAKE, NeutralModeValue.BRAKE
)
def teleopPeriodic(self) -> None:
pass
def testInit(self) -> None:
# Cancels all running commands at the start of test mode.
CommandScheduler.getInstance().cancelAll()
def testPeriodic(self) -> None:
pass
def disabledInit(self) -> None:
self.coastTime.reset()
self.coastTime.start()
def disabledPeriodic(self) -> None:
if self.coastTime.get() == 5:
self.robotContainer.getSwerve().setNeutralModes(
NeutralModeValue.COAST, NeutralModeValue.COAST
)