Clean up Java style (#5990)

Also make equivalent changes in C++ where applicable.

Co-authored-by: Sriman Achanta <68172138+srimanachanta@users.noreply.github.com>
This commit is contained in:
Tyler Veness
2023-12-03 16:21:32 -08:00
committed by GitHub
parent 66172ab288
commit 2bb1409b82
113 changed files with 426 additions and 617 deletions

View File

@@ -22,8 +22,8 @@ public class ReplaceMeTrapezoidProfileCommand extends TrapezoidProfileCommand {
// Use current trajectory state here
},
// Goal state
() -> new TrapezoidProfile.State(),
TrapezoidProfile.State::new,
// Current state
() -> new TrapezoidProfile.State());
TrapezoidProfile.State::new);
}
}

View File

@@ -32,7 +32,7 @@ import org.opencv.imgproc.Imgproc;
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();
}

View File

@@ -78,7 +78,7 @@ public class RobotContainer {
// 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)

View File

@@ -29,7 +29,7 @@ public class DriveDistanceProfiled extends TrapezoidProfileCommand {
// 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

View File

@@ -50,16 +50,12 @@ public class Pneumatics extends SubsystemBase {
*/
public Command disableCompressorCommand() {
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();
})
// 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)
.withName("Compressor Disabled");
}
}

View File

@@ -53,33 +53,17 @@ public class Robot extends TimedRobot {
tab.add("Compressor", m_compressor);
// Also publish some raw data
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();
});
tab.addDouble(
"Compressor Current",
() -> {
// Get compressor current draw.
return m_compressor.getCurrent();
});
tab.addBoolean(
"Compressor Active",
() -> {
// Get whether the compressor is active.
return m_compressor.isEnabled();
});
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();
});
// 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]", m_compressor::getPressure);
// Get compressor current draw.
tab.addDouble("Compressor Current", m_compressor::getCurrent);
// Get whether the compressor is active.
tab.addBoolean("Compressor Active", 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", m_compressor::getPressureSwitchValue);
}
@SuppressWarnings("PMD.UnconditionalIfStatement")

View File

@@ -44,7 +44,7 @@ public class Intake implements AutoCloseable {
}
@Override
public void close() throws Exception {
public void close() {
m_piston.close();
m_motor.close();
}