-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtask2.py
45 lines (34 loc) · 1.63 KB
/
task2.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
import wpilib
import rev
class MyRobot(wpilib.IterativeRobot):
def robotInit(self):
"""
This function is called upon program startup and
should be used for any initialization code.
"""
self.leftSpark1 = rev.CANSparkMax(15, rev.MotorType.kBrushless)
self.leftSpark2 = rev.CANSparkMax(14, rev.MotorType.kBrushless)
self.leftSpark3 = rev.CANSparkMax(13, rev.MotorType.kBrushless)
self.rightSpark1 = rev.CANSparkMax(20, rev.MotorType.kBrushless)
self.rightSpark2 = rev.CANSparkMax(1, rev.MotorType.kBrushless)
self.rightSpark3 = rev.CANSparkMax(2, rev.MotorType.kBrushless)
self.joystick1 = wpilib.Joystick(0)
self.joystick2 = wpilib.Joystick(1)
self.leftSparks = wpilib.SpeedControllerGroup(self.leftSpark1, self.leftSpark2, self.leftSpark3)
self.rightSparks = wpilib.SpeedControllerGroup(self.rightSpark1, self.rightSpark2, self.rightSpark3)
def autonomousInit(self):
"""This function is run once each time the robot enters the autonomous mode."""
def autonomousPeriodic(self):
"""This function is called periodically during autonomous."""
def teleopInit(self):
"""This function is run once each time the robot enters the teleoperated mode."""
def teleopPeriodic(self):
"""This function is called periodically during operator control."""
self.leftSparks.set(-self.joystick1.getY() + self.joystick2.getX())
self.rightSparks.set(self.joystick1.getY() + self.joystick2.getX())
def disabledInit(self):
"""This function is run once each time the robot enters the disabled mode."""
def disabledPeriodic(self):
"""This function is called periodically during disabled."""
if __name__ == "__main__":
wpilib.run(MyRobot)