mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[hal, wpilib] Rewrite CAN APIs (#7798)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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]);
|
||||
|
||||
@@ -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]);
|
||||
|
||||
@@ -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]);
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user