4
4
5
5
import com .team766 .hal .MotorController ;
6
6
import com .team766 .hal .MotorController .ControlMode ;
7
+ import com .team766 .hal .wpilib .REVThroughBoreDutyCycleEncoder ;
7
8
import com .team766 .hal .RobotProvider ;
8
9
import com .team766 .logging .Category ;
9
10
import com .team766 .odometry .DifferentialDriveOdometry ;
@@ -18,37 +19,48 @@ public class BurroDrive extends Drive {
18
19
19
20
private final MotorController leftMotor ;
20
21
private final MotorController rightMotor ;
22
+ private final REVThroughBoreDutyCycleEncoder leftEncoder ;
23
+ private final REVThroughBoreDutyCycleEncoder rightEncoder ;
21
24
private DifferentialDriveKinematics differentialDriveKinematics ;
22
25
private DifferentialDriveOdometry differentialDriveOdometry ;
23
26
24
- // todo set actual ratio
27
+ // TODO set actual ratio
25
28
private static final double DRIVE_GEAR_RATIO = 1 ; // Gear ratio
26
29
27
- // todo set actual radius
30
+ // TODO set actual radius
28
31
private static final double WHEEL_RADIUS = 1 ; // Radius of the wheels
29
32
33
+ // TODO
34
+ private static final double ENCODER_UNIT_TO_REVOLUTION_CONSTANT = 1. ;
35
+
30
36
private static final double MOTOR_WHEEL_FACTOR_MPS =
31
37
1.
32
38
/ WHEEL_RADIUS // Wheel radians/sec
33
39
* DRIVE_GEAR_RATIO // Motor radians/sec
34
- / (2 * Math .PI ); // Motor rotations/sec (what velocity mode takes));
40
+ / (2 * Math .PI ) // Motor rotations/sec (what velocity mode takes))
41
+ * ENCODER_UNIT_TO_REVOLUTION_CONSTANT ; // Encoder units/sec
42
+
43
+ // TODO
44
+ private static final double TRACK_WIDTH_METERS = 0.4 ; // Distance between left and right wheel
35
45
36
- public BurroDrive (double trackWidthMeters ) {
46
+ public BurroDrive () {
37
47
loggerCategory = Category .DRIVE ;
38
48
39
49
leftMotor = RobotProvider .instance .getMotor (DRIVE_LEFT );
40
50
rightMotor = RobotProvider .instance .getMotor (DRIVE_RIGHT );
41
51
42
- differentialDriveKinematics = new DifferentialDriveKinematics (trackWidthMeters );
52
+ leftEncoder = null ; //FIXME
53
+ rightEncoder = null ; //FIXME
54
+
55
+ differentialDriveKinematics = new DifferentialDriveKinematics (TRACK_WIDTH_METERS );
43
56
differentialDriveOdometry =
44
57
new DifferentialDriveOdometry (
45
- leftMotor ,
46
- rightMotor ,
58
+ leftEncoder ,
59
+ rightEncoder ,
47
60
WHEEL_RADIUS * 2 * Math .PI ,
48
61
DRIVE_GEAR_RATIO ,
49
- 1. ,
50
- 0 // TODO
51
- );
62
+ ENCODER_UNIT_TO_REVOLUTION_CONSTANT ,
63
+ TRACK_WIDTH_METERS );
52
64
}
53
65
54
66
/**
@@ -109,4 +121,9 @@ public ChassisSpeeds getChassisSpeeds() {
109
121
}
110
122
111
123
public void setCross () {}
124
+
125
+ @ Override
126
+ public void run () {
127
+ differentialDriveOdometry .run ();
128
+ }
112
129
}
0 commit comments