|
13 | 13 |
|
14 | 14 | package frc.robot.commands;
|
15 | 15 |
|
| 16 | +import static frc.robot.subsystems.drive.DriveConstants.kSlowModeConstant; |
| 17 | +import static frc.robot.subsystems.drive.DriveConstants.kTurnSpeakerD; |
| 18 | +import static frc.robot.subsystems.drive.DriveConstants.kTurnSpeakerI; |
| 19 | +import static frc.robot.subsystems.drive.DriveConstants.kTurnSpeakerP; |
| 20 | + |
| 21 | +import java.util.function.DoubleSupplier; |
| 22 | +import java.util.function.Supplier; |
| 23 | + |
| 24 | +import org.littletonrobotics.junction.Logger; |
| 25 | + |
16 | 26 | import edu.wpi.first.math.MathUtil;
|
17 | 27 | import edu.wpi.first.math.controller.PIDController;
|
18 | 28 | import edu.wpi.first.math.geometry.Pose2d;
|
|
26 | 36 | import edu.wpi.first.wpilibj2.command.Command;
|
27 | 37 | import edu.wpi.first.wpilibj2.command.Commands;
|
28 | 38 | import edu.wpi.first.wpilibj2.command.FunctionalCommand;
|
29 |
| -import edu.wpi.first.wpilibj2.command.WaitCommand; |
30 |
| -import edu.wpi.first.wpilibj2.command.WaitCommand; |
31 |
| -import frc.robot.subsystems.indexer.Indexer; |
32 |
| -import frc.robot.subsystems.indexer.IndexerConstants; |
33 |
| -import frc.robot.subsystems.pivotArm.PivotArm; |
34 |
| -import frc.robot.subsystems.pivotArm.PivotArmConstants; |
35 | 39 | import frc.robot.FieldConstants;
|
36 | 40 | import frc.robot.subsystems.drive.Drive;
|
37 |
| -import frc.robot.subsystems.pivotArm.PivotArm; |
38 |
| -import frc.robot.subsystems.pivotArm.PivotArmConstants; |
39 |
| -import frc.robot.subsystems.shooter.*; |
40 |
| -import java.util.function.DoubleSupplier; |
41 |
| -import java.util.function.Supplier; |
42 |
| - |
43 |
| -import org.littletonrobotics.junction.Logger; |
44 |
| - |
45 |
| -import static frc.robot.subsystems.drive.DriveConstants.*; |
46 |
| -import static frc.robot.util.drive.DriveControls.DRIVE_AMP; |
| 41 | +import frc.robot.subsystems.drive.DriveConstants; |
47 | 42 |
|
48 | 43 | public class DriveCommands {
|
49 | 44 | private static final double DEADBAND = 0.1;
|
@@ -92,8 +87,9 @@ public static Command joystickDrive(
|
92 | 87 | linearVelocity.getY() * drive.getMaxLinearSpeedMetersPerSec(),
|
93 | 88 | omega * drive.getMaxAngularSpeedRadPerSec(),
|
94 | 89 | isFlipped
|
95 |
| - ? drive.getRotation()/* .plus(new Rotation2d(Math.PI)) */ |
96 |
| - : drive.getRotation())); |
| 90 | + ? drive.getRotation().plus(new Rotation2d(Math.PI)) |
| 91 | + : drive.getRotation() |
| 92 | + )); |
97 | 93 | },
|
98 | 94 | drive);
|
99 | 95 | }
|
@@ -132,7 +128,7 @@ public static Command joystickDriveRobotRelative(
|
132 | 128 | linearVelocity.getX() * drive.getMaxLinearSpeedMetersPerSec(),
|
133 | 129 | linearVelocity.getY() * drive.getMaxLinearSpeedMetersPerSec(),
|
134 | 130 | omega * drive.getMaxAngularSpeedRadPerSec(),
|
135 |
| - drive.getRotation())); |
| 131 | + new Rotation2d())); |
136 | 132 | },
|
137 | 133 | drive);
|
138 | 134 | }
|
@@ -191,7 +187,10 @@ public static Command joystickSpeakerPoint(
|
191 | 187 | linearVelocity.getX() * drive.getMaxLinearSpeedMetersPerSec(),
|
192 | 188 | linearVelocity.getY() * drive.getMaxLinearSpeedMetersPerSec(),
|
193 | 189 | omega * drive.getMaxAngularSpeedRadPerSec(),
|
194 |
| - drive.getRotation())); |
| 190 | + getIsFlipped() |
| 191 | + ? drive.getRotation().plus(new Rotation2d(Math.PI)) |
| 192 | + : drive.getRotation() |
| 193 | + )); |
195 | 194 | },
|
196 | 195 | drive);
|
197 | 196 | }
|
@@ -240,7 +239,10 @@ public static Command joystickPasserPoint(
|
240 | 239 | linearVelocity.getX() * drive.getMaxLinearSpeedMetersPerSec(),
|
241 | 240 | linearVelocity.getY() * drive.getMaxLinearSpeedMetersPerSec(),
|
242 | 241 | omega * drive.getMaxAngularSpeedRadPerSec(),
|
243 |
| - drive.getRotation())); |
| 242 | + getIsFlipped() |
| 243 | + ? drive.getRotation().plus(new Rotation2d(Math.PI)) |
| 244 | + : drive.getRotation() |
| 245 | + )); |
244 | 246 | },
|
245 | 247 | drive);
|
246 | 248 | }
|
@@ -280,7 +282,10 @@ public static Command joystickAnglePoint(
|
280 | 282 | linearVelocity.getX() * drive.getMaxLinearSpeedMetersPerSec(),
|
281 | 283 | linearVelocity.getY() * drive.getMaxLinearSpeedMetersPerSec(),
|
282 | 284 | omega * drive.getMaxAngularSpeedRadPerSec(),
|
283 |
| - drive.getRotation())); |
| 285 | + getIsFlipped() |
| 286 | + ? drive.getRotation().plus(new Rotation2d(Math.PI)) |
| 287 | + : drive.getRotation() |
| 288 | + )); |
284 | 289 | },
|
285 | 290 | drive);
|
286 | 291 | }
|
@@ -334,7 +339,7 @@ public static boolean pointedAtSpeaker(Drive drive) {
|
334 | 339 | Rotation2d targetDirection = new Rotation2d(targetTransform.getX(), targetTransform.getY()).plus(new Rotation2d(getIsFlipped() ? Math.PI : 0));;
|
335 | 340 |
|
336 | 341 | // Convert to robot relative speeds and send command
|
337 |
| - if (Math.abs(drive.getRotation().getDegrees() - targetDirection.getDegrees()) < 1) { |
| 342 | + if (Math.abs(drive.getRotation().getDegrees() - targetDirection.getDegrees()) < DriveConstants.angleThreshold) { |
338 | 343 | return true;
|
339 | 344 | } else {
|
340 | 345 | return false;
|
|
0 commit comments