[hal, wpilib] Rewrite CAN APIs (#7798)

This commit is contained in:
Thad House
2025-02-25 19:07:01 -08:00
committed by GitHub
parent b39744b562
commit baa20fa239
107 changed files with 1447 additions and 1379 deletions

View File

@@ -13,7 +13,7 @@ import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
* via CAN. The information will be displayed under variables through the SmartDashboard.
*/
public class Robot extends TimedRobot {
private final PowerDistribution m_pdp = new PowerDistribution();
private final PowerDistribution m_pdp = new PowerDistribution(0);
public Robot() {
// Put the PDP itself to the dashboard

View File

@@ -18,6 +18,7 @@ import edu.wpi.first.wpilibj2.command.SubsystemBase;
public class HatchSubsystem extends SubsystemBase {
private final DoubleSolenoid m_hatchSolenoid =
new DoubleSolenoid(
0,
PneumaticsModuleType.CTREPCM,
HatchConstants.kHatchSolenoidPorts[0],
HatchConstants.kHatchSolenoidPorts[1]);

View File

@@ -17,6 +17,7 @@ import edu.wpi.first.wpilibj2.command.SubsystemBase;
public class HatchSubsystem extends SubsystemBase {
private final DoubleSolenoid m_hatchSolenoid =
new DoubleSolenoid(
0,
PneumaticsModuleType.CTREPCM,
HatchConstants.kHatchSolenoidPorts[0],
HatchConstants.kHatchSolenoidPorts[1]);

View File

@@ -9,6 +9,7 @@ import static edu.wpi.first.wpilibj.examples.rapidreactcommandbot.Constants.Inta
import edu.wpi.first.epilogue.Logged;
import edu.wpi.first.wpilibj.DoubleSolenoid;
import edu.wpi.first.wpilibj.PneumaticsModuleType;
import edu.wpi.first.wpilibj.examples.rapidreactcommandbot.Constants.IntakeConstants;
import edu.wpi.first.wpilibj.motorcontrol.PWMSparkMax;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
@@ -20,6 +21,7 @@ public class Intake extends SubsystemBase {
// Double solenoid connected to two channels of a PCM with the default CAN ID
private final DoubleSolenoid m_pistons =
new DoubleSolenoid(
0,
PneumaticsModuleType.CTREPCM,
IntakeConstants.kSolenoidPorts[0],
IntakeConstants.kSolenoidPorts[1]);

View File

@@ -25,7 +25,7 @@ public class Pneumatics extends SubsystemBase {
new AnalogPotentiometer(/* the AnalogIn port*/ 2, kScale, kOffset);
// Compressor connected to a PCM with a default CAN ID (0)
private final Compressor m_compressor = new Compressor(PneumaticsModuleType.CTREPCM);
private final Compressor m_compressor = new Compressor(0, PneumaticsModuleType.CTREPCM);
/**
* Query the analog pressure sensor.

View File

@@ -28,15 +28,15 @@ public class Robot extends TimedRobot {
// Solenoid corresponds to a single solenoid.
// In this case, it's connected to channel 0 of a PH with the default CAN ID.
private final Solenoid m_solenoid = new Solenoid(PneumaticsModuleType.REVPH, 0);
private final Solenoid m_solenoid = new Solenoid(0, PneumaticsModuleType.REVPH, 0);
// DoubleSolenoid corresponds to a double solenoid.
// In this case, it's connected to channels 1 and 2 of a PH with the default CAN ID.
private final DoubleSolenoid m_doubleSolenoid =
new DoubleSolenoid(PneumaticsModuleType.REVPH, 1, 2);
new DoubleSolenoid(0, PneumaticsModuleType.REVPH, 1, 2);
// Compressor connected to a PH with a default CAN ID (1)
private final Compressor m_compressor = new Compressor(PneumaticsModuleType.REVPH);
private final Compressor m_compressor = new Compressor(0, PneumaticsModuleType.REVPH);
static final int kSolenoidButton = 1;
static final int kDoubleSolenoidForwardButton = 2;

View File

@@ -17,6 +17,7 @@ public class Intake implements AutoCloseable {
m_motor = new PWMSparkMax(IntakeConstants.kMotorPort);
m_piston =
new DoubleSolenoid(
0,
PneumaticsModuleType.CTREPCM,
IntakeConstants.kPistonFwdChannel,
IntakeConstants.kPistonRevChannel);