-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDriveTrain.java
116 lines (88 loc) · 4.03 KB
/
DriveTrain.java
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package org.usfirst.frc.team2637.robot;
import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX;
import com.ctre.phoenix.motorcontrol.can.WPI_VictorSPX;
import edu.wpi.first.wpilibj.Encoder;
import edu.wpi.first.wpilibj.Solenoid;
import edu.wpi.first.wpilibj.drive.DifferentialDrive;
public class DriveTrain {
//motor controllers
private WPI_TalonSRX drvTrainMtrCtrlRightBack;
private WPI_TalonSRX drvTrainMtrCtrlLeftBack;
private WPI_VictorSPX drvTrainMtrCtrlRightMiddle;
private WPI_VictorSPX drvTrainMtrCtrlRightFront;
private WPI_VictorSPX drvTrainMtrCtrlLeftMiddle;
private WPI_VictorSPX drvTrainMtrCtrlLeftFront;
private final int DRVTRAIN_MTR_ID_RIGHT_BACK = 6;
private final int DRVTRAIN_MTR_ID_LEFT_BACK = 5;
private final int DRVTRAIN_MTR_ID_RIGHT_MIDDLE = 1;
private final int DRVTRAIN_MTR_ID_LEFT_MIDDLE = 2;
private final int DRVTRAIN_MTR_ID_RIGHT_FRONT = 3;
private final int DRVTRAIN_MTR_ID_LEFT_FRONT = 4;
private DifferentialDrive drvTrainDifferentialDrive;
//solenoids
/*
private Solenoid drvTrainGearBoxShifterR;
private Solenoid drvTrainGearBoxShifterL;
private final int DRVTRAIN_GEARBOX_SHIFTER_PORT_RIGHT = 0;
private final int DRVTRAIN_GEARBOX_SHIFTER_PORT_LEFT = 0;
private final boolean DRVTRAIN_GEAR_HIGH = true;
private final boolean DRVTRAIN_GEAR_LOW = false;
//encoders
private Encoder drvTrainWheelEncoderR;
private Encoder drvTrainWheelEncoderL;
private final int DRVTRAIN_WHEEL_ENCODER_R_DIOA = 0;
private final int DRVTRAIN_WHEEL_ENCODER_R_DIOB = 0;
private final int DRVTRAIN_WHEEL_ENCODER_L_DIOA = 0;
private final int DRVTRAIN_WHEEL_ENCODER_L_DIOB = 0;
private final double DRVTRAIN_ENCODER_PULSES_PER_REV = 256.0;
private final double DRVTRAIN_WHEEL_DIAMETER = 6.0;
private final double DRVTRAIN_WHEEL_CIRCUMFRENCE = DRVTRAIN_WHEEL_DIAMETER * Math.PI;
private final double DRVTRAIN_ENCODER_INCHES_PER_PULSE = DRVTRAIN_WHEEL_CIRCUMFRENCE / DRVTRAIN_ENCODER_PULSES_PER_REV;
*/
public DriveTrain() {
//initialize motor controllers
drvTrainMtrCtrlRightBack = new WPI_TalonSRX(DRVTRAIN_MTR_ID_RIGHT_BACK);
drvTrainMtrCtrlLeftBack = new WPI_TalonSRX(DRVTRAIN_MTR_ID_LEFT_BACK);
drvTrainMtrCtrlRightMiddle = new WPI_VictorSPX(DRVTRAIN_MTR_ID_RIGHT_MIDDLE);
drvTrainMtrCtrlLeftMiddle = new WPI_VictorSPX(DRVTRAIN_MTR_ID_LEFT_MIDDLE);
drvTrainMtrCtrlRightFront = new WPI_VictorSPX(DRVTRAIN_MTR_ID_RIGHT_FRONT);
drvTrainMtrCtrlLeftFront = new WPI_VictorSPX(DRVTRAIN_MTR_ID_LEFT_FRONT);
drvTrainMtrCtrlRightFront.follow(drvTrainMtrCtrlRightBack);
drvTrainMtrCtrlRightMiddle.follow(drvTrainMtrCtrlRightBack);
drvTrainMtrCtrlLeftMiddle.follow(drvTrainMtrCtrlLeftBack);
drvTrainMtrCtrlLeftFront.follow(drvTrainMtrCtrlLeftBack);
drvTrainDifferentialDrive = new DifferentialDrive(drvTrainMtrCtrlLeftBack, drvTrainMtrCtrlRightBack);
//initialize solenoids
/*
drvTrainGearBoxShifterR = new Solenoid(DRVTRAIN_GEARBOX_SHIFTER_PORT_RIGHT);
drvTrainGearBoxShifterL = new Solenoid(DRVTRAIN_GEARBOX_SHIFTER_PORT_LEFT);
//initialize encoders
drvTrainWheelEncoderR = new Encoder(DRVTRAIN_WHEEL_ENCODER_R_DIOA, DRVTRAIN_WHEEL_ENCODER_R_DIOB,
false, Encoder.EncodingType.k4X);
drvTrainWheelEncoderL = new Encoder(DRVTRAIN_WHEEL_ENCODER_L_DIOA, DRVTRAIN_WHEEL_ENCODER_L_DIOB,
false, Encoder.EncodingType.k4X);
drvTrainWheelEncoderR.setDistancePerPulse(DRVTRAIN_ENCODER_INCHES_PER_PULSE);
drvTrainWheelEncoderR.setReverseDirection(true);
drvTrainWheelEncoderL.setDistancePerPulse(DRVTRAIN_ENCODER_INCHES_PER_PULSE);
*/
}
/*
public void setHighGear() {
drvTrainGearBoxShifterR.set(DRVTRAIN_GEAR_HIGH);
drvTrainGearBoxShifterL.set(DRVTRAIN_GEAR_HIGH);
}
public void setLowGear() {
drvTrainGearBoxShifterR.set(DRVTRAIN_GEAR_LOW);
drvTrainGearBoxShifterL.set(DRVTRAIN_GEAR_LOW);
}
public Encoder getDrvTrainWheelEncoderR() {
return this.drvTrainWheelEncoderR;
}
public Encoder getDrvTrainWheelEncoderL() {
return this.drvTrainWheelEncoderL;
}
*/
public void arcadeDrive(double xSpeed, double zRotation) {
drvTrainDifferentialDrive.arcadeDrive(xSpeed, zRotation);
}
}