mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-30 02:31:44 +00:00
Made SensorBase a utility class and renamed it to SensorUtil (#813)
This commit is contained in:
committed by
Peter Johnson
parent
ba93f79d8b
commit
ecfe95383c
@@ -12,6 +12,7 @@
|
||||
#include <HAL/HAL.h>
|
||||
#include <HAL/Ports.h>
|
||||
|
||||
#include "SensorUtil.h"
|
||||
#include "SmartDashboard/SendableBuilder.h"
|
||||
#include "Timer.h"
|
||||
#include "WPIErrors.h"
|
||||
@@ -25,7 +26,7 @@ using namespace frc;
|
||||
* on-board 4-7 are on the MXP port.
|
||||
*/
|
||||
AnalogInput::AnalogInput(int channel) {
|
||||
if (!SensorBase::CheckAnalogInputChannel(channel)) {
|
||||
if (!SensorUtil::CheckAnalogInputChannel(channel)) {
|
||||
wpi_setWPIErrorWithContext(ChannelIndexOutOfRange,
|
||||
"Analog Input " + wpi::Twine(channel));
|
||||
return;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <HAL/HAL.h>
|
||||
#include <HAL/Ports.h>
|
||||
|
||||
#include "SensorBase.h"
|
||||
#include "SensorUtil.h"
|
||||
#include "SmartDashboard/SendableBuilder.h"
|
||||
#include "WPIErrors.h"
|
||||
|
||||
@@ -26,7 +26,7 @@ using namespace frc;
|
||||
* @param channel The channel number on the roboRIO to represent.
|
||||
*/
|
||||
AnalogOutput::AnalogOutput(int channel) {
|
||||
if (!SensorBase::CheckAnalogOutputChannel(channel)) {
|
||||
if (!SensorUtil::CheckAnalogOutputChannel(channel)) {
|
||||
wpi_setWPIErrorWithContext(ChannelIndexOutOfRange,
|
||||
"analog output " + wpi::Twine(channel));
|
||||
m_channel = std::numeric_limits<int>::max();
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
#include "Counter.h"
|
||||
#include "Encoder.h"
|
||||
#include "SensorUtil.h"
|
||||
#include "Utility.h"
|
||||
#include "WPIErrors.h"
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <HAL/HAL.h>
|
||||
#include <HAL/Ports.h>
|
||||
|
||||
#include "SensorUtil.h"
|
||||
#include "SmartDashboard/SendableBuilder.h"
|
||||
#include "WPIErrors.h"
|
||||
|
||||
@@ -26,7 +27,7 @@ using namespace frc;
|
||||
* @param channel The DIO channel 0-9 are on-board, 10-25 are on the MXP port
|
||||
*/
|
||||
DigitalInput::DigitalInput(int channel) {
|
||||
if (!CheckDigitalChannel(channel)) {
|
||||
if (!SensorUtil::CheckDigitalChannel(channel)) {
|
||||
wpi_setWPIErrorWithContext(ChannelIndexOutOfRange,
|
||||
"Digital Channel " + wpi::Twine(channel));
|
||||
m_channel = std::numeric_limits<int>::max();
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <HAL/HAL.h>
|
||||
#include <HAL/Ports.h>
|
||||
|
||||
#include "SensorBase.h"
|
||||
#include "SensorUtil.h"
|
||||
#include "SmartDashboard/SendableBuilder.h"
|
||||
#include "WPIErrors.h"
|
||||
|
||||
@@ -29,7 +29,7 @@ using namespace frc;
|
||||
*/
|
||||
DigitalOutput::DigitalOutput(int channel) {
|
||||
m_pwmGenerator = HAL_kInvalidHandle;
|
||||
if (!SensorBase::CheckDigitalChannel(channel)) {
|
||||
if (!SensorUtil::CheckDigitalChannel(channel)) {
|
||||
wpi_setWPIErrorWithContext(ChannelIndexOutOfRange,
|
||||
"Digital Channel " + wpi::Twine(channel));
|
||||
m_channel = std::numeric_limits<int>::max();
|
||||
@@ -187,7 +187,7 @@ void DigitalOutput::DisablePWM() {
|
||||
int32_t status = 0;
|
||||
|
||||
// Disable the output by routing to a dead bit.
|
||||
HAL_SetDigitalPWMOutputChannel(m_pwmGenerator, SensorBase::kDigitalChannels,
|
||||
HAL_SetDigitalPWMOutputChannel(m_pwmGenerator, SensorUtil::kDigitalChannels,
|
||||
&status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <HAL/Ports.h>
|
||||
#include <HAL/Solenoid.h>
|
||||
|
||||
#include "SensorBase.h"
|
||||
#include "SensorUtil.h"
|
||||
#include "SmartDashboard/SendableBuilder.h"
|
||||
#include "WPIErrors.h"
|
||||
|
||||
@@ -26,7 +26,7 @@ using namespace frc;
|
||||
* @param reverseChannel The reverse channel number on the PCM (0..7).
|
||||
*/
|
||||
DoubleSolenoid::DoubleSolenoid(int forwardChannel, int reverseChannel)
|
||||
: DoubleSolenoid(SensorBase::GetDefaultSolenoidModule(), forwardChannel,
|
||||
: DoubleSolenoid(SensorUtil::GetDefaultSolenoidModule(), forwardChannel,
|
||||
reverseChannel) {}
|
||||
|
||||
/**
|
||||
@@ -41,18 +41,18 @@ DoubleSolenoid::DoubleSolenoid(int moduleNumber, int forwardChannel,
|
||||
: SolenoidBase(moduleNumber),
|
||||
m_forwardChannel(forwardChannel),
|
||||
m_reverseChannel(reverseChannel) {
|
||||
if (!SensorBase::CheckSolenoidModule(m_moduleNumber)) {
|
||||
if (!SensorUtil::CheckSolenoidModule(m_moduleNumber)) {
|
||||
wpi_setWPIErrorWithContext(ModuleIndexOutOfRange,
|
||||
"Solenoid Module " + wpi::Twine(m_moduleNumber));
|
||||
return;
|
||||
}
|
||||
if (!SensorBase::CheckSolenoidChannel(m_forwardChannel)) {
|
||||
if (!SensorUtil::CheckSolenoidChannel(m_forwardChannel)) {
|
||||
wpi_setWPIErrorWithContext(
|
||||
ChannelIndexOutOfRange,
|
||||
"Solenoid Channel " + wpi::Twine(m_forwardChannel));
|
||||
return;
|
||||
}
|
||||
if (!SensorBase::CheckSolenoidChannel(m_reverseChannel)) {
|
||||
if (!SensorUtil::CheckSolenoidChannel(m_reverseChannel)) {
|
||||
wpi_setWPIErrorWithContext(
|
||||
ChannelIndexOutOfRange,
|
||||
"Solenoid Channel " + wpi::Twine(m_reverseChannel));
|
||||
|
||||
@@ -186,7 +186,7 @@ void LiveWindow::AddActuator(const wpi::Twine& subsystem,
|
||||
|
||||
/**
|
||||
* Meant for internal use in other WPILib classes.
|
||||
* @deprecated Use SensorBase::SetName() instead.
|
||||
* @deprecated Use SendableBase::SetName() instead.
|
||||
*/
|
||||
void LiveWindow::AddSensor(const wpi::Twine& type, int channel,
|
||||
Sendable* component) {
|
||||
@@ -197,7 +197,7 @@ void LiveWindow::AddSensor(const wpi::Twine& type, int channel,
|
||||
|
||||
/**
|
||||
* Meant for internal use in other WPILib classes.
|
||||
* @deprecated Use SensorBase::SetName() instead.
|
||||
* @deprecated Use SendableBase::SetName() instead.
|
||||
*/
|
||||
void LiveWindow::AddActuator(const wpi::Twine& type, int channel,
|
||||
Sendable* component) {
|
||||
@@ -208,7 +208,7 @@ void LiveWindow::AddActuator(const wpi::Twine& type, int channel,
|
||||
|
||||
/**
|
||||
* Meant for internal use in other WPILib classes.
|
||||
* @deprecated Use SensorBase::SetName() instead.
|
||||
* @deprecated Use SendableBase::SetName() instead.
|
||||
*/
|
||||
void LiveWindow::AddActuator(const wpi::Twine& type, int module, int channel,
|
||||
Sendable* component) {
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <HAL/PWM.h>
|
||||
#include <HAL/Ports.h>
|
||||
|
||||
#include "SensorBase.h"
|
||||
#include "SensorUtil.h"
|
||||
#include "SmartDashboard/SendableBuilder.h"
|
||||
#include "Utility.h"
|
||||
#include "WPIErrors.h"
|
||||
@@ -29,7 +29,7 @@ using namespace frc;
|
||||
* MXP port
|
||||
*/
|
||||
PWM::PWM(int channel) {
|
||||
if (!SensorBase::CheckPWMChannel(channel)) {
|
||||
if (!SensorUtil::CheckPWMChannel(channel)) {
|
||||
wpi_setWPIErrorWithContext(ChannelIndexOutOfRange,
|
||||
"PWM Channel " + wpi::Twine(channel));
|
||||
return;
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <wpi/SmallString.h>
|
||||
#include <wpi/raw_ostream.h>
|
||||
|
||||
#include "SensorUtil.h"
|
||||
#include "SmartDashboard/SendableBuilder.h"
|
||||
#include "WPIErrors.h"
|
||||
|
||||
@@ -77,7 +78,7 @@ double PowerDistributionPanel::GetTemperature() const {
|
||||
double PowerDistributionPanel::GetCurrent(int channel) const {
|
||||
int32_t status = 0;
|
||||
|
||||
if (!CheckPDPChannel(channel)) {
|
||||
if (!SensorUtil::CheckPDPChannel(channel)) {
|
||||
wpi::SmallString<32> str;
|
||||
wpi::raw_svector_ostream buf(str);
|
||||
buf << "PDP Channel " << channel;
|
||||
@@ -174,7 +175,7 @@ void PowerDistributionPanel::ClearStickyFaults() {
|
||||
|
||||
void PowerDistributionPanel::InitSendable(SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("PowerDistributionPanel");
|
||||
for (int i = 0; i < kPDPChannels; ++i) {
|
||||
for (int i = 0; i < SensorUtil::kPDPChannels; ++i) {
|
||||
builder.AddDoubleProperty("Chan" + wpi::Twine(i),
|
||||
[=]() { return GetCurrent(i); }, nullptr);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <wpi/raw_ostream.h>
|
||||
|
||||
#include "MotorSafetyHelper.h"
|
||||
#include "SensorBase.h"
|
||||
#include "SensorUtil.h"
|
||||
#include "SmartDashboard/SendableBuilder.h"
|
||||
#include "WPIErrors.h"
|
||||
|
||||
@@ -30,7 +30,7 @@ using namespace frc;
|
||||
*/
|
||||
Relay::Relay(int channel, Relay::Direction direction)
|
||||
: m_channel(channel), m_direction(direction) {
|
||||
if (!SensorBase::CheckRelayChannel(m_channel)) {
|
||||
if (!SensorUtil::CheckRelayChannel(m_channel)) {
|
||||
wpi_setWPIErrorWithContext(ChannelIndexOutOfRange,
|
||||
"Relay Channel " + wpi::Twine(m_channel));
|
||||
return;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "SensorBase.h"
|
||||
#include "SensorUtil.h"
|
||||
|
||||
#include <HAL/AnalogInput.h>
|
||||
#include <HAL/AnalogOutput.h>
|
||||
@@ -17,24 +17,22 @@
|
||||
#include <HAL/Relay.h>
|
||||
#include <HAL/Solenoid.h>
|
||||
|
||||
#include "WPIErrors.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
const int SensorBase::kDigitalChannels = HAL_GetNumDigitalChannels();
|
||||
const int SensorBase::kAnalogInputs = HAL_GetNumAnalogInputs();
|
||||
const int SensorBase::kSolenoidChannels = HAL_GetNumSolenoidChannels();
|
||||
const int SensorBase::kSolenoidModules = HAL_GetNumPCMModules();
|
||||
const int SensorBase::kPwmChannels = HAL_GetNumPWMChannels();
|
||||
const int SensorBase::kRelayChannels = HAL_GetNumRelayHeaders();
|
||||
const int SensorBase::kPDPChannels = HAL_GetNumPDPChannels();
|
||||
const int SensorUtil::kDigitalChannels = HAL_GetNumDigitalChannels();
|
||||
const int SensorUtil::kAnalogInputs = HAL_GetNumAnalogInputs();
|
||||
const int SensorUtil::kSolenoidChannels = HAL_GetNumSolenoidChannels();
|
||||
const int SensorUtil::kSolenoidModules = HAL_GetNumPCMModules();
|
||||
const int SensorUtil::kPwmChannels = HAL_GetNumPWMChannels();
|
||||
const int SensorUtil::kRelayChannels = HAL_GetNumRelayHeaders();
|
||||
const int SensorUtil::kPDPChannels = HAL_GetNumPDPChannels();
|
||||
|
||||
/**
|
||||
* Check that the solenoid module number is valid.
|
||||
*
|
||||
* @return Solenoid module is valid and present
|
||||
*/
|
||||
bool SensorBase::CheckSolenoidModule(int moduleNumber) {
|
||||
bool SensorUtil::CheckSolenoidModule(int moduleNumber) {
|
||||
return HAL_CheckSolenoidModule(moduleNumber);
|
||||
}
|
||||
|
||||
@@ -46,7 +44,7 @@ bool SensorBase::CheckSolenoidModule(int moduleNumber) {
|
||||
*
|
||||
* @return Digital channel is valid
|
||||
*/
|
||||
bool SensorBase::CheckDigitalChannel(int channel) {
|
||||
bool SensorUtil::CheckDigitalChannel(int channel) {
|
||||
return HAL_CheckDIOChannel(channel);
|
||||
}
|
||||
|
||||
@@ -58,7 +56,7 @@ bool SensorBase::CheckDigitalChannel(int channel) {
|
||||
*
|
||||
* @return Relay channel is valid
|
||||
*/
|
||||
bool SensorBase::CheckRelayChannel(int channel) {
|
||||
bool SensorUtil::CheckRelayChannel(int channel) {
|
||||
return HAL_CheckRelayChannel(channel);
|
||||
}
|
||||
|
||||
@@ -70,7 +68,7 @@ bool SensorBase::CheckRelayChannel(int channel) {
|
||||
*
|
||||
* @return PWM channel is valid
|
||||
*/
|
||||
bool SensorBase::CheckPWMChannel(int channel) {
|
||||
bool SensorUtil::CheckPWMChannel(int channel) {
|
||||
return HAL_CheckPWMChannel(channel);
|
||||
}
|
||||
|
||||
@@ -82,7 +80,7 @@ bool SensorBase::CheckPWMChannel(int channel) {
|
||||
*
|
||||
* @return Analog channel is valid
|
||||
*/
|
||||
bool SensorBase::CheckAnalogInputChannel(int channel) {
|
||||
bool SensorUtil::CheckAnalogInputChannel(int channel) {
|
||||
return HAL_CheckAnalogInputChannel(channel);
|
||||
}
|
||||
|
||||
@@ -94,7 +92,7 @@ bool SensorBase::CheckAnalogInputChannel(int channel) {
|
||||
*
|
||||
* @return Analog channel is valid
|
||||
*/
|
||||
bool SensorBase::CheckAnalogOutputChannel(int channel) {
|
||||
bool SensorUtil::CheckAnalogOutputChannel(int channel) {
|
||||
return HAL_CheckAnalogOutputChannel(channel);
|
||||
}
|
||||
|
||||
@@ -103,7 +101,7 @@ bool SensorBase::CheckAnalogOutputChannel(int channel) {
|
||||
*
|
||||
* @return Solenoid channel is valid
|
||||
*/
|
||||
bool SensorBase::CheckSolenoidChannel(int channel) {
|
||||
bool SensorUtil::CheckSolenoidChannel(int channel) {
|
||||
return HAL_CheckSolenoidChannel(channel);
|
||||
}
|
||||
|
||||
@@ -112,6 +110,6 @@ bool SensorBase::CheckSolenoidChannel(int channel) {
|
||||
*
|
||||
* @return PDP channel is valid
|
||||
*/
|
||||
bool SensorBase::CheckPDPChannel(int channel) {
|
||||
bool SensorUtil::CheckPDPChannel(int channel) {
|
||||
return HAL_CheckPDPModule(channel);
|
||||
}
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <HAL/Ports.h>
|
||||
#include <HAL/Solenoid.h>
|
||||
|
||||
#include "SensorBase.h"
|
||||
#include "SensorUtil.h"
|
||||
#include "SmartDashboard/SendableBuilder.h"
|
||||
#include "WPIErrors.h"
|
||||
|
||||
@@ -23,7 +23,7 @@ using namespace frc;
|
||||
* @param channel The channel on the PCM to control (0..7).
|
||||
*/
|
||||
Solenoid::Solenoid(int channel)
|
||||
: Solenoid(SensorBase::GetDefaultSolenoidModule(), channel) {}
|
||||
: Solenoid(SensorUtil::GetDefaultSolenoidModule(), channel) {}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -33,12 +33,12 @@ Solenoid::Solenoid(int channel)
|
||||
*/
|
||||
Solenoid::Solenoid(int moduleNumber, int channel)
|
||||
: SolenoidBase(moduleNumber), m_channel(channel) {
|
||||
if (!SensorBase::CheckSolenoidModule(m_moduleNumber)) {
|
||||
if (!SensorUtil::CheckSolenoidModule(m_moduleNumber)) {
|
||||
wpi_setWPIErrorWithContext(ModuleIndexOutOfRange,
|
||||
"Solenoid Module " + wpi::Twine(m_moduleNumber));
|
||||
return;
|
||||
}
|
||||
if (!SensorBase::CheckSolenoidChannel(m_channel)) {
|
||||
if (!SensorUtil::CheckSolenoidChannel(m_channel)) {
|
||||
wpi_setWPIErrorWithContext(ChannelIndexOutOfRange,
|
||||
"Solenoid Channel " + wpi::Twine(m_channel));
|
||||
return;
|
||||
|
||||
@@ -7,8 +7,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ErrorBase.h"
|
||||
#include "I2C.h"
|
||||
#include "SensorBase.h"
|
||||
#include "SmartDashboard/SendableBase.h"
|
||||
#include "interfaces/Accelerometer.h"
|
||||
|
||||
namespace frc {
|
||||
@@ -20,7 +21,9 @@ namespace frc {
|
||||
* an I2C bus. This class assumes the default (not alternate) sensor address of
|
||||
* 0x1D (7-bit address).
|
||||
*/
|
||||
class ADXL345_I2C : public SensorBase, public Accelerometer {
|
||||
class ADXL345_I2C : public ErrorBase,
|
||||
public SendableBase,
|
||||
public Accelerometer {
|
||||
public:
|
||||
enum Axes { kAxis_X = 0x00, kAxis_Y = 0x02, kAxis_Z = 0x04 };
|
||||
|
||||
|
||||
@@ -7,8 +7,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ErrorBase.h"
|
||||
#include "SPI.h"
|
||||
#include "SensorBase.h"
|
||||
#include "SmartDashboard/SendableBase.h"
|
||||
#include "interfaces/Accelerometer.h"
|
||||
|
||||
namespace frc {
|
||||
@@ -19,7 +20,9 @@ namespace frc {
|
||||
* This class allows access to an Analog Devices ADXL345 3-axis accelerometer
|
||||
* via SPI. This class assumes the sensor is wired in 4-wire SPI mode.
|
||||
*/
|
||||
class ADXL345_SPI : public SensorBase, public Accelerometer {
|
||||
class ADXL345_SPI : public ErrorBase,
|
||||
public SendableBase,
|
||||
public Accelerometer {
|
||||
public:
|
||||
enum Axes { kAxis_X = 0x00, kAxis_Y = 0x02, kAxis_Z = 0x04 };
|
||||
|
||||
|
||||
@@ -7,8 +7,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ErrorBase.h"
|
||||
#include "SPI.h"
|
||||
#include "SensorBase.h"
|
||||
#include "SmartDashboard/SendableBase.h"
|
||||
#include "interfaces/Accelerometer.h"
|
||||
|
||||
namespace frc {
|
||||
@@ -18,7 +19,7 @@ namespace frc {
|
||||
*
|
||||
* This class allows access to an Analog Devices ADXL362 3-axis accelerometer.
|
||||
*/
|
||||
class ADXL362 : public SensorBase, public Accelerometer {
|
||||
class ADXL362 : public ErrorBase, public SendableBase, public Accelerometer {
|
||||
public:
|
||||
enum Axes { kAxis_X = 0x00, kAxis_Y = 0x02, kAxis_Z = 0x04 };
|
||||
struct AllAxes {
|
||||
|
||||
@@ -10,8 +10,9 @@
|
||||
#include <memory>
|
||||
|
||||
#include "AnalogInput.h"
|
||||
#include "ErrorBase.h"
|
||||
#include "PIDSource.h"
|
||||
#include "SensorBase.h"
|
||||
#include "SmartDashboard/SendableBase.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -22,7 +23,9 @@ namespace frc {
|
||||
* sensors have multiple axis and can be treated as multiple devices. Each is
|
||||
* calibrated by finding the center value over a period of time.
|
||||
*/
|
||||
class AnalogAccelerometer : public SensorBase, public PIDSource {
|
||||
class AnalogAccelerometer : public ErrorBase,
|
||||
public SendableBase,
|
||||
public PIDSource {
|
||||
public:
|
||||
explicit AnalogAccelerometer(int channel);
|
||||
explicit AnalogAccelerometer(AnalogInput* channel);
|
||||
|
||||
@@ -11,8 +11,9 @@
|
||||
|
||||
#include <HAL/Types.h>
|
||||
|
||||
#include "ErrorBase.h"
|
||||
#include "PIDSource.h"
|
||||
#include "SensorBase.h"
|
||||
#include "SmartDashboard/SendableBase.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -28,7 +29,7 @@ namespace frc {
|
||||
* are divided by the number of samples to retain the resolution, but get more
|
||||
* stable values.
|
||||
*/
|
||||
class AnalogInput : public SensorBase, public PIDSource {
|
||||
class AnalogInput : public ErrorBase, public SendableBase, public PIDSource {
|
||||
friend class AnalogTrigger;
|
||||
friend class AnalogGyro;
|
||||
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
#include <memory>
|
||||
|
||||
#include "AnalogInput.h"
|
||||
#include "SensorBase.h"
|
||||
#include "ErrorBase.h"
|
||||
#include "SmartDashboard/SendableBase.h"
|
||||
#include "interfaces/Potentiometer.h"
|
||||
|
||||
namespace frc {
|
||||
@@ -21,7 +22,9 @@ namespace frc {
|
||||
* units you choose, by way of the scaling and offset constants passed to the
|
||||
* constructor.
|
||||
*/
|
||||
class AnalogPotentiometer : public SensorBase, public Potentiometer {
|
||||
class AnalogPotentiometer : public ErrorBase,
|
||||
public SendableBase,
|
||||
public Potentiometer {
|
||||
public:
|
||||
/**
|
||||
* AnalogPotentiometer constructor.
|
||||
|
||||
@@ -12,13 +12,14 @@
|
||||
#include <HAL/Types.h>
|
||||
|
||||
#include "AnalogTriggerOutput.h"
|
||||
#include "SensorBase.h"
|
||||
#include "ErrorBase.h"
|
||||
#include "SmartDashboard/SendableBase.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class AnalogInput;
|
||||
|
||||
class AnalogTrigger : public SensorBase {
|
||||
class AnalogTrigger : public ErrorBase, public SendableBase {
|
||||
friend class AnalogTriggerOutput;
|
||||
|
||||
public:
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "SensorBase.h"
|
||||
#include "ErrorBase.h"
|
||||
#include "SmartDashboard/SendableBase.h"
|
||||
#include "interfaces/Accelerometer.h"
|
||||
|
||||
namespace frc {
|
||||
@@ -17,7 +18,9 @@ namespace frc {
|
||||
*
|
||||
* This class allows access to the roboRIO's internal accelerometer.
|
||||
*/
|
||||
class BuiltInAccelerometer : public SensorBase, public Accelerometer {
|
||||
class BuiltInAccelerometer : public ErrorBase,
|
||||
public SendableBase,
|
||||
public Accelerometer {
|
||||
public:
|
||||
explicit BuiltInAccelerometer(Range range = kRange_8G);
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <HAL/Types.h>
|
||||
|
||||
#include "ErrorBase.h"
|
||||
#include "SensorBase.h"
|
||||
#include "SensorUtil.h"
|
||||
#include "SmartDashboard/SendableBase.h"
|
||||
|
||||
namespace frc {
|
||||
@@ -33,7 +33,7 @@ namespace frc {
|
||||
class Compressor : public ErrorBase, public SendableBase {
|
||||
public:
|
||||
// Default PCM ID is 0
|
||||
explicit Compressor(int pcmID = SensorBase::GetDefaultSolenoidModule());
|
||||
explicit Compressor(int pcmID = SensorUtil::GetDefaultSolenoidModule());
|
||||
~Compressor() override = default;
|
||||
|
||||
void Start();
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
|
||||
#include "AnalogTrigger.h"
|
||||
#include "CounterBase.h"
|
||||
#include "SensorBase.h"
|
||||
#include "ErrorBase.h"
|
||||
#include "SmartDashboard/SendableBase.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -30,7 +31,7 @@ class DigitalGlitchFilter;
|
||||
* All counters will immediately start counting - Reset() them if you need them
|
||||
* to be zeroed before use.
|
||||
*/
|
||||
class Counter : public SensorBase, public CounterBase {
|
||||
class Counter : public ErrorBase, public SendableBase, public CounterBase {
|
||||
public:
|
||||
enum Mode {
|
||||
kTwoPulse = 0,
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
#include <wpi/mutex.h>
|
||||
|
||||
#include "DigitalSource.h"
|
||||
#include "SensorBase.h"
|
||||
#include "ErrorBase.h"
|
||||
#include "SmartDashboard/SendableBase.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -28,7 +29,7 @@ class Counter;
|
||||
* filter. The filter lets the user configure the time that an input must remain
|
||||
* high or low before it is classified as high or low.
|
||||
*/
|
||||
class DigitalGlitchFilter : public SensorBase {
|
||||
class DigitalGlitchFilter : public ErrorBase, public SendableBase {
|
||||
public:
|
||||
DigitalGlitchFilter();
|
||||
~DigitalGlitchFilter() override;
|
||||
|
||||
@@ -13,8 +13,9 @@
|
||||
|
||||
#include "Counter.h"
|
||||
#include "CounterBase.h"
|
||||
#include "ErrorBase.h"
|
||||
#include "PIDSource.h"
|
||||
#include "SensorBase.h"
|
||||
#include "SmartDashboard/SendableBase.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -36,7 +37,10 @@ class DigitalGlitchFilter;
|
||||
* All encoders will immediately start counting - Reset() them if you need them
|
||||
* to be zeroed before use.
|
||||
*/
|
||||
class Encoder : public SensorBase, public CounterBase, public PIDSource {
|
||||
class Encoder : public ErrorBase,
|
||||
public SendableBase,
|
||||
public CounterBase,
|
||||
public PIDSource {
|
||||
public:
|
||||
enum IndexingType {
|
||||
kResetWhileHigh,
|
||||
|
||||
@@ -7,8 +7,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ErrorBase.h"
|
||||
#include "PIDSource.h"
|
||||
#include "SensorBase.h"
|
||||
#include "SmartDashboard/SendableBase.h"
|
||||
#include "interfaces/Gyro.h"
|
||||
|
||||
namespace frc {
|
||||
@@ -17,7 +18,10 @@ namespace frc {
|
||||
* GyroBase is the common base class for Gyro implementations such as
|
||||
* AnalogGyro.
|
||||
*/
|
||||
class GyroBase : public Gyro, public SensorBase, public PIDSource {
|
||||
class GyroBase : public Gyro,
|
||||
public ErrorBase,
|
||||
public SendableBase,
|
||||
public PIDSource {
|
||||
public:
|
||||
// PIDSource interface
|
||||
double PIDGet() override;
|
||||
|
||||
@@ -10,11 +10,12 @@
|
||||
#include <HAL/Interrupts.h>
|
||||
|
||||
#include "AnalogTriggerType.h"
|
||||
#include "SensorBase.h"
|
||||
#include "ErrorBase.h"
|
||||
#include "SmartDashboard/SendableBase.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class InterruptableSensorBase : public SensorBase {
|
||||
class InterruptableSensorBase : public ErrorBase, public SendableBase {
|
||||
public:
|
||||
enum WaitResult {
|
||||
kTimeout = 0x0,
|
||||
|
||||
@@ -49,11 +49,11 @@ class LiveWindow {
|
||||
void AddActuator(const wpi::Twine& subsystem, const wpi::Twine& name,
|
||||
std::shared_ptr<Sendable> component);
|
||||
|
||||
WPI_DEPRECATED("use SensorBase::SetName() instead")
|
||||
WPI_DEPRECATED("use SensorUtil::SetName() instead")
|
||||
void AddSensor(const wpi::Twine& type, int channel, Sendable* component);
|
||||
WPI_DEPRECATED("use SensorBase::SetName() instead")
|
||||
WPI_DEPRECATED("use SensorUtil::SetName() instead")
|
||||
void AddActuator(const wpi::Twine& type, int channel, Sendable* component);
|
||||
WPI_DEPRECATED("use SensorBase::SetName() instead")
|
||||
WPI_DEPRECATED("use SensorUtil::SetName() instead")
|
||||
void AddActuator(const wpi::Twine& type, int module, int channel,
|
||||
Sendable* component);
|
||||
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "SensorBase.h"
|
||||
#include "ErrorBase.h"
|
||||
#include "SmartDashboard/SendableBase.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -15,7 +16,7 @@ namespace frc {
|
||||
* Class for getting voltage, current, temperature, power and energy from the
|
||||
* CAN PDP.
|
||||
*/
|
||||
class PowerDistributionPanel : public SensorBase {
|
||||
class PowerDistributionPanel : public ErrorBase, public SendableBase {
|
||||
public:
|
||||
PowerDistributionPanel();
|
||||
explicit PowerDistributionPanel(int module);
|
||||
|
||||
@@ -7,28 +7,14 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "Base.h"
|
||||
#include "ErrorBase.h"
|
||||
#include "SmartDashboard/Sendable.h"
|
||||
#include "SmartDashboard/SendableBase.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
* Base class for all sensors.
|
||||
*
|
||||
* Stores most recent status information as well as containing utility functions
|
||||
* for checking channels and error processing.
|
||||
*/
|
||||
class SensorBase : public ErrorBase, public SendableBase {
|
||||
class SensorUtil final {
|
||||
public:
|
||||
SensorBase() = default;
|
||||
|
||||
SensorBase(const SensorBase&) = delete;
|
||||
SensorBase& operator=(const SensorBase&) = delete;
|
||||
|
||||
static int GetDefaultSolenoidModule() { return 0; }
|
||||
|
||||
static bool CheckSolenoidModule(int moduleNumber);
|
||||
@@ -48,6 +34,9 @@ class SensorBase : public ErrorBase, public SendableBase {
|
||||
static const int kPwmChannels;
|
||||
static const int kRelayChannels;
|
||||
static const int kPDPChannels;
|
||||
|
||||
private:
|
||||
SensorUtil() = default;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
@@ -13,13 +13,14 @@
|
||||
|
||||
#include <networktables/NetworkTableValue.h>
|
||||
|
||||
#include "SensorBase.h"
|
||||
#include "ErrorBase.h"
|
||||
#include "SmartDashboard/SendableBase.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class Sendable;
|
||||
|
||||
class SmartDashboard : public SensorBase {
|
||||
class SmartDashboard : public ErrorBase, public SendableBase {
|
||||
public:
|
||||
static void init();
|
||||
|
||||
|
||||
@@ -13,8 +13,9 @@
|
||||
#include <vector>
|
||||
|
||||
#include "Counter.h"
|
||||
#include "ErrorBase.h"
|
||||
#include "PIDSource.h"
|
||||
#include "SensorBase.h"
|
||||
#include "SmartDashboard/SendableBase.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -33,7 +34,7 @@ class DigitalOutput;
|
||||
* received. The time that the line is high determines the round trip distance
|
||||
* (time of flight).
|
||||
*/
|
||||
class Ultrasonic : public SensorBase, public PIDSource {
|
||||
class Ultrasonic : public ErrorBase, public SendableBase, public PIDSource {
|
||||
public:
|
||||
enum DistanceUnit { kInches = 0, kMilliMeters = 1 };
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
#include "SD540.h"
|
||||
#include "SPI.h"
|
||||
#include "SampleRobot.h"
|
||||
#include "SensorBase.h"
|
||||
#include "SensorUtil.h"
|
||||
#include "SerialPort.h"
|
||||
#include "Servo.h"
|
||||
#include "SmartDashboard/SendableChooser.h"
|
||||
|
||||
Reference in New Issue
Block a user