[wpilib] Use PSI for compressor config and sensor reading (#3847)

This adds the REV Analog Pressure Sensor PSI to volt (and vice versa) conversion to allow setting the compressor config in PSI and getting the sensor reading in PSI. Also adds input validation for pressure values at the higher level.

Co-authored-by: Tyler Veness <calcmogul@gmail.com>
This commit is contained in:
Jan-Felix Abellera
2021-12-31 22:04:56 -07:00
committed by GitHub
parent f401ea9aae
commit 7c09f44898
12 changed files with 208 additions and 52 deletions

View File

@@ -104,6 +104,14 @@ class Compressor : public wpi::Sendable,
*/
units::volt_t GetAnalogVoltage() const;
/**
* Query the analog sensor pressure (on channel 0) (if supported). Note this
* is only for use with the REV Analog Pressure Sensor.
*
* @return The analog sensor pressure, in PSI
*/
units::pounds_per_square_inch_t GetPressure() const;
/**
* Disable the compressor.
*/
@@ -115,26 +123,28 @@ class Compressor : public wpi::Sendable,
void EnableDigital();
/**
* Enable compressor closed loop control using analog input.
* Enable compressor closed loop control using analog input. Note this is only
* for use with the REV Analog Pressure Sensor.
*
* <p>On CTRE PCM, this will enable digital control.
*
* @param minAnalogVoltage The minimum voltage to enable compressor
* @param maxAnalogVoltage The maximum voltage to disable compressor
* @param minPressure The minimum pressure in PSI to enable compressor
* @param maxPressure The maximum pressure in PSI to disable compressor
*/
void EnableAnalog(units::volt_t minAnalogVoltage,
units::volt_t maxAnalogVoltage);
void EnableAnalog(units::pounds_per_square_inch_t minPressure,
units::pounds_per_square_inch_t maxPressure);
/**
* Enable compressor closed loop control using hybrid input.
* Enable compressor closed loop control using hybrid input. Note this is only
* for use with the REV Analog Pressure Sensor.
*
* On CTRE PCM, this will enable digital control.
*
* @param minAnalogVoltage The minimum voltage to enable compressor
* @param maxAnalogVoltage The maximum voltage to disable compressor
* @param minPressure The minimum pressure in PSI to enable compressor
* @param maxPressure The maximum pressure in PSI to disable compressor
*/
void EnableHybrid(units::volt_t minAnalogVoltage,
units::volt_t maxAnalogVoltage);
void EnableHybrid(units::pounds_per_square_inch_t minPressure,
units::pounds_per_square_inch_t maxPressure);
CompressorConfigType GetConfigType() const;