Skip to content

Commit

Permalink
More java sysid example cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bhall-ctre committed Apr 10, 2024
1 parent aa05581 commit 40b9d71
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions java/PhoenixSysId/src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package frc.robot;

public class Constants {
public final static String CANBUS = "canivore";
public final static int TALON_FX_ID = 18;
public final static String kCANbus = "canivore";
public final static int kTalonFxId = 18;
}
4 changes: 2 additions & 2 deletions java/PhoenixSysId/src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ private void configureBindings() {

/* Manually start logging with left bumper before running any tests,
* and stop logging with right bumper after we're done with ALL tests.
* This isn't necessary, but is convenient to reduce the size of the hoot file */
* This isn't necessary but is convenient to reduce the size of the hoot file */
m_joystick.leftBumper().onTrue(Commands.runOnce(SignalLogger::start));
m_joystick.rightBumper().onTrue(Commands.runOnce(SignalLogger::stop));

/**
/*
* Joystick Y = quasistatic forward
* Joystick A = quasistatic reverse
* Joystick B = dynamic forward
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@
import frc.robot.Constants;

public class FlywheelMechanism extends SubsystemBase {
private final TalonFX m_motorToTest = new TalonFX(Constants.TALON_FX_ID, Constants.CANBUS);
private final TalonFX m_motorToTest = new TalonFX(Constants.kTalonFxId, Constants.kCANbus);
private final DutyCycleOut m_joystickControl = new DutyCycleOut(0);
private final VoltageOut m_sysidControl = new VoltageOut(0);
private final VoltageOut m_sysIdControl = new VoltageOut(0);

private final SysIdRoutine m_SysIdRoutine =
private final SysIdRoutine m_sysIdRoutine =
new SysIdRoutine(
new SysIdRoutine.Config(
null, // Default ramp rate is acceptable
Volts.of(4), // Reduce dynamic voltage to 4 to prevent motor brownout
null, // Default timeout is acceptable
null, // Use default ramp rate (1 V/s)
Volts.of(4), // Reduce dynamic voltage to 4 to prevent brownout
null, // Use default timeout (10 s)
// Log state with Phoenix SignalLogger class
(state)->SignalLogger.writeString("state", state.toString())),
new SysIdRoutine.Mechanism(
(Measure<Voltage> volts)-> m_motorToTest.setControl(m_sysidControl.withOutput(volts.in(Volts))),
(Measure<Voltage> volts)-> m_motorToTest.setControl(m_sysIdControl.withOutput(volts.in(Volts))),
null,
this));

Expand All @@ -43,7 +43,7 @@ public FlywheelMechanism() {
// Set any necessary configs in the Feedback group here
m_motorToTest.getConfigurator().apply(cfg);

/* Speed up signals for better charaterization data */
/* Speed up signals for better characterization data */
BaseStatusSignal.setUpdateFrequencyForAll(250,
m_motorToTest.getPosition(),
m_motorToTest.getVelocity(),
Expand All @@ -60,9 +60,9 @@ public Command joystickDriveCommand(DoubleSupplier output) {
return run(()->m_motorToTest.setControl(m_joystickControl.withOutput(output.getAsDouble())));
}
public Command sysIdQuasistatic(SysIdRoutine.Direction direction) {
return m_SysIdRoutine.quasistatic(direction);
return m_sysIdRoutine.quasistatic(direction);
}
public Command sysIdDynamic(SysIdRoutine.Direction direction) {
return m_SysIdRoutine.dynamic(direction);
return m_sysIdRoutine.dynamic(direction);
}
}

0 comments on commit 40b9d71

Please sign in to comment.