|
7 | 7 |
|
8 | 8 | import rev |
9 | 9 | import wpilib |
10 | | -from wpilib.drive import DifferentialDrive |
11 | 10 |
|
12 | 11 |
|
13 | 12 | class Robot(wpilib.TimedRobot): |
14 | | - def robotInit(self): |
| 13 | + def __init__(self): |
| 14 | + super().__init__() |
15 | 15 | # SPARK MAX controllers are intialized over CAN by constructing a |
16 | 16 | # CANSparkMax object |
17 | 17 | # |
18 | | - # The CAN ID, which can be configured using the SPARK MAX Client, is passed |
19 | | - # as the first parameter |
| 18 | + # The CAN bus ID is passed as the first parameter, and the device ID, |
| 19 | + # which can be configured using the SPARK MAX Client, is passed as the |
| 20 | + # second parameter. |
20 | 21 | # |
21 | | - # The motor type is passed as the second parameter. |
| 22 | + # The motor type is passed as the third parameter. |
22 | 23 | # Motor type can either be: |
23 | 24 | # rev.CANSparkMax.MotorType.kBrushless |
24 | 25 | # rev.CANSparkMax.MotorType.kBrushed |
25 | 26 | # |
26 | 27 | # The example below initializes four brushless motors with CAN IDs |
27 | 28 | # 1, 2, 3, 4. Change these parameters to match your setup |
28 | | - self.leftLeadMotor = rev.SparkMax(1, rev.SparkMax.MotorType.kBrushless) |
29 | | - self.rightLeadMotor = rev.SparkMax(3, rev.SparkMax.MotorType.kBrushless) |
30 | | - self.leftFollowMotor = rev.SparkMax(2, rev.SparkMax.MotorType.kBrushless) |
31 | | - self.rightFollowMotor = rev.SparkMax(4, rev.SparkMax.MotorType.kBrushless) |
| 29 | + self.leftLeadMotor = rev.SparkMax(0, 1, rev.SparkMax.MotorType.kBrushless) |
| 30 | + self.rightLeadMotor = rev.SparkMax(0, 3, rev.SparkMax.MotorType.kBrushless) |
| 31 | + self.leftFollowMotor = rev.SparkMax(0, 2, rev.SparkMax.MotorType.kBrushless) |
| 32 | + self.rightFollowMotor = rev.SparkMax(0, 4, rev.SparkMax.MotorType.kBrushless) |
32 | 33 |
|
33 | 34 | # Passing in the lead motors into DifferentialDrive allows any |
34 | 35 | # commmands sent to the lead motors to be sent to the follower motors. |
35 | | - self.driveTrain = DifferentialDrive(self.leftLeadMotor, self.rightLeadMotor) |
| 36 | + self.driveTrain = wpilib.DifferentialDrive( |
| 37 | + self.leftLeadMotor, self.rightLeadMotor |
| 38 | + ) |
36 | 39 | self.joystick = wpilib.Joystick(0) |
37 | 40 |
|
38 | 41 | # Create new SPARK MAX configuration objects. These will store the |
|
0 commit comments