Skip to content

Commit

Permalink
[wpilib] Add/update documentation to PneumaticBase and subclasses (NF…
Browse files Browse the repository at this point in the history
…C) (wpilibsuite#4881)

Co-authored-by: Starlight220 <[email protected]>
  • Loading branch information
rzblue and Starlight220 authored Jan 2, 2023
1 parent 9872e67 commit 83f1860
Show file tree
Hide file tree
Showing 8 changed files with 722 additions and 47 deletions.
80 changes: 61 additions & 19 deletions wpilibc/src/main/native/include/frc/Compressor.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,31 +79,39 @@ class Compressor : public wpi::Sendable,
bool IsEnabled() const;

/**
* Check if the pressure switch is triggered.
* Returns the state of the pressure switch.
*
* @return true if pressure is low
* @return True if pressure switch indicates that the system is not full,
* otherwise false.
*/
bool GetPressureSwitchValue() const;

/**
* Query how much current the compressor is drawing.
* Get the current drawn by the compressor.
*
* @return The current through the compressor, in amps
* @return Current drawn by the compressor.
*/
units::ampere_t GetCurrent() const;

/**
* Query the analog input voltage (on channel 0) (if supported).
* If supported by the device, returns the analog input voltage (on channel
* 0).
*
* @return The analog input voltage, in volts
* This function is only supported by the REV PH. On CTRE PCM, this will
* return 0.
*
* @return The analog input voltage, in volts.
*/
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.
* If supported by the device, returns the pressure read by the analog
* pressure sensor (on channel 0).
*
* This function is only supported by the REV PH with the REV Analog Pressure
* Sensor. On CTRE PCM, this will return 0.
*
* @return The analog sensor pressure, in PSI
* @return The pressure read by the analog pressure sensor.
*/
units::pounds_per_square_inch_t GetPressure() const;

Expand All @@ -113,34 +121,68 @@ class Compressor : public wpi::Sendable,
void Disable();

/**
* Enable compressor closed loop control using digital input.
* Enables the compressor in digital mode using the digital pressure switch.
* The compressor will turn on when the pressure switch indicates that the
* system is not full, and will turn off when the pressure switch indicates
* that the system is full.
*/
void EnableDigital();

/**
* Enable compressor closed loop control using analog input. Note this is only
* for use with the REV Analog Pressure Sensor.
* If supported by the device, enables the compressor in analog mode. This
* mode uses an analog pressure sensor connected to analog channel 0 to cycle
* the compressor. The compressor will turn on when the pressure drops below
* {@code minPressure} and will turn off when the pressure reaches {@code
* maxPressure}. This mode is only supported by the REV PH with the REV Analog
* Pressure Sensor connected to analog channel 0.
*
* <p>On CTRE PCM, this will enable digital control.
* On CTRE PCM, this will enable digital control.
*
* @param minPressure The minimum pressure in PSI to enable compressor
* @param maxPressure The maximum pressure in PSI to disable compressor
* @param minPressure The minimum pressure. The compressor will turn on when
* the pressure drops below this value.
* @param maxPressure The maximum pressure. The compressor will turn off when
* the pressure reaches this value.
*/
void EnableAnalog(units::pounds_per_square_inch_t minPressure,
units::pounds_per_square_inch_t maxPressure);

/**
* Enable compressor closed loop control using hybrid input. Note this is only
* for use with the REV Analog Pressure Sensor.
* If supported by the device, enables the compressor in hybrid mode. This
* mode uses both a digital pressure switch and an analog pressure sensor
* connected to analog channel 0 to cycle the compressor. This mode is only
* supported by the REV PH with the REV Analog Pressure Sensor connected to
* analog channel 0.
*
* The compressor will turn on when \a both:
*
* - The digital pressure switch indicates the system is not full AND
* - The analog pressure sensor indicates that the pressure in the system
* is below the specified minimum pressure.
*
* The compressor will turn off when \a either:
*
* - The digital pressure switch is disconnected or indicates that the system
* is full OR
* - The pressure detected by the analog sensor is greater than the specified
* maximum pressure.
*
* On CTRE PCM, this will enable digital control.
*
* @param minPressure The minimum pressure in PSI to enable compressor
* @param maxPressure The maximum pressure in PSI to disable compressor
* @param minPressure The minimum pressure. The compressor will turn on
* when the pressure drops below this value and the pressure switch indicates
* that the system is not full.
* @param maxPressure The maximum pressure. The compressor will turn
* off when the pressure reaches this value or the pressure switch is
* disconnected or indicates that the system is full.
*/
void EnableHybrid(units::pounds_per_square_inch_t minPressure,
units::pounds_per_square_inch_t maxPressure);

/**
* Returns the active compressor configuration.
*
* @return The active compressor configuration.
*/
CompressorConfigType GetConfigType() const;

void InitSendable(wpi::SendableBuilder& builder) override;
Expand Down
99 changes: 99 additions & 0 deletions wpilibc/src/main/native/include/frc/PneumaticHub.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,72 @@
#include "PneumaticsBase.h"

namespace frc {
/** Module class for controlling a REV Robotics Pneumatic Hub. */
class PneumaticHub : public PneumaticsBase {
public:
/** Constructs a PneumaticHub with the default ID (1). */
PneumaticHub();

/**
* Constructs a PneumaticHub.
*
* @param module module number to construct
*/
explicit PneumaticHub(int module);

~PneumaticHub() override = default;

bool GetCompressor() const override;

/**
* Disables the compressor. The compressor will not turn on until
* EnableCompressorDigital(), EnableCompressorAnalog(), or
* EnableCompressorHybrid() are called.
*/
void DisableCompressor() override;

void EnableCompressorDigital() override;

/**
* Enables the compressor in analog mode. This mode uses an analog pressure
* sensor connected to analog channel 0 to cycle the compressor. The
* compressor will turn on when the pressure drops below {@code minPressure}
* and will turn off when the pressure reaches {@code maxPressure}.
*
* @param minPressure The minimum pressure. The compressor will turn on when
* the pressure drops below this value.
* @param maxPressure The maximum pressure. The compressor will turn off when
* the pressure reaches this value.
*/
void EnableCompressorAnalog(
units::pounds_per_square_inch_t minPressure,
units::pounds_per_square_inch_t maxPressure) override;

/**
* Enables the compressor in hybrid mode. This mode uses both a digital
* pressure switch and an analog pressure sensor connected to analog channel 0
* to cycle the compressor.
*
* The compressor will turn on when \a both:
*
* - The digital pressure switch indicates the system is not full AND
* - The analog pressure sensor indicates that the pressure in the system is
* below the specified minimum pressure.
*
* The compressor will turn off when \a either:
*
* - The digital pressure switch is disconnected or indicates that the system
* is full OR
* - The pressure detected by the analog sensor is greater than the specified
* maximum pressure.
*
* @param minPressure The minimum pressure. The compressor will turn on when
* the pressure drops below this value and the pressure switch indicates that
* the system is not full.
* @param maxPressure The maximum pressure. The compressor will turn off when
* the pressure reaches this value or the pressure switch is disconnected or
* indicates that the system is full.
*/
void EnableCompressorHybrid(
units::pounds_per_square_inch_t minPressure,
units::pounds_per_square_inch_t maxPressure) override;
Expand Down Expand Up @@ -76,6 +125,11 @@ class PneumaticHub : public PneumaticsBase {
uint32_t UniqueId;
};

/**
* Returns the hardware and firmware versions of this device.
*
* @return The hardware and firmware versions.
*/
Version GetVersion() const;

struct Faults {
Expand Down Expand Up @@ -103,6 +157,11 @@ class PneumaticHub : public PneumaticsBase {
uint32_t HardwareFault : 1;
};

/**
* Returns the faults currently active on this device.
*
* @return The faults.
*/
Faults GetFaults() const;

struct StickyFaults {
Expand All @@ -115,20 +174,60 @@ class PneumaticHub : public PneumaticsBase {
uint32_t HasReset : 1;
};

/**
* Returns the sticky faults currently active on this device.
*
* @return The sticky faults.
*/
StickyFaults GetStickyFaults() const;

/** Clears the sticky faults. */
void ClearStickyFaults();

/**
* Returns the current input voltage for this device.
*
* @return The input voltage.
*/
units::volt_t GetInputVoltage() const;

/**
* Returns the current voltage of the regulated 5v supply.
*
* @return The current voltage of the 5v supply.
*/
units::volt_t Get5VRegulatedVoltage() const;

/**
* Returns the total current drawn by all solenoids.
*
* @return Total current drawn by all solenoids.
*/
units::ampere_t GetSolenoidsTotalCurrent() const;

/**
* Returns the current voltage of the solenoid power supply.
*
* @return The current voltage of the solenoid power supply.
*/
units::volt_t GetSolenoidsVoltage() const;

/**
* Returns the raw voltage of the specified analog input channel.
*
* @param channel The analog input channel to read voltage from.
* @return The voltage of the specified analog input channel.
*/
units::volt_t GetAnalogVoltage(int channel) const override;

/**
* Returns the pressure read by an analog pressure sensor on the specified
* analog input channel.
*
* @param channel The analog input channel to read pressure from.
* @return The pressure read by an analog pressure sensor on the specified
* analog input channel.
*/
units::pounds_per_square_inch_t GetPressure(int channel) const override;

private:
Expand Down
Loading

0 comments on commit 83f1860

Please sign in to comment.