Skip to content

Commit 70f3828

Browse files
authored
Merge pull request #31 from IgniteRobotics/debug/defaultCommand
Debug/default command
2 parents 0ecc048 + e59e6b0 commit 70f3828

File tree

2 files changed

+32
-28
lines changed

2 files changed

+32
-28
lines changed

src/main/java/frc/robot/Robot.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ public void robotPeriodic() {
8888

8989
/** This function is called once each time the robot enters Disabled mode. */
9090
@Override
91-
public void disabledInit() {}
91+
public void disabledInit() {
92+
}
9293

9394
@Override
9495
public void disabledPeriodic() {}
@@ -117,6 +118,9 @@ public void teleopInit() {
117118
if (m_autonomousCommand != null) {
118119
m_autonomousCommand.cancel();
119120
}
121+
122+
m_robotContainer.configureSubsystemDefaultCommands();
123+
m_robotContainer.configureTeleopBindings();
120124
}
121125

122126
/** This function is called periodically during operator control. */
@@ -127,6 +131,10 @@ public void teleopPeriodic() {}
127131
public void testInit() {
128132
// Cancels all running commands at the start of test mode.
129133
CommandScheduler.getInstance().cancelAll();
134+
135+
SignalLogger.stop();
136+
m_robotContainer.removeSubsystemDefaultCommands();
137+
m_robotContainer.configureTestBindings();
130138
}
131139

132140
/** This function is called periodically during test mode. */

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

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,13 @@ public RobotContainer() {
5858
autoChooser = AutoBuilder.buildAutoChooser("Auto Chooser");
5959
SmartDashboard.putData("Auto Mode", autoChooser);
6060

61-
configureSubsystemDefaultCommands();
62-
configureBindings();
61+
// Idle while the robot is disabled. This ensures the configured
62+
// neutral mode is applied to the drive motors while disabled.
63+
RobotModeTriggers.disabled()
64+
.whileTrue(drivetrain.applyRequest(() -> new SwerveRequest.Idle()).ignoringDisable(true));
6365
}
6466

65-
private void configureSubsystemDefaultCommands() {
67+
public void configureSubsystemDefaultCommands() {
6668

6769
drivetrain.setDefaultCommand(
6870
// Drivetrain will execute this command periodically
@@ -90,34 +92,36 @@ private void configureSubsystemDefaultCommands() {
9092
.withRotationalDeadband(DriveConstants.MAX_ANGULAR_SPEED * 0.1)));
9193
}
9294

93-
private void configureBindings() {
95+
public void removeSubsystemDefaultCommands(){
96+
drivetrain.removeDefaultCommand();
97+
}
98+
99+
public void configureTestBindings() {
94100
// Idle while the robot is disabled. This ensures the configured
95101
// neutral mode is applied to the drive motors while disabled.
102+
96103
final var idle = new SwerveRequest.Idle();
97104
RobotModeTriggers.disabled()
98105
.whileTrue(drivetrain.applyRequest(() -> idle).ignoringDisable(true));
106+
107+
driverJoystick.rightBumper().onTrue(Commands.runOnce(SignalLogger::start));
108+
driverJoystick.leftBumper().onTrue(Commands.runOnce(SignalLogger::stop));
99109

100-
// // driverJoystick.a().whileTrue(drivetrain.applyRequest(() -> brake));
101-
// driverJoystick
102-
// .b()
103-
// .whileTrue(
104-
// drivetrain.applyRequest(
105-
// () ->
106-
// point.withModuleDirection(
107-
// new Rotation2d(-driverJoystick.getLeftY(),
108-
// -driverJoystick.getLeftX()))));
110+
operatorJoystick.y().whileTrue(shooter.sysIdQuasistatic(SysIdRoutine.Direction.kForward));
111+
operatorJoystick.a().whileTrue(shooter.sysIdQuasistatic(SysIdRoutine.Direction.kReverse));
112+
operatorJoystick.b().whileTrue(shooter.sysIdDynamic(SysIdRoutine.Direction.kForward));
113+
operatorJoystick.x().whileTrue(shooter.sysIdDynamic(SysIdRoutine.Direction.kReverse));
109114

115+
// Reset the field-centric heading on left bumper press.
116+
driverJoystick.start().onTrue(drivetrain.runOnce(drivetrain::seedFieldCentric));
117+
}
118+
119+
public void configureTeleopBindings() {
110120
// Run SysId routines when holding back/start and X/Y.
111121
// Note that each routine should be run exactly once in a single log.
112122

113123
// joystick.x().onTrue(drivetrain.sysIdSteer());
114124
// joystick.y().onTrue(drivetrain.sysIdTranslation());
115-
// driverJoystick.x().onTrue(new WheelSlipTest(drivetrain));
116-
/*
117-
driverJoystick
118-
.y()
119-
.whileTrue(new DriveBySpeed(drivetrain, DrivePreferences.onemeter_speed)); // Testing only
120-
*/
121125

122126
driverJoystick
123127
.rightTrigger()
@@ -139,14 +143,6 @@ private void configureBindings() {
139143
.whileTrue(indexer.setIndexerNoPID())
140144
.onFalse(indexer.stopIndexerNoPID());
141145

142-
driverJoystick.rightBumper().onTrue(Commands.runOnce(SignalLogger::start));
143-
driverJoystick.leftBumper().onTrue(Commands.runOnce(SignalLogger::stop));
144-
145-
operatorJoystick.y().whileTrue(shooter.sysIdQuasistatic(SysIdRoutine.Direction.kForward));
146-
operatorJoystick.a().whileTrue(shooter.sysIdQuasistatic(SysIdRoutine.Direction.kReverse));
147-
operatorJoystick.b().whileTrue(shooter.sysIdDynamic(SysIdRoutine.Direction.kForward));
148-
operatorJoystick.x().whileTrue(shooter.sysIdDynamic(SysIdRoutine.Direction.kReverse));
149-
150146
// Reset the field-centric heading on left bumper press.
151147
driverJoystick.start().onTrue(drivetrain.runOnce(drivetrain::seedFieldCentric));
152148

0 commit comments

Comments
 (0)