Skip to content

Commit

Permalink
example review
Browse files Browse the repository at this point in the history
  • Loading branch information
srimanachanta committed Oct 13, 2023
1 parent 04775d6 commit ec1ad50
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
public class Robot extends TimedRobot {
@Override
public void robotInit() {
var visionThread = new Thread(() -> apriltagVisionThreadProc());
var visionThread = new Thread(this::apriltagVisionThreadProc);
visionThread.setDaemon(true);
visionThread.start();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private void configureButtonBindings() {
// End at desired position in meters; implicitly starts at 0
() -> new TrapezoidProfile.State(3, 0),
// Current position
() -> new TrapezoidProfile.State(),
TrapezoidProfile.State::new,
// Require the drive
m_robotDrive)
.beforeStarting(m_robotDrive::resetEncoders)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public DriveDistanceProfiled(double meters, DriveSubsystem drive) {
// End at desired position in meters; implicitly starts at 0
() -> new TrapezoidProfile.State(meters, 0),
// Current position
() -> new TrapezoidProfile.State(),
TrapezoidProfile.State::new,
// Require the drive
drive);
// Reset drive encoders since we're starting at 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,13 @@ private double getPressure() {
* @return command
*/
public Command disableCompressorCommand() {
// Disable closed-loop mode on the compressor.
return startEnd(
() -> {
// Disable closed-loop mode on the compressor.
m_compressor.disable();
},
() -> {
// Enable closed-loop mode based on the digital pressure switch connected to the
// PCM/PH.
// The switch is open when the pressure is over ~120 PSI.
m_compressor.enableDigital();
})
m_compressor::disable,
// Enable closed-loop mode based on the digital pressure switch connected to the
// PCM/PH.
// The switch is open when the pressure is over ~120 PSI.
m_compressor::enableDigital)
.withName("Compressor Disabled");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,33 +53,25 @@ public void robotInit() {
tab.add("Compressor", m_compressor);

// Also publish some raw data
// Get the pressure (in PSI) from the analog sensor connected to the PH.
// This function is supported only on the PH!
// On a PCM, this function will return 0.
tab.addDouble(
"PH Pressure [PSI]",
() -> {
// Get the pressure (in PSI) from the analog sensor connected to the PH.
// This function is supported only on the PH!
// On a PCM, this function will return 0.
return m_compressor.getPressure();
});
m_compressor::getPressure);
// Get compressor current draw.
tab.addDouble(
"Compressor Current",
() -> {
// Get compressor current draw.
return m_compressor.getCurrent();
});
m_compressor::getCurrent);
// Get whether the compressor is active.
tab.addBoolean(
"Compressor Active",
() -> {
// Get whether the compressor is active.
return m_compressor.isEnabled();
});
m_compressor::isEnabled);
// Get the digital pressure switch connected to the PCM/PH.
// The switch is open when the pressure is over ~120 PSI.
tab.addBoolean(
"Pressure Switch",
() -> {
// Get the digital pressure switch connected to the PCM/PH.
// The switch is open when the pressure is over ~120 PSI.
return m_compressor.getPressureSwitchValue();
});
m_compressor::getPressureSwitchValue);
}

@SuppressWarnings("PMD.UnconditionalIfStatement")
Expand Down

0 comments on commit ec1ad50

Please sign in to comment.