mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-27 02:01:42 +00:00
[hal, wpilib] Incorporate pneumatic control type into wpilibc/j (#3728)
This commit is contained in:
@@ -7,9 +7,11 @@
|
||||
#include <memory>
|
||||
|
||||
#include <hal/Types.h>
|
||||
#include <wpi/deprecated.h>
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
#include "frc/CompressorConfigType.h"
|
||||
#include "frc/PneumaticsBase.h"
|
||||
#include "frc/PneumaticsModuleType.h"
|
||||
#include "frc/SensorUtil.h"
|
||||
@@ -59,13 +61,19 @@ class Compressor : public wpi::Sendable,
|
||||
/**
|
||||
* Starts closed-loop control. Note that closed loop control is enabled by
|
||||
* default.
|
||||
*
|
||||
* @deprecated Use EnableDigital() instead.
|
||||
*/
|
||||
WPI_DEPRECATED("Use EnableDigital() instead")
|
||||
void Start();
|
||||
|
||||
/**
|
||||
* Stops closed-loop control. Note that closed loop control is enabled by
|
||||
* default.
|
||||
*
|
||||
* @deprecated Use Disable() instead.
|
||||
*/
|
||||
WPI_DEPRECATED("Use Disable() instead")
|
||||
void Stop();
|
||||
|
||||
/**
|
||||
@@ -87,25 +95,39 @@ class Compressor : public wpi::Sendable,
|
||||
*
|
||||
* @return The current through the compressor, in amps
|
||||
*/
|
||||
double GetCompressorCurrent() const;
|
||||
double GetCurrent() const;
|
||||
|
||||
/**
|
||||
* Enables or disables automatically turning the compressor on when the
|
||||
* pressure is low.
|
||||
*
|
||||
* @param on Set to true to enable closed loop control of the compressor.
|
||||
* False to disable.
|
||||
* Disable the compressor.
|
||||
*/
|
||||
void SetClosedLoopControl(bool on);
|
||||
void Disable();
|
||||
|
||||
/**
|
||||
* Returns true if the compressor will automatically turn on when the
|
||||
* pressure is low.
|
||||
*
|
||||
* @return True if closed loop control of the compressor is enabled. False if
|
||||
* disabled.
|
||||
* Enable compressor closed loop control using digital input.
|
||||
*/
|
||||
bool GetClosedLoopControl() const;
|
||||
void EnableDigital();
|
||||
|
||||
/**
|
||||
* Enable compressor closed loop control using analog input.
|
||||
*
|
||||
* <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
|
||||
*/
|
||||
void EnableAnalog(double minAnalogVoltage, double maxAnalogVoltage);
|
||||
|
||||
/**
|
||||
* Enable compressor closed loop control using hybrid input.
|
||||
*
|
||||
* On CTRE PCM, this will enable digital control.
|
||||
*
|
||||
* @param minAnalogVoltage The minimum voltage to enable compressor
|
||||
* @param maxAnalogVoltage The maximum voltage to disable compressor
|
||||
*/
|
||||
void EnableHybrid(double minAnalogVoltage, double maxAnalogVoltage);
|
||||
|
||||
CompressorConfigType GetConfigType() const;
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
|
||||
|
||||
15
wpilibc/src/main/native/include/frc/CompressorConfigType.h
Normal file
15
wpilibc/src/main/native/include/frc/CompressorConfigType.h
Normal file
@@ -0,0 +1,15 @@
|
||||
// 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
|
||||
|
||||
namespace frc {
|
||||
enum class CompressorConfigType {
|
||||
Disabled = 0,
|
||||
Digital = 1,
|
||||
Analog = 2,
|
||||
Hybrid = 3
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
@@ -22,9 +22,17 @@ class PneumaticHub : public PneumaticsBase {
|
||||
|
||||
bool GetCompressor() const override;
|
||||
|
||||
void SetClosedLoopControl(bool enabled) override;
|
||||
void DisableCompressor() override;
|
||||
|
||||
bool GetClosedLoopControl() const override;
|
||||
void EnableCompressorDigital() override;
|
||||
|
||||
void EnableCompressorAnalog(double minAnalogVoltage,
|
||||
double maxAnalogVoltage) override;
|
||||
|
||||
void EnableCompressorHybrid(double minAnalogVoltage,
|
||||
double maxAnalogVoltage) override;
|
||||
|
||||
CompressorConfigType GetCompressorConfigType() const override;
|
||||
|
||||
bool GetPressureSwitch() const override;
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <units/time.h>
|
||||
|
||||
#include "frc/CompressorConfigType.h"
|
||||
#include "frc/PneumaticsModuleType.h"
|
||||
|
||||
namespace frc {
|
||||
@@ -24,9 +25,17 @@ class PneumaticsBase {
|
||||
|
||||
virtual double GetCompressorCurrent() const = 0;
|
||||
|
||||
virtual void SetClosedLoopControl(bool on) = 0;
|
||||
virtual void DisableCompressor() = 0;
|
||||
|
||||
virtual bool GetClosedLoopControl() const = 0;
|
||||
virtual void EnableCompressorDigital() = 0;
|
||||
|
||||
virtual void EnableCompressorAnalog(double minAnalogVoltage,
|
||||
double maxAnalogVoltage) = 0;
|
||||
|
||||
virtual void EnableCompressorHybrid(double minAnalogVoltage,
|
||||
double maxAnalogVoltage) = 0;
|
||||
|
||||
virtual CompressorConfigType GetCompressorConfigType() const = 0;
|
||||
|
||||
virtual void SetSolenoids(int mask, int values) = 0;
|
||||
|
||||
|
||||
@@ -22,9 +22,17 @@ class PneumaticsControlModule : public PneumaticsBase {
|
||||
|
||||
bool GetCompressor() const override;
|
||||
|
||||
void SetClosedLoopControl(bool enabled) override;
|
||||
void DisableCompressor() override;
|
||||
|
||||
bool GetClosedLoopControl() const override;
|
||||
void EnableCompressorDigital() override;
|
||||
|
||||
void EnableCompressorAnalog(double minAnalogVoltage,
|
||||
double maxAnalogVoltage) override;
|
||||
|
||||
void EnableCompressorHybrid(double minAnalogVoltage,
|
||||
double maxAnalogVoltage) override;
|
||||
|
||||
CompressorConfigType GetCompressorConfigType() const override;
|
||||
|
||||
bool GetPressureSwitch() const override;
|
||||
|
||||
|
||||
@@ -119,22 +119,22 @@ class REVPHSim {
|
||||
* @return the CallbackStore object associated with this callback
|
||||
*/
|
||||
[[nodiscard]] std::unique_ptr<CallbackStore>
|
||||
RegisterClosedLoopEnabledCallback(NotifyCallback callback,
|
||||
bool initialNotify);
|
||||
RegisterCompressorConfigTypeCallback(NotifyCallback callback,
|
||||
bool initialNotify);
|
||||
|
||||
/**
|
||||
* Check whether the closed loop compressor control is active.
|
||||
*
|
||||
* @return true if active
|
||||
* @return compressor config type
|
||||
*/
|
||||
bool GetClosedLoopEnabled() const;
|
||||
int GetCompressorConfigType() const;
|
||||
|
||||
/**
|
||||
* Turn on/off the closed loop control of the compressor.
|
||||
*
|
||||
* @param closedLoopEnabled whether the control loop is active
|
||||
* @param compressorConfigType compressor config type
|
||||
*/
|
||||
void SetClosedLoopEnabled(bool closedLoopEnabled);
|
||||
void SetCompressorConfigType(int compressorConfigType);
|
||||
|
||||
/**
|
||||
* Register a callback to be run whenever the pressure switch value changes.
|
||||
|
||||
Reference in New Issue
Block a user