Skip to content
This repository was archived by the owner on Aug 23, 2025. It is now read-only.

Commit 8ab578c

Browse files
turn to angle based on right joystick
add deadbands ltr Co-Authored-By: silverx257 <[email protected]>
1 parent c05f3a9 commit 8ab578c

File tree

1 file changed

+54
-34
lines changed

1 file changed

+54
-34
lines changed

src/main/java/frc/robot/RobotContainer.java

Lines changed: 54 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import frc.robot.Constants.VisionConstants;
2828
import frc.robot.commands.SwerveJoystickCommand;
2929
import frc.robot.commands.autos.Mid5PieceMiddle;
30-
import frc.robot.commands.autos.Preload;
30+
// import frc.robot.commands.autos.Preload;
3131
import frc.robot.commands.autos.PreloadTaxi;
3232
import frc.robot.commands.autos.Reliable4Piece;
3333
import frc.robot.commands.autos.ThreePieceMid;
@@ -159,7 +159,8 @@ public void initDefaultCommands_teleop() {
159159
// return turnPower;
160160
// }
161161
// SmartDashboard.putBoolean("Turn to angle 2", false);
162-
return commandDriverController.getRightX(); // Rotation
162+
// return commandDriverController.getRightX(); // Rotation
163+
return 0.0;
163164
},
164165

165166
// driverController::getSquareButton, // Field oriented
@@ -170,11 +171,13 @@ public void initDefaultCommands_teleop() {
170171
() -> driverController.getR2Button(), // Precision mode (disabled)
171172
() -> {
172173
return (
173-
driverController.getR1Button()
174-
|| driverController.getL1Button()
175-
|| driverController.getL2Button()
176-
|| driverController.getCircleButton()
177-
|| driverController.getTriangleButton()
174+
driverController.getRightX() > 0.0
175+
|| driverController.getRightY() > 0.0
176+
// driverController.getR1Button()
177+
// || driverController.getL1Button()
178+
// || driverController.getL2Button()
179+
// || driverController.getCircleButton()
180+
// || driverController.getTriangleButton()
178181
// || (
179182
// driverController.getTouchpad() && superSystem.getIsPassing()
180183
// )
@@ -183,40 +186,57 @@ public void initDefaultCommands_teleop() {
183186
},
184187
// () -> false, // Turn to angle (disabled)
185188
() -> { // Turn To angle Direction
186-
if (
187-
// (driverController.getTouchpad() && superSystem.getIsPassing())
188-
// ||
189-
driverController.getTriangleButton())
190-
{
191-
if (!IsRedSide()) {
192-
return 315.0;
193-
} else {
194-
return 45.0;
189+
if (Math.abs(driverController.getRightY()) > Math.abs(driverController.getRightX())) {
190+
if (driverController.getRightY() < 0) {
191+
return 0.0;
195192
}
193+
else if (driverController.getRightY() > 0) {
194+
return 180.0;
195+
}
196196
}
197-
if (driverController.getL2Button()) {
198-
return swerveDrive.getTurnToSpecificTagAngle(IsRedSide() ? 4 : 7); // TODO, update?
199-
// 4 if red side, 7 if blue
200-
}
201-
if (driverController.getCircleButton()) { //turn to amp
202-
if (!IsRedSide()){
197+
else if ((Math.abs(driverController.getRightY()) < Math.abs(driverController.getRightX()))) {
198+
if (driverController.getRightX() < 0) {
199+
return 90.0;
200+
}
201+
else if (driverController.getRightX() > 0) {
203202
return 270.0;
204203
}
205-
return 90.0;
206-
}
207-
else
208-
if (driverController.getL1Button()) { //turn to speaker
209-
return 0.0;
210-
}
211-
else if (driverController.getR1Button()) {
212-
return 180.0;
213204
}
205+
return 0.0;
206+
});
207+
208+
209+
// if (
210+
// // (driverController.getTouchpad() && superSystem.getIsPassing())
211+
// // ||
212+
// driverController.getTriangleButton())
213+
// {
214+
// if (!IsRedSide()) {
215+
// return 315.0;
216+
// } else {
217+
// return 45.0;
218+
// }
219+
// }
220+
// if (driverController.getL2Button()) {
221+
// return swerveDrive.getTurnToSpecificTagAngle(IsRedSide() ? 4 : 7); // TODO, update?
222+
// // 4 if red side, 7 if blue
223+
// }
224+
// if (driverController.getCircleButton()) { //turn to amp
225+
// if (!IsRedSide()){
226+
// return 270.0;
227+
// }
228+
// return 90.0;
229+
// }
230+
// else
231+
// if (driverController.getL1Button()) { //turn to speaker
232+
// return 0.0;
233+
// }
234+
// else if (driverController.getR1Button()) {
235+
// return 180.0;
236+
// }
214237
// if (driverController.getPSButton()) { // Turn to shuffleboard angle
215238
// return SmartDashboard.getNumber("Test Desired Angle", 0);
216239
// }
217-
return 0.0;
218-
}
219-
);
220240

221241
swerveDrive.setDefaultCommand(swerveJoystickCommand);
222242

@@ -604,7 +624,7 @@ private void initAutoChoosers() {
604624
if (paths.contains("TaxiOnly")) {
605625
autoChooser.addOption("Taxi Only", AutoBuilder.buildAuto("TaxiOnly"));
606626
autoChooser.addOption("Preload Taxi Source", new PreloadTaxi(swerveDrive, List.of(aSY), superSystem));
607-
autoChooser.addOption("Preload", new Preload(swerveDrive, List.of(a02), superSystem));
627+
// autoChooser.addOption("Preload", new Preload(swerveDrive, List.of(a02), superSystem));
608628
}
609629

610630

0 commit comments

Comments
 (0)