mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -44,7 +44,7 @@ public class Intake implements AutoCloseable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws Exception {
|
||||
public void close() {
|
||||
m_piston.close();
|
||||
m_motor.close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user