@@ -17,46 +17,146 @@ public class DriveTank extends CommandBase {
17
17
protected final Supplier <Double > leftSpeedSupplier ;
18
18
protected final Supplier <Double > rightSpeedSupplier ;
19
19
protected final Supplier <Boolean > isFinished ;
20
+ protected final boolean squareInputs ;
20
21
21
22
/**
22
23
* This constructs a new {@link DriveTank} command that moves the given
23
- * {@link TankDrivetrain} according to speed values from Double {@link Supplier}s for left and right sides.<br>
24
- * Positive values move forwards .
24
+ * {@link TankDrivetrain} according to speed values from Double {@link Supplier}s for left and right sides. <br>
25
+ * Positive values move the drivetrain forward .
25
26
*
26
- * @param drivetrain the drivetrain this command requires and moves.
27
- * @param leftSpeedSupplier the double {@link Supplier} supplying the speed to move on the left side with.
28
- * @param rightSpeedSupplier the double {@link Supplier} supplying the speed to move on the right side with.
27
+ * @param drivetrain the tank drivetrain this command operates on
28
+ * @param leftSpeedSupplier the double {@link Supplier} supplying the left side's speed (-1 to 1).
29
+ * Positive values go forwards
30
+ * @param rightSpeedSupplier the double {@link Supplier} supplying the right side's speed (-1 to 1).
31
+ * Positive values go forwards
32
+ * @param isFinished when to finish the command
33
+ * @param squareInputs whether to square the speed suppliers' values
29
34
*/
30
35
public DriveTank (TankDrivetrain drivetrain , Supplier <Double > leftSpeedSupplier ,
31
- Supplier <Double > rightSpeedSupplier , Supplier <Boolean > isFinished ) {
36
+ Supplier <Double > rightSpeedSupplier , Supplier <Boolean > isFinished , boolean squareInputs ) {
32
37
addRequirements (drivetrain );
33
38
this .tankDrivetrain = drivetrain ;
34
39
this .leftSpeedSupplier = leftSpeedSupplier ;
35
40
this .rightSpeedSupplier = rightSpeedSupplier ;
36
41
this .isFinished = isFinished ;
42
+ this .squareInputs = squareInputs ;
43
+ }
44
+
45
+ /**
46
+ * This constructs a new {@link DriveTank} command that moves the given
47
+ * {@link TankDrivetrain} according to speed values from Double {@link Supplier}s for left and right sides. <br>
48
+ * Positive values move the drivetrain forward. Does not square the inputs.
49
+ *
50
+ * @param drivetrain the tank drivetrain this command operates on
51
+ * @param leftSpeedSupplier the double {@link Supplier} supplying the left side's speed (-1 to 1).
52
+ * Positive values go forwards
53
+ * @param rightSpeedSupplier the double {@link Supplier} supplying the right side's speed (-1 to 1).
54
+ * Positive values go forwards
55
+ * @param isFinished when to finish the command
56
+ */
57
+ public DriveTank (TankDrivetrain drivetrain , Supplier <Double > leftSpeedSupplier ,
58
+ Supplier <Double > rightSpeedSupplier , Supplier <Boolean > isFinished ) {
59
+ this (drivetrain , leftSpeedSupplier , rightSpeedSupplier , isFinished , false );
60
+ }
61
+
62
+ /**
63
+ * This constructs a new {@link DriveTank} command that moves the given
64
+ * {@link TankDrivetrain} according to speed values from Double {@link Supplier}s for left and right sides. <br>
65
+ * Positive values move the drivetrain forward.
66
+ *
67
+ * @param drivetrain the tank drivetrain this command operates on
68
+ * @param leftSpeedSupplier the double {@link Supplier} supplying the left side's speed (-1 to 1).
69
+ * Positive values go forwards
70
+ * @param rightSpeedSupplier the double {@link Supplier} supplying the right side's speed (-1 to 1).
71
+ * Positive values go forwards
72
+ * @param squareInputs whether to square the speed suppliers' values
73
+ */
74
+ public DriveTank (TankDrivetrain drivetrain , Supplier <Double > leftSpeedSupplier ,
75
+ Supplier <Double > rightSpeedSupplier , boolean squareInputs ) {
76
+ this (drivetrain , leftSpeedSupplier , rightSpeedSupplier , () -> false , squareInputs );
37
77
}
38
78
79
+ /**
80
+ * This constructs a new {@link DriveTank} command that moves the given
81
+ * {@link TankDrivetrain} according to speed values from Double {@link Supplier}s for left and right sides. <br>
82
+ * Positive values move the drivetrain forward. Does not square the inputs.
83
+ *
84
+ * @param drivetrain the tank drivetrain this command operates on
85
+ * @param leftSpeedSupplier the double {@link Supplier} supplying the left side's speed (-1 to 1).
86
+ * Positive values go forwards
87
+ * @param rightSpeedSupplier the double {@link Supplier} supplying the right side's speed (-1 to 1).
88
+ * Positive values go forwards
89
+ */
39
90
public DriveTank (TankDrivetrain drivetrain , Supplier <Double > leftSpeedSupplier ,
40
91
Supplier <Double > rightSpeedSupplier ) {
41
- this (drivetrain , leftSpeedSupplier , rightSpeedSupplier , () -> false );
92
+ this (drivetrain , leftSpeedSupplier , rightSpeedSupplier , () -> false , false );
42
93
}
43
94
44
- public DriveTank (TankDrivetrain drivetrain , double leftSpeed , double rightSpeed , boolean isFinished ) {
45
- this (drivetrain , () -> leftSpeed , () -> rightSpeed , () -> isFinished );
95
+ /**
96
+ * This constructs a new {@link DriveTank} command that moves the given
97
+ * {@link TankDrivetrain} according to speed values for left and right sides. <br>
98
+ * Positive values move the drivetrain forward.
99
+ *
100
+ * @param drivetrain the tank drivetrain this command operates on
101
+ * @param leftSpeed the left side's speed (-1 to 1). Positive values go forwards
102
+ * @param rightSpeed the right side's speed (-1 to 1). Positive values go forwards
103
+ * @param isFinished when to finish the command
104
+ * @param squareInputs whether to square the speed values
105
+ */
106
+ public DriveTank (TankDrivetrain drivetrain , double leftSpeed ,
107
+ double rightSpeed , Supplier <Boolean > isFinished , boolean squareInputs ) {
108
+ this (drivetrain , () -> leftSpeed , () -> rightSpeed , isFinished , squareInputs );
109
+ }
110
+
111
+ /**
112
+ * This constructs a new {@link DriveTank} command that moves the given
113
+ * {@link TankDrivetrain} according to speed values for left and right sides. <br>
114
+ * Positive values move the drivetrain forward. Does not square the inputs.
115
+ *
116
+ * @param drivetrain the tank drivetrain this command operates on
117
+ * @param leftSpeed the left side's speed (-1 to 1). Positive values go forwards
118
+ * @param rightSpeed the right side's speed (-1 to 1). Positive values go forwards
119
+ * @param isFinished when to finish the command
120
+ */
121
+ public DriveTank (TankDrivetrain drivetrain , double leftSpeed , double rightSpeed , Supplier <Boolean > isFinished ) {
122
+ this (drivetrain , leftSpeed , rightSpeed , isFinished , false );
46
123
}
47
124
125
+ /**
126
+ * This constructs a new {@link DriveTank} command that moves the given
127
+ * {@link TankDrivetrain} according to speed values for left and right sides. <br>
128
+ * Positive values move the drivetrain forward.
129
+ *
130
+ * @param drivetrain the tank drivetrain this command operates on
131
+ * @param leftSpeed the left side's speed (-1 to 1). Positive values go forwards
132
+ * @param rightSpeed the right side's speed (-1 to 1). Positive values go forwards
133
+ * @param squareInputs whether to square the speed values
134
+ */
135
+ public DriveTank (TankDrivetrain drivetrain , double leftSpeed , double rightSpeed , boolean squareInputs ) {
136
+ this (drivetrain , leftSpeed , rightSpeed , () -> false , squareInputs );
137
+ }
138
+
139
+ /**
140
+ * This constructs a new {@link DriveTank} command that moves the given
141
+ * {@link TankDrivetrain} according to speed values for left and right sides. <br>
142
+ * Positive values move the drivetrain forward. Does not square the inputs.
143
+ *
144
+ * @param drivetrain the tank drivetrain this command operates on
145
+ * @param leftSpeed the left side's speed (-1 to 1). Positive values go forwards
146
+ * @param rightSpeed the right side's speed (-1 to 1). Positive values go forwards
147
+ */
48
148
public DriveTank (TankDrivetrain drivetrain , double leftSpeed , double rightSpeed ) {
49
- this (drivetrain , () -> leftSpeed , () -> rightSpeed , () -> false );
149
+ this (drivetrain , leftSpeed , rightSpeed , () -> false , false );
50
150
}
51
151
52
152
@ Override
53
153
public void execute () {
54
- tankDrivetrain .tankDrive (leftSpeedSupplier .get (), rightSpeedSupplier .get ());
154
+ tankDrivetrain .tankDrive (leftSpeedSupplier .get (), rightSpeedSupplier .get (), squareInputs );
55
155
}
56
156
57
157
@ Override
58
158
public boolean isFinished () {
59
- return this . isFinished .get ();
159
+ return isFinished .get ();
60
160
}
61
161
62
162
@ Override
0 commit comments