Pneumatic Control Reference - hammerheads5000/Team-Documentation GitHub Wiki
Double Solenoid
We use double solenoids, meaning that there is a forward channel and a reverse channel. WPILib uses the DoubleSolenoid class to control these.
To declare a solenoid (in RobotContainer.java):
private final DoubleSolenoid doubleSolenoid = new DoubleSolenoid(PneumaticsModuleType.CTREPCM, 1, 2);
Where 1 and 2 are the IDs of the forward and reverse channels respectively.
To use a solenoid (in a subsystem usually):
doubleSolenoid.set(kForward); // to extend
doubleSolenoid.set(kReverse); // to contract
doubleSolenoid.toggle(); // to toggle
Keep in mind that if import static edu.wpi.first.wpilibj.DoubleSolenoid.Value.*; is not imported, kForward and kReverse will not be defined.
Compressor
Not necessary for controlling solenoids and pistons, but can be controlled to turn compressor on and off or get information such as current draw.
To define compressor (in RobotContainer.java):
private final Compressor compressor = new Compressor(PneumaticsModuleType.CTREPCM);
To get information:
compressor.getCurrent(); // returns current draw
compressor.isEnabled(); // returns whether the compressor is active
compressor.getPressureSwitchValve(); // returns value of switch that is open when the pressure is over ~120 PSI
While you can control some compressor functionality, generally just leave it be.