2023-07-04 07:23:18 +03:00
|
|
|
// Copyright (c) FIRST and other WPILib contributors.
|
|
|
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
|
|
|
// the WPILib BSD license file in the root directory of this project.
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <frc/AnalogPotentiometer.h>
|
|
|
|
|
#include <frc/Compressor.h>
|
|
|
|
|
#include <frc/PneumaticsControlModule.h>
|
|
|
|
|
#include <frc2/command/CommandPtr.h>
|
2023-09-14 23:56:48 -04:00
|
|
|
#include <frc2/command/SubsystemBase.h>
|
2023-07-04 07:23:18 +03:00
|
|
|
#include <units/pressure.h>
|
|
|
|
|
|
|
|
|
|
#include "Constants.h"
|
|
|
|
|
|
2023-09-14 23:56:48 -04:00
|
|
|
class Pneumatics : frc2::SubsystemBase {
|
2023-07-04 07:23:18 +03:00
|
|
|
public:
|
|
|
|
|
Pneumatics();
|
|
|
|
|
/** Returns a command that disables the compressor indefinitely. */
|
2023-07-04 08:14:06 -06:00
|
|
|
frc2::CommandPtr DisableCompressorCommand();
|
2023-07-04 07:23:18 +03:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Query the analog pressure sensor.
|
|
|
|
|
*
|
|
|
|
|
* @return the measured pressure, in PSI
|
|
|
|
|
*/
|
|
|
|
|
units::pounds_per_square_inch_t GetPressure();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// External analog pressure sensor
|
|
|
|
|
// product-specific voltage->pressure conversion, see product manual
|
|
|
|
|
// in this case, 250(V/5)-25
|
|
|
|
|
// the scale parameter in the AnalogPotentiometer constructor is scaled from
|
|
|
|
|
// 1 instead of 5, so if r is the raw AnalogPotentiometer output, the
|
|
|
|
|
// pressure is 250r-25
|
|
|
|
|
static constexpr double kScale = 250;
|
|
|
|
|
static constexpr double kOffset = -25;
|
|
|
|
|
frc::AnalogPotentiometer m_pressureTransducer{/* the AnalogIn port*/ 2,
|
|
|
|
|
kScale, kOffset};
|
|
|
|
|
|
|
|
|
|
// Compressor connected to a PH with a default CAN ID
|
|
|
|
|
frc::Compressor m_compressor{frc::PneumaticsModuleType::CTREPCM};
|
|
|
|
|
};
|