-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrobot.py
57 lines (40 loc) · 1.89 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
import wpilib
from phoenix5 import WPI_TalonSRX, NeutralMode
import wpilib.drive
breakMode = NeutralMode(2)
class MyRobot(wpilib.TimedRobot):
def robotInit(self) -> None:
self.motorRightMaster = WPI_TalonSRX(1)
self.motorRightSlave = WPI_TalonSRX(2)
self.motorRightMaster.setNeutralMode(breakMode)
self.motorRightSlave.setNeutralMode(breakMode)
self.motorRightMaster.setSafetyEnabled(True)
self.motorRightSlave.setSafetyEnabled(True)
self.right = wpilib.MotorControllerGroup(self.motorRightMaster, self.motorRightSlave)
self.right.setInverted(True)
self.motorLeftMaster = WPI_TalonSRX(3)
self.motorLeftSlave = WPI_TalonSRX(4)
self.motorLeftMaster.setNeutralMode(breakMode)
self.motorLeftSlave.setNeutralMode(breakMode)
self.motorLeftMaster.setSafetyEnabled(True)
self.motorLeftSlave.setSafetyEnabled(True)
self.left = wpilib.MotorControllerGroup(self.motorLeftMaster, self.motorLeftSlave)
self.left.setInverted(False)
self.robotDrive = wpilib.drive.DifferentialDrive(self.left, self.right)
self.controller = wpilib.XboxController(0)
def autonomousInit(self) -> None:
"""The function is called when autonomous starts"""
return None
def autonomousPeriodic(self) -> None:
"""The function is called periodically during autonomous mode"""
return None
def teleopInit(self) -> None:
"""The function is called when teleoperated starts"""
return None
def teleopPeriodic(self) -> None:
"""The function is called periodically during teleoperated mode"""
self.robotDrive.arcadeDrive(
-self.controller.getLeftY(), -self.controller.getRightX(), True
)
if __name__ == "__main__":
wpilib.run(MyRobot)