Merge branch '2022'

This commit is contained in:
Peter Johnson
2021-05-09 14:15:40 -07:00
765 changed files with 5914 additions and 13714 deletions

View File

@@ -6,7 +6,6 @@
#include <hal/SimDevice.h>
#include "frc/ErrorBase.h"
#include "frc/I2C.h"
#include "frc/interfaces/Accelerometer.h"
#include "frc/smartdashboard/Sendable.h"
@@ -23,8 +22,7 @@ class SendableBuilder;
* an I2C bus. This class assumes the default (not alternate) sensor address of
* 0x1D (7-bit address).
*/
class ADXL345_I2C : public ErrorBase,
public Accelerometer,
class ADXL345_I2C : public Accelerometer,
public Sendable,
public SendableHelper<ADXL345_I2C> {
public:

View File

@@ -6,7 +6,6 @@
#include <hal/SimDevice.h>
#include "frc/ErrorBase.h"
#include "frc/SPI.h"
#include "frc/interfaces/Accelerometer.h"
#include "frc/smartdashboard/Sendable.h"
@@ -20,8 +19,7 @@ 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 ErrorBase,
public Accelerometer,
class ADXL345_SPI : public Accelerometer,
public Sendable,
public SendableHelper<ADXL345_SPI> {
public:

View File

@@ -6,7 +6,6 @@
#include <hal/SimDevice.h>
#include "frc/ErrorBase.h"
#include "frc/SPI.h"
#include "frc/interfaces/Accelerometer.h"
#include "frc/smartdashboard/Sendable.h"
@@ -21,8 +20,7 @@ class SendableBuilder;
*
* This class allows access to an Analog Devices ADXL362 3-axis accelerometer.
*/
class ADXL362 : public ErrorBase,
public Accelerometer,
class ADXL362 : public Accelerometer,
public Sendable,
public SendableHelper<ADXL362> {
public:

View File

@@ -8,8 +8,10 @@
#include <hal/SimDevice.h>
#include "frc/GyroBase.h"
#include "frc/SPI.h"
#include "frc/interfaces/Gyro.h"
#include "frc/smartdashboard/Sendable.h"
#include "frc/smartdashboard/SendableHelper.h"
namespace frc {
@@ -26,7 +28,9 @@ namespace frc {
* This class is for the digital ADXRS450 gyro sensor that connects via SPI.
* Only one instance of an ADXRS Gyro is supported.
*/
class ADXRS450_Gyro : public GyroBase {
class ADXRS450_Gyro : public Gyro,
public Sendable,
public SendableHelper<ADXRS450_Gyro> {
public:
/**
* Gyro constructor on onboard CS0.
@@ -96,6 +100,8 @@ class ADXRS450_Gyro : public GyroBase {
*/
int GetPort() const;
void InitSendable(SendableBuilder& builder) override;
private:
SPI m_spi;
SPI::Port m_port;

View File

@@ -11,7 +11,6 @@
#include <units/time.h>
#include <wpi/ArrayRef.h>
#include "frc/ErrorBase.h"
#include "util/Color.h"
#include "util/Color8Bit.h"
@@ -22,7 +21,7 @@ namespace frc {
*
* <p>Only 1 LED driver is currently supported by the roboRIO.
*/
class AddressableLED : public ErrorBase {
class AddressableLED {
public:
class LEDData : public HAL_AddressableLEDData {
public:
@@ -86,7 +85,7 @@ class AddressableLED : public ErrorBase {
*/
explicit AddressableLED(int port);
~AddressableLED() override;
~AddressableLED();
/**
* Sets the length of the LED strip.

View File

@@ -7,8 +7,6 @@
#include <memory>
#include "frc/AnalogInput.h"
#include "frc/ErrorBase.h"
#include "frc/PIDSource.h"
#include "frc/smartdashboard/Sendable.h"
#include "frc/smartdashboard/SendableHelper.h"
@@ -23,9 +21,7 @@ class SendableBuilder;
* 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 ErrorBase,
public PIDSource,
public Sendable,
class AnalogAccelerometer : public Sendable,
public SendableHelper<AnalogAccelerometer> {
public:
/**
@@ -97,13 +93,6 @@ class AnalogAccelerometer : public ErrorBase,
*/
void SetZero(double zero);
/**
* Get the Acceleration for the PID Source parent.
*
* @return The current acceleration in Gs.
*/
double PIDGet() override;
void InitSendable(SendableBuilder& builder) override;
private:

View File

@@ -12,7 +12,6 @@
#include "frc/AnalogTrigger.h"
#include "frc/Counter.h"
#include "frc/ErrorBase.h"
#include "frc/smartdashboard/Sendable.h"
#include "frc/smartdashboard/SendableHelper.h"
@@ -22,9 +21,7 @@ class AnalogInput;
/**
* Class for supporting continuous analog encoders, such as the US Digital MA3.
*/
class AnalogEncoder : public ErrorBase,
public Sendable,
public SendableHelper<AnalogEncoder> {
class AnalogEncoder : public Sendable, public SendableHelper<AnalogEncoder> {
public:
/**
* Construct a new AnalogEncoder attached to a specific AnalogIn channel.

View File

@@ -8,7 +8,7 @@
#include <hal/Types.h>
#include "frc/GyroBase.h"
#include "frc/interfaces/Gyro.h"
#include "frc/smartdashboard/Sendable.h"
#include "frc/smartdashboard/SendableHelper.h"
@@ -29,7 +29,9 @@ class AnalogInput;
*
* This class is for gyro sensors that connect to an analog input.
*/
class AnalogGyro : public GyroBase {
class AnalogGyro : public Gyro,
public Sendable,
public SendableHelper<AnalogGyro> {
public:
static constexpr int kOversampleBits = 10;
static constexpr int kAverageBits = 0;
@@ -190,6 +192,8 @@ class AnalogGyro : public GyroBase {
*/
std::shared_ptr<AnalogInput> GetAnalogInput() const;
void InitSendable(SendableBuilder& builder) override;
protected:
std::shared_ptr<AnalogInput> m_analog;

View File

@@ -8,8 +8,6 @@
#include <hal/Types.h>
#include "frc/ErrorBase.h"
#include "frc/PIDSource.h"
#include "frc/smartdashboard/Sendable.h"
#include "frc/smartdashboard/SendableHelper.h"
@@ -31,10 +29,7 @@ class DMASample;
* are divided by the number of samples to retain the resolution, but get more
* stable values.
*/
class AnalogInput : public ErrorBase,
public PIDSource,
public Sendable,
public SendableHelper<AnalogInput> {
class AnalogInput : public Sendable, public SendableHelper<AnalogInput> {
friend class AnalogTrigger;
friend class AnalogGyro;
friend class DMA;
@@ -280,13 +275,6 @@ class AnalogInput : public ErrorBase,
*/
static double GetSampleRate();
/**
* Get the Average value for the PID Source base object.
*
* @return The average voltage.
*/
double PIDGet() override;
/**
* Indicates this input is used by a simulated device.
*

View File

@@ -6,7 +6,6 @@
#include <hal/Types.h>
#include "frc/ErrorBase.h"
#include "frc/smartdashboard/Sendable.h"
#include "frc/smartdashboard/SendableHelper.h"
@@ -17,9 +16,7 @@ class SendableBuilder;
/**
* MXP analog output class.
*/
class AnalogOutput : public ErrorBase,
public Sendable,
public SendableHelper<AnalogOutput> {
class AnalogOutput : public Sendable, public SendableHelper<AnalogOutput> {
public:
/**
* Construct an analog output on the given channel.

View File

@@ -7,8 +7,6 @@
#include <memory>
#include "frc/AnalogInput.h"
#include "frc/ErrorBase.h"
#include "frc/interfaces/Potentiometer.h"
#include "frc/smartdashboard/Sendable.h"
#include "frc/smartdashboard/SendableHelper.h"
@@ -22,9 +20,7 @@ class SendableBuilder;
* units you choose, by way of the scaling and offset constants passed to the
* constructor.
*/
class AnalogPotentiometer : public ErrorBase,
public Potentiometer,
public Sendable,
class AnalogPotentiometer : public Sendable,
public SendableHelper<AnalogPotentiometer> {
public:
/**
@@ -105,14 +101,7 @@ class AnalogPotentiometer : public ErrorBase,
* @return The current position of the potentiometer (in the units used for
* fullRange and offset).
*/
double Get() const override;
/**
* Implement the PIDSource interface.
*
* @return The current reading.
*/
double PIDGet() override;
double Get() const;
void InitSendable(SendableBuilder& builder) override;

View File

@@ -9,7 +9,6 @@
#include <hal/Types.h>
#include "frc/AnalogTriggerOutput.h"
#include "frc/ErrorBase.h"
#include "frc/smartdashboard/Sendable.h"
#include "frc/smartdashboard/SendableHelper.h"
@@ -19,9 +18,7 @@ class AnalogInput;
class DutyCycle;
class SendableBuilder;
class AnalogTrigger : public ErrorBase,
public Sendable,
public SendableHelper<AnalogTrigger> {
class AnalogTrigger : public Sendable, public SendableHelper<AnalogTrigger> {
friend class AnalogTriggerOutput;
public:

View File

@@ -4,7 +4,6 @@
#pragma once
#include "frc/ErrorBase.h"
#include "frc/interfaces/Accelerometer.h"
#include "frc/smartdashboard/Sendable.h"
#include "frc/smartdashboard/SendableHelper.h"
@@ -18,8 +17,7 @@ class SendableBuilder;
*
* This class allows access to the roboRIO's internal accelerometer.
*/
class BuiltInAccelerometer : public ErrorBase,
public Accelerometer,
class BuiltInAccelerometer : public Accelerometer,
public Sendable,
public SendableHelper<BuiltInAccelerometer> {
public:

View File

@@ -8,8 +8,6 @@
#include <hal/CANAPITypes.h>
#include "frc/ErrorBase.h"
namespace frc {
struct CANData {
uint8_t data[8];
@@ -27,7 +25,7 @@ struct CANData {
* All methods are thread save, however the buffer objects passed in
* by the user need to not be modified for the duration of their calls.
*/
class CAN : public ErrorBase {
class CAN {
public:
/**
* Create a new CAN communication interface with the specific device ID.
@@ -52,7 +50,7 @@ class CAN : public ErrorBase {
/**
* Closes the CAN communication.
*/
~CAN() override;
~CAN();
CAN(CAN&&) = default;
CAN& operator=(CAN&&) = default;

View File

@@ -6,7 +6,6 @@
#include <hal/Types.h>
#include "frc/ErrorBase.h"
#include "frc/SensorUtil.h"
#include "frc/smartdashboard/Sendable.h"
#include "frc/smartdashboard/SendableHelper.h"
@@ -30,9 +29,7 @@ class SendableBuilder;
* loop control. You can only turn off closed loop control, thereby stopping
* the compressor from operating.
*/
class Compressor : public ErrorBase,
public Sendable,
public SendableHelper<Compressor> {
class Compressor : public Sendable, public SendableHelper<Compressor> {
public:
/**
* Constructor. The default PCM ID is 0.

View File

@@ -10,7 +10,6 @@
#include "frc/AnalogTrigger.h"
#include "frc/CounterBase.h"
#include "frc/ErrorBase.h"
#include "frc/smartdashboard/Sendable.h"
#include "frc/smartdashboard/SendableHelper.h"
@@ -31,8 +30,7 @@ class DMASample;
* All counters will immediately start counting - Reset() them if you need them
* to be zeroed before use.
*/
class Counter : public ErrorBase,
public CounterBase,
class Counter : public CounterBase,
public Sendable,
public SendableHelper<Counter> {
friend class DMA;

View File

@@ -6,8 +6,6 @@
#include <hal/Types.h>
#include "frc/ErrorBase.h"
namespace frc {
class Encoder;
class Counter;
@@ -16,12 +14,12 @@ class DutyCycle;
class AnalogInput;
class DMASample;
class DMA : public ErrorBase {
class DMA {
friend class DMASample;
public:
DMA();
~DMA() override;
~DMA();
DMA& operator=(DMA&& other) = default;
DMA(DMA&& other) = default;

View File

@@ -11,7 +11,6 @@
#include <wpi/mutex.h>
#include "frc/DigitalSource.h"
#include "frc/ErrorBase.h"
#include "frc/smartdashboard/Sendable.h"
#include "frc/smartdashboard/SendableHelper.h"
@@ -27,8 +26,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 ErrorBase,
public Sendable,
class DigitalGlitchFilter : public Sendable,
public SendableHelper<DigitalGlitchFilter> {
public:
DigitalGlitchFilter();

View File

@@ -15,8 +15,6 @@
#include <wpi/condition_variable.h>
#include <wpi/mutex.h>
#include "frc/ErrorBase.h"
namespace frc {
class MatchDataSender;
@@ -25,12 +23,12 @@ class MatchDataSender;
* Provide access to the network communication data to / from the Driver
* Station.
*/
class DriverStation : public ErrorBase {
class DriverStation {
public:
enum Alliance { kRed, kBlue, kInvalid };
enum MatchType { kNone, kPractice, kQualification, kElimination };
~DriverStation() override;
~DriverStation();
DriverStation(const DriverStation&) = delete;
DriverStation& operator=(const DriverStation&) = delete;

View File

@@ -8,7 +8,6 @@
#include <hal/Types.h>
#include "frc/ErrorBase.h"
#include "frc/smartdashboard/Sendable.h"
#include "frc/smartdashboard/SendableHelper.h"
@@ -29,9 +28,7 @@ class DMASample;
* order to implement rollover checking.
*
*/
class DutyCycle : public ErrorBase,
public Sendable,
public SendableHelper<DutyCycle> {
class DutyCycle : public Sendable, public SendableHelper<DutyCycle> {
friend class AnalogTrigger;
friend class DMA;
friend class DMASample;

View File

@@ -12,7 +12,6 @@
#include "frc/AnalogTrigger.h"
#include "frc/Counter.h"
#include "frc/ErrorBase.h"
#include "frc/smartdashboard/Sendable.h"
#include "frc/smartdashboard/SendableHelper.h"
@@ -25,8 +24,7 @@ class DigitalSource;
* PWM Output, the CTRE Mag Encoder, the Rev Hex Encoder, and the AM Mag
* Encoder.
*/
class DutyCycleEncoder : public ErrorBase,
public Sendable,
class DutyCycleEncoder : public Sendable,
public SendableHelper<DutyCycleEncoder> {
public:
/**

View File

@@ -10,8 +10,6 @@
#include "frc/Counter.h"
#include "frc/CounterBase.h"
#include "frc/ErrorBase.h"
#include "frc/PIDSource.h"
#include "frc/smartdashboard/Sendable.h"
#include "frc/smartdashboard/SendableHelper.h"
@@ -38,9 +36,7 @@ class DMASample;
* All encoders will immediately start counting - Reset() them if you need them
* to be zeroed before use.
*/
class Encoder : public ErrorBase,
public CounterBase,
public PIDSource,
class Encoder : public CounterBase,
public Sendable,
public SendableHelper<Encoder> {
friend class DMA;
@@ -314,8 +310,6 @@ class Encoder : public ErrorBase,
*/
int GetSamplesToAverage() const;
double PIDGet() override;
/**
* Set the index source for the encoder.
*

View File

@@ -1,63 +0,0 @@
// 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 <string>
#include <wpi/StringRef.h>
#include <wpi/Twine.h>
#ifdef _WIN32
#pragma push_macro("GetMessage")
#undef GetMessage
#endif
namespace frc {
class ErrorBase;
/**
* Error object represents a library error.
*/
class Error {
public:
using Code = int;
Error() = default;
Error(Code code, const wpi::Twine& contextMessage, wpi::StringRef filename,
wpi::StringRef function, int lineNumber,
const ErrorBase* originatingObject);
bool operator<(const Error& rhs) const;
Code GetCode() const;
std::string GetMessage() const;
std::string GetFilename() const;
std::string GetFunction() const;
int GetLineNumber() const;
const ErrorBase* GetOriginatingObject() const;
double GetTimestamp() const;
void Clear();
void Set(Code code, const wpi::Twine& contextMessage, wpi::StringRef filename,
wpi::StringRef function, int lineNumber,
const ErrorBase* originatingObject);
private:
void Report();
Code m_code = 0;
std::string m_message;
std::string m_filename;
std::string m_function;
int m_lineNumber = 0;
const ErrorBase* m_originatingObject = nullptr;
double m_timestamp = 0.0;
};
} // namespace frc
#ifdef _WIN32
#pragma pop_macro("GetMessage")
#endif

View File

@@ -1,239 +0,0 @@
// 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 <vector>
#include <wpi/StringRef.h>
#include <wpi/Twine.h>
#include "frc/Error.h"
// Forward declared manually to avoid needing to pull in entire HAL header.
extern "C" const char* HAL_GetErrorMessage(int32_t code);
#define wpi_setErrnoErrorWithContext(context) \
this->SetErrnoError((context), __FILE__, __FUNCTION__, __LINE__)
#define wpi_setErrnoError() wpi_setErrnoErrorWithContext("")
#define wpi_setImaqErrorWithContext(code, context) \
do { \
if ((code) != 0) \
this->SetImaqError((code), (context), __FILE__, __FUNCTION__, __LINE__); \
} while (0)
#define wpi_setErrorWithContext(code, context) \
do { \
if ((code) != 0) \
this->SetError((code), (context), __FILE__, __FUNCTION__, __LINE__); \
} while (0)
#define wpi_setErrorWithContextRange(code, min, max, req, context) \
do { \
if ((code) != 0) \
this->SetErrorRange((code), (min), (max), (req), (context), __FILE__, \
__FUNCTION__, __LINE__); \
} while (0)
#define wpi_setHALError(code) \
do { \
if ((code) != 0) \
this->SetError((code), HAL_GetErrorMessage(code), __FILE__, \
__FUNCTION__, __LINE__); \
} while (0)
#define wpi_setHALErrorWithRange(code, min, max, req) \
do { \
if ((code) != 0) \
this->SetErrorRange((code), (min), (max), (req), \
HAL_GetErrorMessage(code), __FILE__, __FUNCTION__, \
__LINE__); \
} while (0)
#define wpi_setError(code) wpi_setErrorWithContext(code, "")
#define wpi_setStaticErrorWithContext(object, code, context) \
do { \
if ((code) != 0) \
object->SetError((code), (context), __FILE__, __FUNCTION__, __LINE__); \
} while (0)
#define wpi_setStaticError(object, code) \
wpi_setStaticErrorWithContext(object, code, "")
#define wpi_setGlobalErrorWithContext(code, context) \
do { \
if ((code) != 0) \
::frc::ErrorBase::SetGlobalError((code), (context), __FILE__, \
__FUNCTION__, __LINE__); \
} while (0)
#define wpi_setGlobalHALError(code) \
do { \
if ((code) != 0) \
::frc::ErrorBase::SetGlobalError((code), HAL_GetErrorMessage(code), \
__FILE__, __FUNCTION__, __LINE__); \
} while (0)
#define wpi_setGlobalError(code) wpi_setGlobalErrorWithContext(code, "")
#define wpi_setWPIErrorWithContext(error, context) \
this->SetWPIError(wpi_error_s_##error(), wpi_error_value_##error(), \
(context), __FILE__, __FUNCTION__, __LINE__)
#define wpi_setWPIError(error) (wpi_setWPIErrorWithContext(error, ""))
#define wpi_setStaticWPIErrorWithContext(object, error, context) \
object->SetWPIError(wpi_error_s_##error(), (context), __FILE__, \
__FUNCTION__, __LINE__)
#define wpi_setStaticWPIError(object, error) \
wpi_setStaticWPIErrorWithContext(object, error, "")
#define wpi_setGlobalWPIErrorWithContext(error, context) \
::frc::ErrorBase::SetGlobalWPIError(wpi_error_s_##error(), (context), \
__FILE__, __FUNCTION__, __LINE__)
#define wpi_setGlobalWPIError(error) wpi_setGlobalWPIErrorWithContext(error, "")
namespace frc {
/**
* Base class for most objects.
*
* ErrorBase is the base class for most objects since it holds the generated
* error for that object. In addition, there is a single instance of a global
* error object.
*/
class ErrorBase {
// TODO: Consider initializing instance variables and cleanup in destructor
public:
ErrorBase();
virtual ~ErrorBase() = default;
ErrorBase(const ErrorBase&) = default;
ErrorBase& operator=(const ErrorBase&) = default;
ErrorBase(ErrorBase&&) = default;
ErrorBase& operator=(ErrorBase&&) = default;
/**
* @brief Retrieve the current error.
*
* Get the current error information associated with this sensor.
*/
virtual Error& GetError();
/**
* @brief Retrieve the current error.
*
* Get the current error information associated with this sensor.
*/
virtual const Error& GetError() const;
/**
* @brief Clear the current error information associated with this sensor.
*/
virtual void ClearError() const;
/**
* @brief Set error information associated with a C library call that set an
* error to the "errno" global variable.
*
* @param contextMessage A custom message from the code that set the error.
* @param filename Filename of the error source
* @param function Function of the error source
* @param lineNumber Line number of the error source
*/
virtual void SetErrnoError(const wpi::Twine& contextMessage,
wpi::StringRef filename, wpi::StringRef function,
int lineNumber) const;
/**
* @brief Set the current error information associated from the nivision Imaq
* API.
*
* @param success The return from the function
* @param contextMessage A custom message from the code that set the error.
* @param filename Filename of the error source
* @param function Function of the error source
* @param lineNumber Line number of the error source
*/
virtual void SetImaqError(int success, const wpi::Twine& contextMessage,
wpi::StringRef filename, wpi::StringRef function,
int lineNumber) const;
/**
* @brief Set the current error information associated with this sensor.
*
* @param code The error code
* @param contextMessage A custom message from the code that set the error.
* @param filename Filename of the error source
* @param function Function of the error source
* @param lineNumber Line number of the error source
*/
virtual void SetError(Error::Code code, const wpi::Twine& contextMessage,
wpi::StringRef filename, wpi::StringRef function,
int lineNumber) const;
/**
* @brief Set the current error information associated with this sensor.
* Range versions use for initialization code.
*
* @param code The error code
* @param minRange The minimum allowed allocation range
* @param maxRange The maximum allowed allocation range
* @param requestedValue The requested value to allocate
* @param contextMessage A custom message from the code that set the error.
* @param filename Filename of the error source
* @param function Function of the error source
* @param lineNumber Line number of the error source
*/
virtual void SetErrorRange(Error::Code code, int32_t minRange,
int32_t maxRange, int32_t requestedValue,
const wpi::Twine& contextMessage,
wpi::StringRef filename, wpi::StringRef function,
int lineNumber) const;
/**
* @brief Set the current error information associated with this sensor.
*
* @param errorMessage The error message from WPIErrors.h
* @param contextMessage A custom message from the code that set the error.
* @param filename Filename of the error source
* @param function Function of the error source
* @param lineNumber Line number of the error source
*/
virtual void SetWPIError(const wpi::Twine& errorMessage, Error::Code code,
const wpi::Twine& contextMessage,
wpi::StringRef filename, wpi::StringRef function,
int lineNumber) const;
virtual void CloneError(const ErrorBase& rhs) const;
/**
* @brief Check if the current error code represents a fatal error.
*
* @return true if the current error is fatal.
*/
virtual bool StatusIsFatal() const;
static void SetGlobalError(Error::Code code, const wpi::Twine& contextMessage,
wpi::StringRef filename, wpi::StringRef function,
int lineNumber);
static void SetGlobalWPIError(const wpi::Twine& errorMessage,
const wpi::Twine& contextMessage,
wpi::StringRef filename,
wpi::StringRef function, int lineNumber);
/**
* Retrieve the last global error.
*/
static Error GetGlobalError();
/**
* Retrieve all global errors.
*/
static std::vector<Error> GetGlobalErrors();
/**
* Clear global errors.
*/
void ClearGlobalErrors();
protected:
mutable Error m_error;
};
} // namespace frc

View File

@@ -0,0 +1,139 @@
// 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 <stdint.h>
#include <memory>
#include <stdexcept>
#include <string>
#include <wpi/Twine.h>
namespace frc {
/**
* Runtime error exception.
*/
class RuntimeError : public std::runtime_error {
public:
RuntimeError(int32_t code, const wpi::Twine& message, const wpi::Twine& loc,
wpi::StringRef stack);
RuntimeError(int32_t code, const wpi::Twine& message, const char* fileName,
int lineNumber, const char* funcName, wpi::StringRef stack);
int32_t code() const noexcept { return m_data->code; }
const char* loc() const noexcept { return m_data->loc.c_str(); }
const char* stack() const noexcept { return m_data->stack.c_str(); }
/**
* Reports error to Driver Station (using HAL_SendError).
*/
void Report() const;
private:
struct Data {
int32_t code;
std::string loc;
std::string stack;
};
std::shared_ptr<Data> m_data;
};
/**
* Gets error message string for an error code.
*/
const char* GetErrorMessage(int32_t* code);
/**
* Reports an error to the driver station (using HAL_SendError).
* Generally the FRC_ReportError wrapper macro should be used instead.
*
* @param status error code
* @param message error message details
* @param fileName source file name
* @param lineNumber source line number
* @param funcName source function name
*/
void ReportError(int32_t status, const wpi::Twine& message,
const char* fileName, int lineNumber, const char* funcName);
/**
* Makes a runtime error exception object. This object should be thrown
* by the caller. Generally the FRC_MakeError wrapper macro should be used
* instead.
*
* @param status error code
* @param message error message details
* @param fileName source file name
* @param lineNumber source line number
* @param funcName source function name
* @return runtime error object
*/
[[nodiscard]] RuntimeError MakeError(int32_t status, const wpi::Twine& message,
const char* fileName, int lineNumber,
const char* funcName);
namespace err {
#define S(label, offset, message) inline constexpr int label = offset;
#include "frc/WPIErrors.mac"
#undef S
} // namespace err
namespace warn {
#define S(label, offset, message) inline constexpr int label = offset;
#include "frc/WPIWarnings.mac"
#undef S
} // namespace warn
} // namespace frc
/**
* Reports an error to the driver station (using HAL_SendError).
*
* @param status error code
* @param message error message details
*/
#define FRC_ReportError(status, message) \
do { \
if ((status) != 0) { \
::frc::ReportError(status, message, __FILE__, __LINE__, __FUNCTION__); \
} \
} while (0)
/**
* Makes a runtime error exception object. This object should be thrown
* by the caller.
*
* @param status error code
* @param message error message details
* @return runtime error object
*/
#define FRC_MakeError(status, message) \
::frc::MakeError(status, message, __FILE__, __LINE__, __FUNCTION__)
/**
* Checks a status code and depending on its value, either throws a
* RuntimeError exception, calls ReportError, or does nothing (if no error).
*
* @param status error code
* @param message error message details
*/
#define FRC_CheckErrorStatus(status, message) \
do { \
if ((status) < 0) { \
throw FRC_MakeError(status, message); \
} else if ((status) > 0) { \
FRC_ReportError(status, message); \
} \
} while (0)
#define FRC_AssertMessage(condition, message) \
do { \
if (!(condition)) { \
throw FRC_MakeError(err::AssertionFailure, message); \
} \
} while (0)
#define FRC_Assert(condition) FRC_AssertMessage(condition, #condition)

View File

@@ -1,85 +0,0 @@
// 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 <memory>
#include <string>
#include <wpi/deprecated.h>
#include "frc/Counter.h"
namespace frc {
/**
* Alias for counter class.
*
* Implements the gear tooth sensor supplied by FIRST. Currently there is no
* reverse sensing on the gear tooth sensor, but in future versions we might
* implement the necessary timing in the FPGA to sense direction.
*
* @deprecated No longer used per FMS usage reporting
*/
class GearTooth : public Counter {
public:
// 55 uSec for threshold
static constexpr double kGearToothThreshold = 55e-6;
/**
* Construct a GearTooth sensor given a channel.
*
* @param channel The DIO channel that the sensor is connected to.
* 0-9 are on-board, 10-25 are on the MXP.
* @param directionSensitive True to enable the pulse length decoding in
* hardware to specify count direction.
*/
WPI_DEPRECATED(
"The only sensor this works with is no longer available and no teams use "
"it according to FMS usage reporting.")
explicit GearTooth(int channel, bool directionSensitive = false);
/**
* Construct a GearTooth sensor given a digital input.
*
* This should be used when sharing digital inputs.
*
* @param source A pointer to the existing DigitalSource object
* (such as a DigitalInput)
* @param directionSensitive True to enable the pulse length decoding in
* hardware to specify count direction.
*/
WPI_DEPRECATED(
"The only sensor this works with is no longer available and no teams use "
"it according to FMS usage reporting.")
explicit GearTooth(DigitalSource* source, bool directionSensitive = false);
/**
* Construct a GearTooth sensor given a digital input.
*
* This should be used when sharing digital inputs.
*
* @param source A reference to the existing DigitalSource object
* (such as a DigitalInput)
* @param directionSensitive True to enable the pulse length decoding in
* hardware to specify count direction.
*/
WPI_DEPRECATED(
"The only sensor this works with is no longer available and no teams use "
"it according to FMS usage reporting.")
explicit GearTooth(std::shared_ptr<DigitalSource> source,
bool directionSensitive = false);
GearTooth(GearTooth&&) = default;
GearTooth& operator=(GearTooth&&) = default;
/**
* Common code called by the constructors.
*/
void EnableDirectionSensing(bool directionSensitive);
void InitSendable(SendableBuilder& builder) override;
};
} // namespace frc

View File

@@ -8,8 +8,6 @@
#include <string>
#include "frc/ErrorBase.h"
namespace frc {
class DriverStation;
@@ -17,7 +15,7 @@ class DriverStation;
/**
* GenericHID Interface.
*/
class GenericHID : public ErrorBase {
class GenericHID {
public:
enum RumbleType { kLeftRumble, kRightRumble };
@@ -44,7 +42,7 @@ class GenericHID : public ErrorBase {
enum JoystickHand { kLeftHand = 0, kRightHand = 1 };
explicit GenericHID(int port);
~GenericHID() override = default;
virtual ~GenericHID() = default;
GenericHID(GenericHID&&) = default;
GenericHID& operator=(GenericHID&&) = default;

View File

@@ -1,41 +0,0 @@
// 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/ErrorBase.h"
#include "frc/PIDSource.h"
#include "frc/interfaces/Gyro.h"
#include "frc/smartdashboard/Sendable.h"
#include "frc/smartdashboard/SendableHelper.h"
namespace frc {
/**
* GyroBase is the common base class for Gyro implementations such as
* AnalogGyro.
*/
class GyroBase : public Gyro,
public ErrorBase,
public PIDSource,
public Sendable,
public SendableHelper<GyroBase> {
public:
GyroBase() = default;
GyroBase(GyroBase&&) = default;
GyroBase& operator=(GyroBase&&) = default;
// PIDSource interface
/**
* Get the PIDOutput for the PIDSource base object. Can be set to return
* angle or rate using SetPIDSourceType(). Defaults to angle.
*
* @return The PIDOutput (angle or rate, defaults to angle)
*/
double PIDGet() override;
void InitSendable(SendableBuilder& builder) override;
};
} // namespace frc

View File

@@ -8,8 +8,6 @@
#include <hal/I2CTypes.h>
#include "frc/ErrorBase.h"
namespace frc {
/**
@@ -18,7 +16,7 @@ namespace frc {
* This class is intended to be used by sensor (and other I2C device) drivers.
* It probably should not be used directly.
*/
class I2C : public ErrorBase {
class I2C {
public:
enum Port { kOnboard = 0, kMXP };
@@ -30,7 +28,7 @@ class I2C : public ErrorBase {
*/
I2C(Port port, int deviceAddress);
~I2C() override;
~I2C();
I2C(I2C&&) = default;
I2C& operator=(I2C&&) = default;

View File

@@ -10,11 +10,10 @@
#include <hal/Interrupts.h>
#include "frc/AnalogTriggerType.h"
#include "frc/ErrorBase.h"
namespace frc {
class InterruptableSensorBase : public ErrorBase {
class InterruptableSensorBase {
public:
enum WaitResult {
kTimeout = 0x0,
@@ -35,7 +34,7 @@ class InterruptableSensorBase : public ErrorBase {
/**
* Free the resources for an interrupt event.
*/
~InterruptableSensorBase() override;
virtual ~InterruptableSensorBase();
InterruptableSensorBase(InterruptableSensorBase&&) = default;
InterruptableSensorBase& operator=(InterruptableSensorBase&&) = default;

View File

@@ -1,50 +0,0 @@
// 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 <atomic>
#include "frc/IterativeRobotBase.h"
namespace frc {
/**
* IterativeRobot implements the IterativeRobotBase robot program framework.
*
* The IterativeRobot class is intended to be subclassed by a user creating a
* robot program.
*
* Periodic() functions from the base class are called each time a new packet is
* received from the driver station.
*
* @deprecated Use TimedRobot instead. It's a drop-in replacement that provides
* more regular execution periods.
*/
class IterativeRobot : public IterativeRobotBase {
public:
WPI_DEPRECATED(
"Use TimedRobot instead. It's a drop-in replacement that provides more "
"regular execution periods.")
IterativeRobot();
~IterativeRobot() override = default;
/**
* Provide an alternate "main loop" via StartCompetition().
*
* This specific StartCompetition() implements "main loop" behavior synced
* with the DS packets.
*/
void StartCompetition() override;
/**
* Ends the main loop in StartCompetition().
*/
void EndCompetition() override;
private:
std::atomic<bool> m_exit{false};
};
} // namespace frc

View File

@@ -160,6 +160,11 @@ class IterativeRobotBase : public RobotBase {
*/
void SetNetworkTablesFlushEnabled(bool enabled);
/**
* Gets time period between calls to Periodic() functions.
*/
units::second_t GetPeriod() const;
/**
* Constructor for IterativeRobotBase.
*
@@ -186,12 +191,11 @@ class IterativeRobotBase : public RobotBase {
void LoopFunc();
units::second_t m_period;
private:
enum class Mode { kNone, kDisabled, kAutonomous, kTeleop, kTest };
Mode m_lastMode = Mode::kNone;
units::second_t m_period;
Watchdog m_watchdog;
bool m_ntFlushEnabled = false;

View File

@@ -5,11 +5,13 @@
#pragma once
#include <wpi/mutex.h>
#include <wpi/raw_ostream.h>
#include "frc/ErrorBase.h"
#include "frc/Timer.h"
namespace wpi {
class raw_ostream;
} // namespace wpi
namespace frc {
/**
@@ -18,10 +20,10 @@ namespace frc {
*
* The subclass should call Feed() whenever the motor value is updated.
*/
class MotorSafety : public ErrorBase {
class MotorSafety {
public:
MotorSafety();
~MotorSafety() override;
virtual ~MotorSafety();
MotorSafety(MotorSafety&& rhs);
MotorSafety& operator=(MotorSafety&& rhs);

View File

@@ -18,11 +18,9 @@
#include <wpi/deprecated.h>
#include <wpi/mutex.h>
#include "frc/ErrorBase.h"
namespace frc {
class Notifier : public ErrorBase {
class Notifier {
public:
/**
* Create a Notifier for timer event notification.
@@ -63,7 +61,7 @@ class Notifier : public ErrorBase {
/**
* Free the resources for a timer event.
*/
~Notifier() override;
~Notifier();
Notifier(Notifier&& rhs);
Notifier& operator=(Notifier&& rhs);

View File

@@ -1,407 +0,0 @@
// 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 <memory>
#include <string>
#include <wpi/deprecated.h>
#include <wpi/mutex.h>
#include "frc/Base.h"
#include "frc/LinearFilter.h"
#include "frc/PIDInterface.h"
#include "frc/PIDOutput.h"
#include "frc/PIDSource.h"
#include "frc/Timer.h"
#include "frc/smartdashboard/Sendable.h"
#include "frc/smartdashboard/SendableHelper.h"
namespace frc {
class SendableBuilder;
/**
* Class implements a PID Control Loop.
*
* Creates a separate thread which reads the given PIDSource and takes care of
* the integral calculations, as well as writing the given PIDOutput.
*
* This feedback controller runs in discrete time, so time deltas are not used
* in the integral and derivative calculations. Therefore, the sample rate
* affects the controller's behavior for a given set of PID constants.
*
* @deprecated All APIs which use this have been deprecated.
*/
class PIDBase : public PIDInterface,
public PIDOutput,
public Sendable,
public SendableHelper<PIDBase> {
public:
/**
* Allocate a PID object with the given constants for P, I, D.
*
* @param Kp the proportional coefficient
* @param Ki the integral coefficient
* @param Kd the derivative coefficient
* @param source The PIDSource object that is used to get values
* @param output The PIDOutput object that is set to the output value
*/
WPI_DEPRECATED("All APIs which use this have been deprecated.")
PIDBase(double p, double i, double d, PIDSource& source, PIDOutput& output);
/**
* Allocate a PID object with the given constants for P, I, D.
*
* @param Kp the proportional coefficient
* @param Ki the integral coefficient
* @param Kd the derivative coefficient
* @param source The PIDSource object that is used to get values
* @param output The PIDOutput object that is set to the output value
*/
WPI_DEPRECATED("All APIs which use this have been deprecated.")
PIDBase(double p, double i, double d, double f, PIDSource& source,
PIDOutput& output);
~PIDBase() override = default;
/**
* Return the current PID result.
*
* This is always centered on zero and constrained the the max and min outs.
*
* @return the latest calculated output
*/
virtual double Get() const;
/**
* Set the PID controller to consider the input to be continuous,
*
* Rather then using the max and min input range as constraints, it considers
* them to be the same point and automatically calculates the shortest route
* to the setpoint.
*
* @param continuous true turns on continuous, false turns off continuous
*/
virtual void SetContinuous(bool continuous = true);
/**
* Sets the maximum and minimum values expected from the input.
*
* @param minimumInput the minimum value expected from the input
* @param maximumInput the maximum value expected from the output
*/
virtual void SetInputRange(double minimumInput, double maximumInput);
/**
* Sets the minimum and maximum values to write.
*
* @param minimumOutput the minimum value to write to the output
* @param maximumOutput the maximum value to write to the output
*/
virtual void SetOutputRange(double minimumOutput, double maximumOutput);
/**
* Set the PID Controller gain parameters.
*
* Set the proportional, integral, and differential coefficients.
*
* @param p Proportional coefficient
* @param i Integral coefficient
* @param d Differential coefficient
*/
void SetPID(double p, double i, double d) override;
/**
* Set the PID Controller gain parameters.
*
* Set the proportional, integral, and differential coefficients.
*
* @param p Proportional coefficient
* @param i Integral coefficient
* @param d Differential coefficient
* @param f Feed forward coefficient
*/
virtual void SetPID(double p, double i, double d, double f);
/**
* Set the Proportional coefficient of the PID controller gain.
*
* @param p proportional coefficient
*/
void SetP(double p);
/**
* Set the Integral coefficient of the PID controller gain.
*
* @param i integral coefficient
*/
void SetI(double i);
/**
* Set the Differential coefficient of the PID controller gain.
*
* @param d differential coefficient
*/
void SetD(double d);
/**
* Get the Feed forward coefficient of the PID controller gain.
*
* @param f Feed forward coefficient
*/
void SetF(double f);
/**
* Get the Proportional coefficient.
*
* @return proportional coefficient
*/
double GetP() const override;
/**
* Get the Integral coefficient.
*
* @return integral coefficient
*/
double GetI() const override;
/**
* Get the Differential coefficient.
*
* @return differential coefficient
*/
double GetD() const override;
/**
* Get the Feed forward coefficient.
*
* @return Feed forward coefficient
*/
virtual double GetF() const;
/**
* Set the setpoint for the PIDBase.
*
* @param setpoint the desired setpoint
*/
void SetSetpoint(double setpoint) override;
/**
* Returns the current setpoint of the PIDBase.
*
* @return the current setpoint
*/
double GetSetpoint() const override;
/**
* Returns the change in setpoint over time of the PIDBase.
*
* @return the change in setpoint over time
*/
double GetDeltaSetpoint() const;
/**
* Returns the current difference of the input from the setpoint.
*
* @return the current error
*/
virtual double GetError() const;
/**
* Returns the current average of the error over the past few iterations.
*
* You can specify the number of iterations to average with
* SetToleranceBuffer() (defaults to 1). This is the same value that is used
* for OnTarget().
*
* @return the average error
*/
WPI_DEPRECATED("Use a LinearFilter as the input and GetError().")
virtual double GetAvgError() const;
/**
* Sets what type of input the PID controller will use.
*/
virtual void SetPIDSourceType(PIDSourceType pidSource);
/**
* Returns the type of input the PID controller is using.
*
* @return the PID controller input type
*/
virtual PIDSourceType GetPIDSourceType() const;
/**
* Set the percentage error which is considered tolerable for use with
* OnTarget.
*
* @param percentage error which is tolerable
*/
WPI_DEPRECATED("Use SetPercentTolerance() instead.")
virtual void SetTolerance(double percent);
/**
* Set the absolute error which is considered tolerable for use with
* OnTarget.
*
* @param percentage error which is tolerable
*/
virtual void SetAbsoluteTolerance(double absValue);
/**
* Set the percentage error which is considered tolerable for use with
* OnTarget.
*
* @param percentage error which is tolerable
*/
virtual void SetPercentTolerance(double percentValue);
/**
* Set the number of previous error samples to average for tolerancing. When
* determining whether a mechanism is on target, the user may want to use a
* rolling average of previous measurements instead of a precise position or
* velocity. This is useful for noisy sensors which return a few erroneous
* measurements when the mechanism is on target. However, the mechanism will
* not register as on target for at least the specified bufLength cycles.
*
* @param bufLength Number of previous cycles to average. Defaults to 1.
*/
WPI_DEPRECATED("Use a LinearDigitalFilter as the input.")
virtual void SetToleranceBuffer(int buf = 1);
/**
* Return true if the error is within the percentage of the total input range,
* determined by SetTolerance. This asssumes that the maximum and minimum
* input were set using SetInput.
*
* Currently this just reports on target as the actual value passes through
* the setpoint. Ideally it should be based on being within the tolerance for
* some period of time.
*
* This will return false until at least one input value has been computed.
*/
virtual bool OnTarget() const;
/**
* Reset the previous error, the integral term, and disable the controller.
*/
void Reset() override;
/**
* Passes the output directly to SetSetpoint().
*
* PIDControllers can be nested by passing a PIDController as another
* PIDController's output. In that case, the output of the parent controller
* becomes the input (i.e., the reference) of the child.
*
* It is the caller's responsibility to put the data into a valid form for
* SetSetpoint().
*/
void PIDWrite(double output) override;
void InitSendable(SendableBuilder& builder) override;
protected:
// Is the pid controller enabled
bool m_enabled = false;
mutable wpi::mutex m_thisMutex;
// Ensures when Disable() is called, PIDWrite() won't run if Calculate()
// is already running at that time.
mutable wpi::mutex m_pidWriteMutex;
PIDSource* m_pidInput;
PIDOutput* m_pidOutput;
Timer m_setpointTimer;
/**
* Read the input, calculate the output accordingly, and write to the output.
* This should only be called by the Notifier.
*/
virtual void Calculate();
/**
* Calculate the feed forward term.
*
* Both of the provided feed forward calculations are velocity feed forwards.
* If a different feed forward calculation is desired, the user can override
* this function and provide his or her own. This function does no
* synchronization because the PIDBase class only calls it in synchronized
* code, so be careful if calling it oneself.
*
* If a velocity PID controller is being used, the F term should be set to 1
* over the maximum setpoint for the output. If a position PID controller is
* being used, the F term should be set to 1 over the maximum speed for the
* output measured in setpoint units per this controller's update period (see
* the default period in this class's constructor).
*/
virtual double CalculateFeedForward();
/**
* Wraps error around for continuous inputs. The original error is returned if
* continuous mode is disabled. This is an unsynchronized function.
*
* @param error The current error of the PID controller.
* @return Error for continuous inputs.
*/
double GetContinuousError(double error) const;
private:
// Factor for "proportional" control
double m_P;
// Factor for "integral" control
double m_I;
// Factor for "derivative" control
double m_D;
// Factor for "feed forward" control
double m_F;
// |maximum output|
double m_maximumOutput = 1.0;
// |minimum output|
double m_minimumOutput = -1.0;
// Maximum input - limit setpoint to this
double m_maximumInput = 0;
// Minimum input - limit setpoint to this
double m_minimumInput = 0;
// input range - difference between maximum and minimum
double m_inputRange = 0;
// Do the endpoints wrap around? eg. Absolute encoder
bool m_continuous = false;
// The prior error (used to compute velocity)
double m_prevError = 0;
// The sum of the errors for use in the integral calc
double m_totalError = 0;
enum {
kAbsoluteTolerance,
kPercentTolerance,
kNoTolerance
} m_toleranceType = kNoTolerance;
// The percetage or absolute error that is considered on target.
double m_tolerance = 0.05;
double m_setpoint = 0;
double m_prevSetpoint = 0;
double m_error = 0;
double m_result = 0;
LinearFilter<double> m_filter{{}, {}};
};
} // namespace frc

View File

@@ -1,136 +0,0 @@
// 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 <memory>
#include <string>
#include <wpi/deprecated.h>
#include <wpi/mutex.h>
#include "frc/Base.h"
#include "frc/Controller.h"
#include "frc/Notifier.h"
#include "frc/PIDBase.h"
#include "frc/PIDSource.h"
#include "frc/Timer.h"
namespace frc {
class PIDOutput;
/**
* Class implements a PID Control Loop.
*
* Creates a separate thread which reads the given PIDSource and takes care of
* the integral calculations, as well as writing the given PIDOutput.
*
* This feedback controller runs in discrete time, so time deltas are not used
* in the integral and derivative calculations. Therefore, the sample rate
* affects the controller's behavior for a given set of PID constants.
*
* @deprecated Use frc2::PIDController class instead.
*/
class PIDController : public PIDBase, public Controller {
public:
/**
* Allocate a PID object with the given constants for P, I, D.
*
* @param Kp the proportional coefficient
* @param Ki the integral coefficient
* @param Kd the derivative coefficient
* @param source The PIDSource object that is used to get values
* @param output The PIDOutput object that is set to the output value
* @param period the loop time for doing calculations in seconds. This
* particularly affects calculations of the integral and
* differential terms. The default is 0.05 (50ms).
*/
WPI_DEPRECATED("Use frc2::PIDController class instead.")
PIDController(double p, double i, double d, PIDSource* source,
PIDOutput* output, double period = 0.05);
/**
* Allocate a PID object with the given constants for P, I, D.
*
* @param Kp the proportional coefficient
* @param Ki the integral coefficient
* @param Kd the derivative coefficient
* @param source The PIDSource object that is used to get values
* @param output The PIDOutput object that is set to the output value
* @param period the loop time for doing calculations in seconds. This
* particularly affects calculations of the integral and
* differential terms. The default is 0.05 (50ms).
*/
WPI_DEPRECATED("Use frc2::PIDController class instead.")
PIDController(double p, double i, double d, double f, PIDSource* source,
PIDOutput* output, double period = 0.05);
/**
* Allocate a PID object with the given constants for P, I, D.
*
* @param Kp the proportional coefficient
* @param Ki the integral coefficient
* @param Kd the derivative coefficient
* @param source The PIDSource object that is used to get values
* @param output The PIDOutput object that is set to the output value
* @param period the loop time for doing calculations in seconds. This
* particularly affects calculations of the integral and
* differential terms. The default is 0.05 (50ms).
*/
WPI_DEPRECATED("Use frc2::PIDController class instead.")
PIDController(double p, double i, double d, PIDSource& source,
PIDOutput& output, double period = 0.05);
/**
* Allocate a PID object with the given constants for P, I, D.
*
* @param Kp the proportional coefficient
* @param Ki the integral coefficient
* @param Kd the derivative coefficient
* @param source The PIDSource object that is used to get values
* @param output The PIDOutput object that is set to the output value
* @param period the loop time for doing calculations in seconds. This
* particularly affects calculations of the integral and
* differential terms. The default is 0.05 (50ms).
*/
WPI_DEPRECATED("Use frc2::PIDController class instead.")
PIDController(double p, double i, double d, double f, PIDSource& source,
PIDOutput& output, double period = 0.05);
~PIDController() override;
/**
* Begin running the PIDController.
*/
void Enable() override;
/**
* Stop running the PIDController, this sets the output to zero before
* stopping.
*/
void Disable() override;
/**
* Set the enabled state of the PIDController.
*/
void SetEnabled(bool enable);
/**
* Return true if PIDController is enabled.
*/
bool IsEnabled() const;
/**
* Reset the previous error, the integral term, and disable the controller.
*/
void Reset() override;
void InitSendable(SendableBuilder& builder) override;
private:
std::unique_ptr<Notifier> m_controlLoop;
};
} // namespace frc

View File

@@ -1,34 +0,0 @@
// 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 <wpi/deprecated.h>
namespace frc {
/**
* Interface for PID Control Loop.
*
* @deprecated All APIs which use this have been deprecated.
*/
class PIDInterface {
public:
WPI_DEPRECATED("All APIs which use this have been deprecated.")
PIDInterface() = default;
PIDInterface(PIDInterface&&) = default;
PIDInterface& operator=(PIDInterface&&) = default;
virtual void SetPID(double p, double i, double d) = 0;
virtual double GetP() const = 0;
virtual double GetI() const = 0;
virtual double GetD() const = 0;
virtual void SetSetpoint(double setpoint) = 0;
virtual double GetSetpoint() const = 0;
virtual void Reset() = 0;
};
} // namespace frc

View File

@@ -1,22 +0,0 @@
// 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/Base.h"
namespace frc {
/**
* PIDOutput interface is a generic output for the PID class.
*
* PWMs use this class. Users implement this interface to allow for a
* PIDController to read directly from the inputs.
*/
class PIDOutput {
public:
virtual void PIDWrite(double output) = 0;
};
} // namespace frc

View File

@@ -1,36 +0,0 @@
// 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 PIDSourceType { kDisplacement, kRate };
/**
* PIDSource interface is a generic sensor source for the PID class.
*
* All sensors that can be used with the PID class will implement the PIDSource
* that returns a standard value that will be used in the PID code.
*/
class PIDSource {
public:
virtual ~PIDSource() = default;
/**
* Set which parameter you are using as a process control variable.
*
* @param pidSource An enum to select the parameter.
*/
virtual void SetPIDSourceType(PIDSourceType pidSource);
virtual PIDSourceType GetPIDSourceType() const;
virtual double PIDGet() = 0;
protected:
PIDSourceType m_pidSource = PIDSourceType::kDisplacement;
};
} // namespace frc

View File

@@ -7,9 +7,7 @@
#include <stdint.h>
#include <hal/Types.h>
#include <wpi/raw_ostream.h>
#include "frc/MotorSafety.h"
#include "frc/smartdashboard/Sendable.h"
#include "frc/smartdashboard/SendableHelper.h"
@@ -34,7 +32,7 @@ class SendableBuilder;
* - 1 = minimum pulse width (currently 0.5ms)
* - 0 = disabled (i.e. PWM output is held low)
*/
class PWM : public MotorSafety, public Sendable, public SendableHelper<PWM> {
class PWM : public Sendable, public SendableHelper<PWM> {
public:
friend class AddressableLED;
/**
@@ -64,8 +62,10 @@ class PWM : public MotorSafety, public Sendable, public SendableHelper<PWM> {
*
* @param channel The PWM channel number. 0-9 are on-board, 10-19 are on the
* MXP port
* @param registerSendable If true, adds this instance to SendableRegistry
* and LiveWindow
*/
explicit PWM(int channel);
explicit PWM(int channel, bool registerSendable = true);
/**
* Free the PWM channel.
@@ -77,10 +77,6 @@ class PWM : public MotorSafety, public Sendable, public SendableHelper<PWM> {
PWM(PWM&&) = default;
PWM& operator=(PWM&&) = default;
// MotorSafety interface
void StopMotor() override;
void GetDescription(wpi::raw_ostream& desc) const override;
/**
* Set the PWM value directly to the hardware.
*

View File

@@ -6,7 +6,6 @@
#include <hal/Types.h>
#include "frc/ErrorBase.h"
#include "frc/smartdashboard/Sendable.h"
#include "frc/smartdashboard/SendableHelper.h"
@@ -18,8 +17,7 @@ class SendableBuilder;
* Class for getting voltage, current, temperature, power and energy from the
* CAN PDP.
*/
class PowerDistributionPanel : public ErrorBase,
public Sendable,
class PowerDistributionPanel : public Sendable,
public SendableHelper<PowerDistributionPanel> {
public:
PowerDistributionPanel();

View File

@@ -11,8 +11,7 @@
#include <vector>
#include <networktables/NetworkTable.h>
#include "frc/ErrorBase.h"
#include <wpi/deprecated.h>
namespace frc {
@@ -30,14 +29,14 @@ namespace frc {
* This will also interact with {@link NetworkTable} by creating a table called
* "Preferences" with all the key-value pairs.
*/
class Preferences : public ErrorBase {
class Preferences {
public:
/**
* Get the one and only {@link Preferences} object.
*
* @return pointer to the {@link Preferences}
* @return reference to the {@link Preferences}
*/
static Preferences* GetInstance();
static Preferences& GetInstance();
/**
* Returns a vector of all the keys.
@@ -116,6 +115,18 @@ class Preferences : public ErrorBase {
* @param key the key
* @param value the value
*/
void SetString(wpi::StringRef key, wpi::StringRef value);
/**
* Puts the given string into the preferences table.
*
* The value may not have quotation marks, nor may the key have any whitespace
* nor an equals sign.
*
* @param key the key
* @param value the value
*/
WPI_DEPRECATED("Use SetString instead.")
void PutString(wpi::StringRef key, wpi::StringRef value);
/**
@@ -132,6 +143,17 @@ class Preferences : public ErrorBase {
* @param key the key
* @param value the value
*/
void SetInt(wpi::StringRef key, int value);
/**
* Puts the given int into the preferences table.
*
* The key may not have any whitespace nor an equals sign.
*
* @param key the key
* @param value the value
*/
WPI_DEPRECATED("Use SetInt instead.")
void PutInt(wpi::StringRef key, int value);
/**
@@ -148,6 +170,17 @@ class Preferences : public ErrorBase {
* @param key the key
* @param value the value
*/
void SetDouble(wpi::StringRef key, double value);
/**
* Puts the given double into the preferences table.
*
* The key may not have any whitespace nor an equals sign.
*
* @param key the key
* @param value the value
*/
WPI_DEPRECATED("Use SetDouble instead.")
void PutDouble(wpi::StringRef key, double value);
/**
@@ -164,6 +197,17 @@ class Preferences : public ErrorBase {
* @param key the key
* @param value the value
*/
void SetFloat(wpi::StringRef key, float value);
/**
* Puts the given float into the preferences table.
*
* The key may not have any whitespace nor an equals sign.
*
* @param key the key
* @param value the value
*/
WPI_DEPRECATED("Use SetFloat instead.")
void PutFloat(wpi::StringRef key, float value);
/**
@@ -180,6 +224,17 @@ class Preferences : public ErrorBase {
* @param key the key
* @param value the value
*/
void SetBoolean(wpi::StringRef key, bool value);
/**
* Puts the given boolean into the preferences table.
*
* The key may not have any whitespace nor an equals sign.
*
* @param key the key
* @param value the value
*/
WPI_DEPRECATED("Use SetBoolean instead.")
void PutBoolean(wpi::StringRef key, bool value);
/**
@@ -196,6 +251,17 @@ class Preferences : public ErrorBase {
* @param key the key
* @param value the value
*/
void SetLong(wpi::StringRef key, int64_t value);
/**
* Puts the given long (int64_t) into the preferences table.
*
* The key may not have any whitespace nor an equals sign.
*
* @param key the key
* @param value the value
*/
WPI_DEPRECATED("Use SetLong instead.")
void PutLong(wpi::StringRef key, int64_t value);
/**
@@ -226,7 +292,7 @@ class Preferences : public ErrorBase {
protected:
Preferences();
~Preferences() override = default;
~Preferences();
Preferences(Preferences&&) = default;
Preferences& operator=(Preferences&&) = default;

View File

@@ -9,7 +9,6 @@
#include <hal/Types.h>
#include <wpi/raw_ostream.h>
#include "frc/ErrorBase.h"
#include "frc/MotorSafety.h"
#include "frc/smartdashboard/Sendable.h"
#include "frc/smartdashboard/SendableHelper.h"

View File

@@ -12,8 +12,6 @@
#include <wpi/mutex.h>
#include "frc/ErrorBase.h"
namespace frc {
/**
@@ -26,9 +24,9 @@ namespace frc {
* resources; it just tracks which indices were marked in use by Allocate and
* not yet freed by Free.
*/
class Resource : public ErrorBase {
class Resource {
public:
~Resource() override = default;
virtual ~Resource() = default;
/**
* Factory method to create a Resource allocation-tracker *if* needed.

View File

@@ -14,6 +14,7 @@
#include <wpi/raw_ostream.h>
#include "frc/Base.h"
#include "frc/Errors.h"
namespace frc {
@@ -25,12 +26,17 @@ namespace impl {
template <class Robot>
void RunRobot(wpi::mutex& m, Robot** robot) {
static Robot theRobot;
{
std::scoped_lock lock{m};
*robot = &theRobot;
try {
static Robot theRobot;
{
std::scoped_lock lock{m};
*robot = &theRobot;
}
theRobot.StartCompetition();
} catch (const frc::RuntimeError& e) {
e.Report();
throw;
}
theRobot.StartCompetition();
}
} // namespace impl

View File

@@ -1,461 +0,0 @@
// 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 <memory>
#include <wpi/deprecated.h>
#include <wpi/raw_ostream.h>
#include "frc/ErrorBase.h"
#include "frc/MotorSafety.h"
namespace frc {
class SpeedController;
class GenericHID;
/**
* Utility class for handling Robot drive based on a definition of the motor
* configuration.
*
* The robot drive class handles basic driving for a robot. Currently, 2 and 4
* motor tank and mecanum drive trains are supported. In the future other drive
* types like swerve might be implemented. Motor channel numbers are passed
* supplied on creation of the class. Those are used for either the Drive
* function (intended for hand created drive code, such as autonomous) or with
* the Tank/Arcade functions intended to be used for Operator Control driving.
*
* @deprecated Use DifferentialDrive or MecanumDrive classes instead.
*
*/
class RobotDrive : public MotorSafety {
public:
enum MotorType {
kFrontLeftMotor = 0,
kFrontRightMotor = 1,
kRearLeftMotor = 2,
kRearRightMotor = 3
};
/**
* Constructor for RobotDrive with 2 motors specified with channel numbers.
*
* Set up parameters for a two wheel drive system where the
* left and right motor pwm channels are specified in the call.
* This call assumes Talons for controlling the motors.
*
* @param leftMotorChannel The PWM channel number that drives the left motor.
* 0-9 are on-board, 10-19 are on the MXP port
* @param rightMotorChannel The PWM channel number that drives the right
* motor. 0-9 are on-board, 10-19 are on the MXP port
*/
WPI_DEPRECATED("Use DifferentialDrive or MecanumDrive classes instead.")
RobotDrive(int leftMotorChannel, int rightMotorChannel);
/**
* Constructor for RobotDrive with 4 motors specified with channel numbers.
*
* Set up parameters for a four wheel drive system where all four motor
* pwm channels are specified in the call.
* This call assumes Talons for controlling the motors.
*
* @param frontLeftMotor Front left motor channel number. 0-9 are on-board,
* 10-19 are on the MXP port
* @param rearLeftMotor Rear Left motor channel number. 0-9 are on-board,
* 10-19 are on the MXP port
* @param frontRightMotor Front right motor channel number. 0-9 are on-board,
* 10-19 are on the MXP port
* @param rearRightMotor Rear Right motor channel number. 0-9 are on-board,
* 10-19 are on the MXP port
*/
WPI_DEPRECATED("Use DifferentialDrive or MecanumDrive classes instead.")
RobotDrive(int frontLeftMotorChannel, int rearLeftMotorChannel,
int frontRightMotorChannel, int rearRightMotorChannel);
/**
* Constructor for RobotDrive with 2 motors specified as SpeedController
* objects.
*
* The SpeedController version of the constructor enables programs to use the
* RobotDrive classes with subclasses of the SpeedController objects, for
* example, versions with ramping or reshaping of the curve to suit motor bias
* or deadband elimination.
*
* @param leftMotor The left SpeedController object used to drive the robot.
* @param rightMotor The right SpeedController object used to drive the robot.
*/
WPI_DEPRECATED("Use DifferentialDrive or MecanumDrive classes instead.")
RobotDrive(SpeedController* leftMotor, SpeedController* rightMotor);
WPI_DEPRECATED("Use DifferentialDrive or MecanumDrive classes instead.")
RobotDrive(SpeedController& leftMotor, SpeedController& rightMotor);
WPI_DEPRECATED("Use DifferentialDrive or MecanumDrive classes instead.")
RobotDrive(std::shared_ptr<SpeedController> leftMotor,
std::shared_ptr<SpeedController> rightMotor);
/**
* Constructor for RobotDrive with 4 motors specified as SpeedController
* objects.
*
* Speed controller input version of RobotDrive (see previous comments).
*
* @param frontLeftMotor The front left SpeedController object used to drive
* the robot.
* @param rearLeftMotor The back left SpeedController object used to drive
* the robot.
* @param frontRightMotor The front right SpeedController object used to drive
* the robot.
* @param rearRightMotor The back right SpeedController object used to drive
* the robot.
*/
WPI_DEPRECATED("Use DifferentialDrive or MecanumDrive classes instead.")
RobotDrive(SpeedController* frontLeftMotor, SpeedController* rearLeftMotor,
SpeedController* frontRightMotor, SpeedController* rearRightMotor);
WPI_DEPRECATED("Use DifferentialDrive or MecanumDrive classes instead.")
RobotDrive(SpeedController& frontLeftMotor, SpeedController& rearLeftMotor,
SpeedController& frontRightMotor, SpeedController& rearRightMotor);
WPI_DEPRECATED("Use DifferentialDrive or MecanumDrive classes instead.")
RobotDrive(std::shared_ptr<SpeedController> frontLeftMotor,
std::shared_ptr<SpeedController> rearLeftMotor,
std::shared_ptr<SpeedController> frontRightMotor,
std::shared_ptr<SpeedController> rearRightMotor);
~RobotDrive() override = default;
RobotDrive(RobotDrive&&) = default;
RobotDrive& operator=(RobotDrive&&) = default;
/**
* Drive the motors at "outputMagnitude" and "curve".
*
* Both outputMagnitude and curve are -1.0 to +1.0 values, where 0.0
* represents stopped and not turning. curve < 0 will turn left and curve > 0
* will turn right.
*
* The algorithm for steering provides a constant turn radius for any normal
* speed range, both forward and backward. Increasing m_sensitivity causes
* sharper turns for fixed values of curve.
*
* This function will most likely be used in an autonomous routine.
*
* @param outputMagnitude The speed setting for the outside wheel in a turn,
* forward or backwards, +1 to -1.
* @param curve The rate of turn, constant for different forward
* speeds. Set curve < 0 for left turn or curve > 0 for
* right turn.
*
* Set curve = e^(-r/w) to get a turn radius r for wheelbase w of your robot.
* Conversely, turn radius r = -ln(curve)*w for a given value of curve and
* wheelbase w.
*/
void Drive(double outputMagnitude, double curve);
/**
* Provide tank steering using the stored robot configuration.
*
* Drive the robot using two joystick inputs. The Y-axis will be selected from
* each Joystick object.
*
* @param leftStick The joystick to control the left side of the robot.
* @param rightStick The joystick to control the right side of the robot.
* @param squaredInputs If true, the sensitivity will be decreased for small
* values
*/
void TankDrive(GenericHID* leftStick, GenericHID* rightStick,
bool squaredInputs = true);
/**
* Provide tank steering using the stored robot configuration.
*
* Drive the robot using two joystick inputs. The Y-axis will be selected from
* each Joystick object.
*
* @param leftStick The joystick to control the left side of the robot.
* @param rightStick The joystick to control the right side of the robot.
* @param squaredInputs If true, the sensitivity will be decreased for small
* values
*/
void TankDrive(GenericHID& leftStick, GenericHID& rightStick,
bool squaredInputs = true);
/**
* Provide tank steering using the stored robot configuration.
*
* This function lets you pick the axis to be used on each Joystick object for
* the left and right sides of the robot.
*
* @param leftStick The Joystick object to use for the left side of the
* robot.
* @param leftAxis The axis to select on the left side Joystick object.
* @param rightStick The Joystick object to use for the right side of the
* robot.
* @param rightAxis The axis to select on the right side Joystick object.
* @param squaredInputs If true, the sensitivity will be decreased for small
* values
*/
void TankDrive(GenericHID* leftStick, int leftAxis, GenericHID* rightStick,
int rightAxis, bool squaredInputs = true);
void TankDrive(GenericHID& leftStick, int leftAxis, GenericHID& rightStick,
int rightAxis, bool squaredInputs = true);
/**
* Provide tank steering using the stored robot configuration.
*
* This function lets you directly provide joystick values from any source.
*
* @param leftValue The value of the left stick.
* @param rightValue The value of the right stick.
* @param squaredInputs If true, the sensitivity will be decreased for small
* values
*/
void TankDrive(double leftValue, double rightValue,
bool squaredInputs = true);
/**
* Arcade drive implements single stick driving.
*
* Given a single Joystick, the class assumes the Y axis for the move value
* and the X axis for the rotate value. (Should add more information here
* regarding the way that arcade drive works.)
*
* @param stick The joystick to use for Arcade single-stick driving.
* The Y-axis will be selected for forwards/backwards and
* the X-axis will be selected for rotation rate.
* @param squaredInputs If true, the sensitivity will be decreased for small
* values
*/
void ArcadeDrive(GenericHID* stick, bool squaredInputs = true);
/**
* Arcade drive implements single stick driving.
*
* Given a single Joystick, the class assumes the Y axis for the move value
* and the X axis for the rotate value. (Should add more information here
* regarding the way that arcade drive works.)
*
* @param stick The joystick to use for Arcade single-stick driving.
* The Y-axis will be selected for forwards/backwards and
* the X-axis will be selected for rotation rate.
* @param squaredInputs If true, the sensitivity will be decreased for small
* values
*/
void ArcadeDrive(GenericHID& stick, bool squaredInputs = true);
/**
* Arcade drive implements single stick driving.
*
* Given two joystick instances and two axis, compute the values to send to
* either two or four motors.
*
* @param moveStick The Joystick object that represents the
* forward/backward direction
* @param moveAxis The axis on the moveStick object to use for
* forwards/backwards (typically Y_AXIS)
* @param rotateStick The Joystick object that represents the rotation value
* @param rotateAxis The axis on the rotation object to use for the rotate
* right/left (typically X_AXIS)
* @param squaredInputs Setting this parameter to true increases the
* sensitivity at lower speeds
*/
void ArcadeDrive(GenericHID* moveStick, int moveChannel,
GenericHID* rotateStick, int rotateChannel,
bool squaredInputs = true);
/**
* Arcade drive implements single stick driving.
*
* Given two joystick instances and two axis, compute the values to send to
* either two or four motors.
*
* @param moveStick The Joystick object that represents the
* forward/backward direction
* @param moveAxis The axis on the moveStick object to use for
* forwards/backwards (typically Y_AXIS)
* @param rotateStick The Joystick object that represents the rotation value
* @param rotateAxis The axis on the rotation object to use for the rotate
* right/left (typically X_AXIS)
* @param squaredInputs Setting this parameter to true increases the
* sensitivity at lower speeds
*/
void ArcadeDrive(GenericHID& moveStick, int moveChannel,
GenericHID& rotateStick, int rotateChannel,
bool squaredInputs = true);
/**
* Arcade drive implements single stick driving.
*
* This function lets you directly provide joystick values from any source.
*
* @param moveValue The value to use for fowards/backwards
* @param rotateValue The value to use for the rotate right/left
* @param squaredInputs If set, increases the sensitivity at low speeds
*/
void ArcadeDrive(double moveValue, double rotateValue,
bool squaredInputs = true);
/**
* Drive method for Mecanum wheeled robots.
*
* A method for driving with Mecanum wheeled robots. There are 4 wheels
* on the robot, arranged so that the front and back wheels are toed in 45
* degrees.
* When looking at the wheels from the top, the roller axles should form an X
* across the robot.
*
* This is designed to be directly driven by joystick axes.
*
* @param x The speed that the robot should drive in the X direction.
* [-1.0..1.0]
* @param y The speed that the robot should drive in the Y direction.
* This input is inverted to match the forward == -1.0 that
* joysticks produce. [-1.0..1.0]
* @param rotation The rate of rotation for the robot that is completely
* independent of the translation. [-1.0..1.0]
* @param gyroAngle The current angle reading from the gyro. Use this to
* implement field-oriented controls.
*/
void MecanumDrive_Cartesian(double x, double y, double rotation,
double gyroAngle = 0.0);
/**
* Drive method for Mecanum wheeled robots.
*
* A method for driving with Mecanum wheeled robots. There are 4 wheels
* on the robot, arranged so that the front and back wheels are toed in 45
* degrees.
* When looking at the wheels from the top, the roller axles should form an X
* across the robot.
*
* @param magnitude The speed that the robot should drive in a given
* direction. [-1.0..1.0]
* @param direction The direction the robot should drive in degrees. The
* direction and maginitute are independent of the rotation
* rate.
* @param rotation The rate of rotation for the robot that is completely
* independent of the magnitute or direction. [-1.0..1.0]
*/
void MecanumDrive_Polar(double magnitude, double direction, double rotation);
/**
* Holonomic Drive method for Mecanum wheeled robots.
*
* This is an alias to MecanumDrive_Polar() for backward compatibility
*
* @param magnitude The speed that the robot should drive in a given
* direction. [-1.0..1.0]
* @param direction The direction the robot should drive. The direction and
* magnitude are independent of the rotation rate.
* @param rotation The rate of rotation for the robot that is completely
* independent of the magnitude or direction. [-1.0..1.0]
*/
void HolonomicDrive(double magnitude, double direction, double rotation);
/**
* Set the speed of the right and left motors.
*
* This is used once an appropriate drive setup function is called such as
* TwoWheelDrive(). The motors are set to "leftOutput" and "rightOutput"
* and includes flipping the direction of one side for opposing motors.
*
* @param leftOutput The speed to send to the left side of the robot.
* @param rightOutput The speed to send to the right side of the robot.
*/
virtual void SetLeftRightMotorOutputs(double leftOutput, double rightOutput);
/*
* Invert a motor direction.
*
* This is used when a motor should run in the opposite direction as the drive
* code would normally run it. Motors that are direct drive would be inverted,
* the Drive code assumes that the motors are geared with one reversal.
*
* @param motor The motor index to invert.
* @param isInverted True if the motor should be inverted when operated.
*/
void SetInvertedMotor(MotorType motor, bool isInverted);
/**
* Set the turning sensitivity.
*
* This only impacts the Drive() entry-point.
*
* @param sensitivity Effectively sets the turning sensitivity (or turn radius
* for a given value)
*/
void SetSensitivity(double sensitivity);
/**
* Configure the scaling factor for using RobotDrive with motor controllers in
* a mode other than PercentVbus.
*
* @param maxOutput Multiplied with the output percentage computed by the
* drive functions.
*/
void SetMaxOutput(double maxOutput);
void StopMotor() override;
void GetDescription(wpi::raw_ostream& desc) const override;
protected:
/**
* Common function to initialize all the robot drive constructors.
*
* Create a motor safety object (the real reason for the common code) and
* initialize all the motor assignments. The default timeout is set for the
* robot drive.
*/
void InitRobotDrive();
/**
* Limit motor values to the -1.0 to +1.0 range.
*/
double Limit(double number);
/**
* Normalize all wheel speeds if the magnitude of any wheel is greater than
* 1.0.
*/
void Normalize(double* wheelSpeeds);
/**
* Rotate a vector in Cartesian space.
*/
void RotateVector(double& x, double& y, double angle);
static constexpr int kMaxNumberOfMotors = 4;
double m_sensitivity = 0.5;
double m_maxOutput = 1.0;
std::shared_ptr<SpeedController> m_frontLeftMotor;
std::shared_ptr<SpeedController> m_frontRightMotor;
std::shared_ptr<SpeedController> m_rearLeftMotor;
std::shared_ptr<SpeedController> m_rearRightMotor;
private:
int GetNumMotors() {
int motors = 0;
if (m_frontLeftMotor) {
motors++;
}
if (m_frontRightMotor) {
motors++;
}
if (m_rearLeftMotor) {
motors++;
}
if (m_rearRightMotor) {
motors++;
}
return motors;
}
};
} // namespace frc

View File

@@ -13,8 +13,6 @@
#include <wpi/ArrayRef.h>
#include <wpi/deprecated.h>
#include "frc/ErrorBase.h"
namespace frc {
class DigitalSource;
@@ -26,7 +24,7 @@ class DigitalSource;
* It probably should not be used directly.
*
*/
class SPI : public ErrorBase {
class SPI {
public:
enum Port { kOnboardCS0 = 0, kOnboardCS1, kOnboardCS2, kOnboardCS3, kMXP };
@@ -37,7 +35,7 @@ class SPI : public ErrorBase {
*/
explicit SPI(Port port);
~SPI() override;
~SPI();
SPI(SPI&&) = default;
SPI& operator=(SPI&&) = default;

View File

@@ -11,8 +11,6 @@
#include <wpi/Twine.h>
#include <wpi/deprecated.h>
#include "frc/ErrorBase.h"
namespace frc {
/**
@@ -27,7 +25,7 @@ namespace frc {
* and the NI-VISA Programmer's Reference Manual here:
* http://www.ni.com/pdf/manuals/370132c.pdf
*/
class SerialPort : public ErrorBase {
class SerialPort {
public:
enum Parity {
kParity_None = 0,
@@ -88,7 +86,7 @@ class SerialPort : public ErrorBase {
int dataBits = 8, Parity parity = kParity_None,
StopBits stopBits = kStopBits_One);
~SerialPort() override;
~SerialPort();
SerialPort(SerialPort&& rhs) = default;
SerialPort& operator=(SerialPort&& rhs) = default;

View File

@@ -5,7 +5,6 @@
#pragma once
#include "frc/PWM.h"
#include "frc/SpeedController.h"
namespace frc {

View File

@@ -4,16 +4,16 @@
#pragma once
#include "frc/ErrorBase.h"
namespace frc {
/**
* SolenoidBase class is the common base class for the Solenoid and
* DoubleSolenoid classes.
*/
class SolenoidBase : public ErrorBase {
class SolenoidBase {
public:
virtual ~SolenoidBase() = default;
/**
* Get the CAN ID of the module this solenoid is connected to.
*

View File

@@ -5,15 +5,14 @@
#pragma once
#include <units/voltage.h>
#include "frc/PIDOutput.h"
#include <wpi/deprecated.h>
namespace frc {
/**
* Interface for speed controlling devices.
*/
class SpeedController : public PIDOutput {
class WPI_DEPRECATED("use MotorController") SpeedController {
public:
virtual ~SpeedController() = default;

View File

@@ -7,15 +7,18 @@
#include <functional>
#include <vector>
#include "frc/SpeedController.h"
#include <wpi/deprecated.h>
#include "frc/motorcontrol/MotorController.h"
#include "frc/smartdashboard/Sendable.h"
#include "frc/smartdashboard/SendableHelper.h"
namespace frc {
class SpeedControllerGroup : public Sendable,
public SpeedController,
public SendableHelper<SpeedControllerGroup> {
class WPI_DEPRECATED("use MotorControllerGroup") SpeedControllerGroup
: public Sendable,
public MotorController,
public SendableHelper<SpeedControllerGroup> {
public:
template <class... SpeedControllers>
explicit SpeedControllerGroup(SpeedController& speedController,
@@ -32,7 +35,6 @@ class SpeedControllerGroup : public Sendable,
bool GetInverted() const override;
void Disable() override;
void StopMotor() override;
void PIDWrite(double output) override;
void InitSendable(SendableBuilder& builder) override;

View File

@@ -14,7 +14,6 @@
#include <wpi/deprecated.h>
#include <wpi/priority_queue.h>
#include "frc/ErrorBase.h"
#include "frc/IterativeRobotBase.h"
#include "frc2/Timer.h"
@@ -29,7 +28,7 @@ namespace frc {
* Periodic() functions from the base class are called on an interval by a
* Notifier instance.
*/
class TimedRobot : public IterativeRobotBase, public ErrorBase {
class TimedRobot : public IterativeRobotBase {
public:
static constexpr units::second_t kDefaultPeriod = 20_ms;
@@ -43,11 +42,6 @@ class TimedRobot : public IterativeRobotBase, public ErrorBase {
*/
void EndCompetition() override;
/**
* Get the time period between calls to Periodic() functions.
*/
units::second_t GetPeriod() const;
/**
* Constructor for TimedRobot.
*

View File

@@ -12,8 +12,6 @@
#include <hal/SimDevice.h>
#include "frc/Counter.h"
#include "frc/ErrorBase.h"
#include "frc/PIDSource.h"
#include "frc/smartdashboard/Sendable.h"
#include "frc/smartdashboard/SendableHelper.h"
@@ -34,13 +32,8 @@ class DigitalOutput;
* received. The time that the line is high determines the round trip distance
* (time of flight).
*/
class Ultrasonic : public ErrorBase,
public Sendable,
public PIDSource,
public SendableHelper<Ultrasonic> {
class Ultrasonic : public Sendable, public SendableHelper<Ultrasonic> {
public:
enum DistanceUnit { kInches = 0, kMilliMeters = 1 };
/**
* Create an instance of the Ultrasonic Sensor.
*
@@ -51,9 +44,8 @@ class Ultrasonic : public ErrorBase,
* @param echoChannel The digital input channel that receives the echo. The
* length of time that the echo is high represents the
* round trip time of the ping, and the distance.
* @param units The units returned in either kInches or kMilliMeters
*/
Ultrasonic(int pingChannel, int echoChannel, DistanceUnit units = kInches);
Ultrasonic(int pingChannel, int echoChannel);
/**
* Create an instance of an Ultrasonic Sensor from a DigitalInput for the echo
@@ -63,10 +55,8 @@ class Ultrasonic : public ErrorBase,
* ping. Requires a 10uS pulse to start.
* @param echoChannel The digital input object that times the return pulse to
* determine the range.
* @param units The units returned in either kInches or kMilliMeters
*/
Ultrasonic(DigitalOutput* pingChannel, DigitalInput* echoChannel,
DistanceUnit units = kInches);
Ultrasonic(DigitalOutput* pingChannel, DigitalInput* echoChannel);
/**
* Create an instance of an Ultrasonic Sensor from a DigitalInput for the echo
@@ -76,10 +66,8 @@ class Ultrasonic : public ErrorBase,
* ping. Requires a 10uS pulse to start.
* @param echoChannel The digital input object that times the return pulse to
* determine the range.
* @param units The units returned in either kInches or kMilliMeters
*/
Ultrasonic(DigitalOutput& pingChannel, DigitalInput& echoChannel,
DistanceUnit units = kInches);
Ultrasonic(DigitalOutput& pingChannel, DigitalInput& echoChannel);
/**
* Create an instance of an Ultrasonic Sensor from a DigitalInput for the echo
@@ -89,11 +77,9 @@ class Ultrasonic : public ErrorBase,
* ping. Requires a 10uS pulse to start.
* @param echoChannel The digital input object that times the return pulse to
* determine the range.
* @param units The units returned in either kInches or kMilliMeters
*/
Ultrasonic(std::shared_ptr<DigitalOutput> pingChannel,
std::shared_ptr<DigitalInput> echoChannel,
DistanceUnit units = kInches);
std::shared_ptr<DigitalInput> echoChannel);
~Ultrasonic() override;
@@ -156,30 +142,6 @@ class Ultrasonic : public ErrorBase,
void SetEnabled(bool enable);
/**
* Set the current DistanceUnit that should be used for the PIDSource base
* object.
*
* @param units The DistanceUnit that should be used.
*/
void SetDistanceUnits(DistanceUnit units);
/**
* Get the current DistanceUnit that is used for the PIDSource base object.
*
* @return The type of DistanceUnit that is being used.
*/
DistanceUnit GetDistanceUnits() const;
/**
* Get the range in the current DistanceUnit for the PIDSource base object.
*
* @return The range in DistanceUnit
*/
double PIDGet() override;
void SetPIDSourceType(PIDSourceType pidSource) override;
void InitSendable(SendableBuilder& builder) override;
private:
@@ -228,7 +190,6 @@ class Ultrasonic : public ErrorBase,
std::shared_ptr<DigitalInput> m_echoChannel;
bool m_enabled = false;
Counter m_counter;
DistanceUnit m_units;
hal::SimDevice m_simDevice;
hal::SimBoolean m_simRangeValid;

View File

@@ -2,18 +2,9 @@
// 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 <stdint.h>
#define S(label, offset, message) \
constexpr inline const char* wpi_error_s_##label() { return message; } \
constexpr inline int wpi_error_value_##label() { return offset; }
// Fatal errors
S(ModuleIndexOutOfRange, -1,
"Allocating module that is out of range or not found")
S(ChannelIndexOutOfRange, -1, "Allocating channel that is out of range")
S(ChannelIndexOutOfRange, -45, "Allocating channel that is out of range")
S(NotAllocated, -2, "Attempting to free unallocated resource")
S(ResourceAlreadyAllocated, -3, "Attempted to reuse an allocated resource")
S(NoAvailableResources, -4, "No available resources to allocate")
@@ -26,13 +17,13 @@ S(IncompatibleMode, -9, "The object is in an incompatible mode")
S(AnalogTriggerLimitOrderError, -10,
"AnalogTrigger limits error. Lower limit > Upper Limit")
S(AnalogTriggerPulseOutputError, -11,
"Attempted to read AnalogTrigger pulse output.")
"Attempted to read AnalogTrigger pulse output")
S(TaskError, -12, "Task can't be started")
S(TaskIDError, -13, "Task error: Invalid ID.")
S(TaskDeletedError, -14, "Task error: Task already deleted.")
S(TaskOptionsError, -15, "Task error: Invalid options.")
S(TaskMemoryError, -16, "Task can't be started due to insufficient memory.")
S(TaskPriorityError, -17, "Task error: Invalid priority [1-255].")
S(TaskIDError, -13, "Task error: Invalid ID")
S(TaskDeletedError, -14, "Task error: Task already deleted")
S(TaskOptionsError, -15, "Task error: Invalid options")
S(TaskMemoryError, -16, "Task can't be started due to insufficient memory")
S(TaskPriorityError, -17, "Task error: Invalid priority [1-255]")
S(DriveUninitialized, -18, "RobotDrive not initialized for the C interface")
S(CompressorNonMatching, -19,
"Compressor slot/channel doesn't match previous instance")
@@ -41,19 +32,19 @@ S(CompressorUndefined, -21,
"Using compressor functions without defining compressor")
S(InconsistentArrayValueAdded, -22,
"When packing data into an array to the dashboard, not all values added were "
"of the same type.")
"of the same type")
S(MismatchedComplexTypeClose, -23,
"When packing data to the dashboard, a Close for a complex type was called "
"without a matching Open.")
"without a matching Open")
S(DashboardDataOverflow, -24,
"When packing data to the dashboard, too much data was packed and the buffer "
"overflowed.")
"overflowed")
S(DashboardDataCollision, -25,
"The same buffer was used for packing data and for printing.")
S(EnhancedIOMissing, -26, "IO is not attached or Enhanced IO is not enabled.")
"The same buffer was used for packing data and for printing")
S(EnhancedIOMissing, -26, "IO is not attached or Enhanced IO is not enabled")
S(LineNotOutput, -27,
"Cannot SetDigitalOutput for a line not configured for output.")
S(ParameterOutOfRange, -28, "A parameter is out of range.")
"Cannot SetDigitalOutput for a line not configured for output")
S(ParameterOutOfRange, -28, "A parameter is out of range")
S(SPIClockRateTooLow, -29, "SPI clock rate was below the minimum supported")
S(JaguarVersionError, -30, "Jaguar firmware version error")
S(JaguarMessageNotFound, -31, "Jaguar message not found")
@@ -62,31 +53,9 @@ S(NetworkTablesBufferFull, -41, "Buffer full writing to NetworkTables socket")
S(NetworkTablesWrongType, -42,
"The wrong type was read from the NetworkTables entry")
S(NetworkTablesCorrupt, -43, "NetworkTables data stream is corrupt")
S(SmartDashboardMissingKey, -43, "SmartDashboard data does not exist")
S(SmartDashboardMissingKey, -44, "SmartDashboard data does not exist")
S(CommandIllegalUse, -50, "Illegal use of Command")
S(UnsupportedInSimulation, -80, "Unsupported in simulation")
S(CameraServerError, -90, "CameraServer error")
S(InvalidParameter, -100, "Invalid parameter value")
// Warnings
S(SampleRateTooHigh, 1, "Analog module sample rate is too high")
S(VoltageOutOfRange, 2,
"Voltage to convert to raw value is out of range [-10; 10]")
S(CompressorTaskError, 3, "Compressor task won't start")
S(LoopTimingError, 4, "Digital module loop timing is not the expected value")
S(NonBinaryDigitalValue, 5, "Digital output value is not 0 or 1")
S(IncorrectBatteryChannel, 6,
"Battery measurement channel is not correct value")
S(BadJoystickIndex, 7, "Joystick index is out of range, should be 0-3")
S(BadJoystickAxis, 8, "Joystick axis or POV is out of range")
S(InvalidMotorIndex, 9, "Motor index is out of range, should be 0-3")
S(DriverStationTaskError, 10, "Driver Station task won't start")
S(EnhancedIOPWMPeriodOutOfRange, 11,
"Driver Station Enhanced IO PWM Output period out of range.")
S(SPIWriteNoMOSI, 12, "Cannot write to SPI port with no MOSI output")
S(SPIReadNoMISO, 13, "Cannot read from SPI port with no MISO input")
S(SPIReadNoData, 14, "No data available to read from SPI")
S(IncompatibleState, 15,
"Incompatible State: The operation cannot be completed")
#undef S
S(AssertionFailure, -110, "Assertion failed")

View File

@@ -1,107 +0,0 @@
// 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
// clang-format off
#ifdef _MSC_VER
#pragma message("warning: Including this header drastically increases compilation times and is bad style. Include only what you use instead.")
#else
#warning "Including this header drastically increases compilation times and is bad style. Include only what you use instead."
#endif
// clang-format on
#if __has_include(<cameraserver/CameraServer.h>)
#include <cameraserver/CameraServer.h>
#include <vision/VisionRunner.h>
#endif
#include "frc/ADXL345_I2C.h"
#include "frc/ADXL345_SPI.h"
#include "frc/ADXL362.h"
#include "frc/ADXRS450_Gyro.h"
#include "frc/AnalogAccelerometer.h"
#include "frc/AnalogGyro.h"
#include "frc/AnalogInput.h"
#include "frc/AnalogOutput.h"
#include "frc/AnalogPotentiometer.h"
#include "frc/AnalogTrigger.h"
#include "frc/AnalogTriggerOutput.h"
#include "frc/BuiltInAccelerometer.h"
#include "frc/Compressor.h"
#include "frc/Counter.h"
#include "frc/DMC60.h"
#include "frc/DigitalInput.h"
#include "frc/DigitalOutput.h"
#include "frc/DigitalSource.h"
#include "frc/DoubleSolenoid.h"
#include "frc/DriverStation.h"
#include "frc/Encoder.h"
#include "frc/ErrorBase.h"
#include "frc/GearTooth.h"
#include "frc/GenericHID.h"
#include "frc/I2C.h"
#include "frc/InterruptableSensorBase.h"
#include "frc/IterativeRobot.h"
#include "frc/Jaguar.h"
#include "frc/Joystick.h"
#include "frc/NidecBrushless.h"
#include "frc/Notifier.h"
#include "frc/PIDController.h"
#include "frc/PIDOutput.h"
#include "frc/PIDSource.h"
#include "frc/PWM.h"
#include "frc/PWMSpeedController.h"
#include "frc/PWMTalonSRX.h"
#include "frc/PWMVictorSPX.h"
#include "frc/PowerDistributionPanel.h"
#include "frc/Preferences.h"
#include "frc/Relay.h"
#include "frc/RobotBase.h"
#include "frc/RobotController.h"
#include "frc/RobotDrive.h"
#include "frc/SD540.h"
#include "frc/SPI.h"
#include "frc/SensorUtil.h"
#include "frc/SerialPort.h"
#include "frc/Servo.h"
#include "frc/Solenoid.h"
#include "frc/Spark.h"
#include "frc/SpeedController.h"
#include "frc/SpeedControllerGroup.h"
#include "frc/Talon.h"
#include "frc/Threads.h"
#include "frc/TimedRobot.h"
#include "frc/Timer.h"
#include "frc/Ultrasonic.h"
#include "frc/Utility.h"
#include "frc/Victor.h"
#include "frc/VictorSP.h"
#include "frc/WPIErrors.h"
#include "frc/XboxController.h"
#if __has_include("frc/buttons/InternalButton.h")
#include "frc/buttons/InternalButton.h"
#include "frc/buttons/JoystickButton.h"
#include "frc/buttons/NetworkButton.h"
#include "frc/commands/Command.h"
#include "frc/commands/CommandGroup.h"
#include "frc/commands/PIDCommand.h"
#include "frc/commands/PIDSubsystem.h"
#include "frc/commands/PrintCommand.h"
#include "frc/commands/StartCommand.h"
#include "frc/commands/Subsystem.h"
#include "frc/commands/WaitCommand.h"
#include "frc/commands/WaitForChildren.h"
#include "frc/commands/WaitUntilCommand.h"
#endif
#include "frc/drive/DifferentialDrive.h"
#include "frc/drive/KilloughDrive.h"
#include "frc/drive/MecanumDrive.h"
#include "frc/filters/LinearDigitalFilter.h"
#include "frc/interfaces/Accelerometer.h"
#include "frc/interfaces/Gyro.h"
#include "frc/interfaces/Potentiometer.h"
#include "frc/smartdashboard/SendableChooser.h"
#include "frc/smartdashboard/SmartDashboard.h"

View File

@@ -0,0 +1,23 @@
// 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.
S(SampleRateTooHigh, 1, "Analog module sample rate is too high")
S(VoltageOutOfRange, 2,
"Voltage to convert to raw value is out of range [-10; 10]")
S(CompressorTaskError, 3, "Compressor task won't start")
S(LoopTimingError, 4, "Digital module loop timing is not the expected value")
S(NonBinaryDigitalValue, 5, "Digital output value is not 0 or 1")
S(IncorrectBatteryChannel, 6,
"Battery measurement channel is not correct value")
S(BadJoystickIndex, 7, "Joystick index is out of range, should be 0-3")
S(BadJoystickAxis, 8, "Joystick axis or POV is out of range")
S(InvalidMotorIndex, 9, "Motor index is out of range, should be 0-3")
S(DriverStationTaskError, 10, "Driver Station task won't start")
S(EnhancedIOPWMPeriodOutOfRange, 11,
"Driver Station Enhanced IO PWM Output period out of range")
S(SPIWriteNoMOSI, 12, "Cannot write to SPI port with no MOSI output")
S(SPIReadNoMISO, 13, "Cannot read from SPI port with no MISO input")
S(SPIReadNoData, 14, "No data available to read from SPI")
S(IncompatibleState, 15,
"Incompatible State: The operation cannot be completed")

View File

@@ -239,3 +239,9 @@ class PIDController : public frc::Sendable,
};
} // namespace frc2
namespace frc {
using frc2::PIDController;
} // namespace frc

View File

@@ -12,6 +12,17 @@
namespace frc {
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable : 4996) // was declared deprecated
#elif defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#elif defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
class SpeedController;
/**
@@ -19,9 +30,9 @@ class SpeedController;
* the Kit of Parts drive base, "tank drive", or West Coast Drive.
*
* These drive bases typically have drop-center / skid-steer with two or more
* wheels per side (e.g., 6WD or 8WD). This class takes a SpeedController per
* wheels per side (e.g., 6WD or 8WD). This class takes a MotorController per
* side. For four and six motor drivetrains, construct and pass in
* SpeedControllerGroup instances as follows.
* MotorControllerGroup instances as follows.
*
* Four motor drivetrain:
* @code{.cpp}
@@ -29,11 +40,11 @@ class SpeedController;
* public:
* frc::PWMVictorSPX m_frontLeft{1};
* frc::PWMVictorSPX m_rearLeft{2};
* frc::SpeedControllerGroup m_left{m_frontLeft, m_rearLeft};
* frc::MotorControllerGroup m_left{m_frontLeft, m_rearLeft};
*
* frc::PWMVictorSPX m_frontRight{3};
* frc::PWMVictorSPX m_rearRight{4};
* frc::SpeedControllerGroup m_right{m_frontRight, m_rearRight};
* frc::MotorControllerGroup m_right{m_frontRight, m_rearRight};
*
* frc::DifferentialDrive m_drive{m_left, m_right};
* };
@@ -46,12 +57,12 @@ class SpeedController;
* frc::PWMVictorSPX m_frontLeft{1};
* frc::PWMVictorSPX m_midLeft{2};
* frc::PWMVictorSPX m_rearLeft{3};
* frc::SpeedControllerGroup m_left{m_frontLeft, m_midLeft, m_rearLeft};
* frc::MotorControllerGroup m_left{m_frontLeft, m_midLeft, m_rearLeft};
*
* frc::PWMVictorSPX m_frontRight{4};
* frc::PWMVictorSPX m_midRight{5};
* frc::PWMVictorSPX m_rearRight{6};
* frc::SpeedControllerGroup m_right{m_frontRight, m_midRight, m_rearRight};
* frc::MotorControllerGroup m_right{m_frontRight, m_midRight, m_rearRight};
*
* frc::DifferentialDrive m_drive{m_left, m_right};
* };
@@ -87,12 +98,12 @@ class SpeedController;
*
* <p>RobotDrive porting guide:
* <br>TankDrive(double, double, bool) is equivalent to
* RobotDrive#TankDrive(double, double, bool) if a deadband of 0 is used.
* RobotDrive's TankDrive(double, double, bool) if a deadband of 0 is used.
* <br>ArcadeDrive(double, double, bool) is equivalent to
* RobotDrive#ArcadeDrive(double, double, bool) if a deadband of 0 is used
* RobotDrive's ArcadeDrive(double, double, bool) if a deadband of 0 is used
* and the the rotation input is inverted eg ArcadeDrive(y, -rotation, false)
* <br>CurvatureDrive(double, double, bool) is similar in concept to
* RobotDrive#Drive(double, double) with the addition of a quick turn
* RobotDrive's Drive(double, double) with the addition of a quick turn
* mode. However, it is not designed to give exactly the same response.
*/
class DifferentialDrive : public RobotDriveBase,
@@ -105,7 +116,7 @@ class DifferentialDrive : public RobotDriveBase,
/**
* Construct a DifferentialDrive.
*
* To pass multiple motors per side, use a SpeedControllerGroup. If a motor
* To pass multiple motors per side, use a MotorControllerGroup. If a motor
* needs to be inverted, do so before passing it in.
*/
DifferentialDrive(SpeedController& leftMotor, SpeedController& rightMotor);
@@ -219,4 +230,12 @@ class DifferentialDrive : public RobotDriveBase,
double m_rightSideInvertMultiplier = -1.0;
};
#if defined(_MSC_VER)
#pragma warning(pop)
#elif defined(__clang__)
#pragma clang diagnostic pop
#elif defined(__GNUC__)
#pragma GCC diagnostic pop
#endif
} // namespace frc

View File

@@ -15,6 +15,17 @@
namespace frc {
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable : 4996) // was declared deprecated
#elif defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#elif defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
class SpeedController;
/**
@@ -140,4 +151,12 @@ class KilloughDrive : public RobotDriveBase,
bool reported = false;
};
#if defined(_MSC_VER)
#pragma warning(pop)
#elif defined(__clang__)
#pragma clang diagnostic pop
#elif defined(__GNUC__)
#pragma GCC diagnostic pop
#endif
} // namespace frc

View File

@@ -14,6 +14,17 @@
namespace frc {
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable : 4996) // was declared deprecated
#elif defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#elif defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
class SpeedController;
/**
@@ -53,12 +64,12 @@ class SpeedController;
* inverted, while in RobotDrive, no speed controllers are automatically
* inverted.
* <br>DriveCartesian(double, double, double, double) is equivalent to
* RobotDrive#MecanumDrive_Cartesian(double, double, double, double)
* RobotDrive's MecanumDrive_Cartesian(double, double, double, double)
* if a deadband of 0 is used, and the ySpeed and gyroAngle values are inverted
* compared to RobotDrive (eg DriveCartesian(xSpeed, -ySpeed, zRotation,
* -gyroAngle).
* <br>DrivePolar(double, double, double) is equivalent to
* RobotDrive#MecanumDrive_Polar(double, double, double) if a
* RobotDrive's MecanumDrive_Polar(double, double, double) if a
* deadband of 0 is used.
*/
class MecanumDrive : public RobotDriveBase,
@@ -145,4 +156,12 @@ class MecanumDrive : public RobotDriveBase,
bool reported = false;
};
#if defined(_MSC_VER)
#pragma warning(pop)
#elif defined(__clang__)
#pragma clang diagnostic pop
#elif defined(__GNUC__)
#pragma GCC diagnostic pop
#endif
} // namespace frc

View File

@@ -13,8 +13,6 @@
namespace frc {
class SpeedController;
/**
* Common base class for drive platforms.
*/

View File

@@ -1,61 +0,0 @@
// 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 <memory>
#include <wpi/deprecated.h>
#include "frc/PIDSource.h"
namespace frc {
/**
* Interface for filters
*
* @deprecated only used by the deprecated LinearDigitalFilter
*/
class Filter : public PIDSource {
public:
WPI_DEPRECATED("This class is no longer used.")
explicit Filter(PIDSource& source);
WPI_DEPRECATED("This class is no longer used.")
explicit Filter(std::shared_ptr<PIDSource> source);
~Filter() override = default;
Filter(Filter&&) = default;
Filter& operator=(Filter&&) = default;
// PIDSource interface
void SetPIDSourceType(PIDSourceType pidSource) override;
PIDSourceType GetPIDSourceType() const override;
double PIDGet() override = 0;
/**
* Returns the current filter estimate without also inserting new data as
* PIDGet() would do.
*
* @return The current filter estimate
*/
virtual double Get() const = 0;
/**
* Reset the filter state
*/
virtual void Reset() = 0;
protected:
/**
* Calls PIDGet() of source
*
* @return Current value of source
*/
double PIDGetSource();
private:
std::shared_ptr<PIDSource> m_source;
};
} // namespace frc

View File

@@ -1,223 +0,0 @@
// 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 <initializer_list>
#include <memory>
#include <vector>
#include <wpi/ArrayRef.h>
#include <wpi/circular_buffer.h>
#include <wpi/deprecated.h>
#include "frc/filters/Filter.h"
namespace frc {
/**
* This class implements a linear, digital filter. All types of FIR and IIR
* filters are supported. Static factory methods are provided to create commonly
* used types of filters.
*
* Filters are of the form:<br>
* y[n] = (b0 * x[n] + b1 * x[n-1] + ... + bP * x[n-P]) -
* (a0 * y[n-1] + a2 * y[n-2] + ... + aQ * y[n-Q])
*
* Where:<br>
* y[n] is the output at time "n"<br>
* x[n] is the input at time "n"<br>
* y[n-1] is the output from the LAST time step ("n-1")<br>
* x[n-1] is the input from the LAST time step ("n-1")<br>
* b0...bP are the "feedforward" (FIR) gains<br>
* a0...aQ are the "feedback" (IIR) gains<br>
* IMPORTANT! Note the "-" sign in front of the feedback term! This is a common
* convention in signal processing.
*
* What can linear filters do? Basically, they can filter, or diminish, the
* effects of undesirable input frequencies. High frequencies, or rapid changes,
* can be indicative of sensor noise or be otherwise undesirable. A "low pass"
* filter smooths out the signal, reducing the impact of these high frequency
* components. Likewise, a "high pass" filter gets rid of slow-moving signal
* components, letting you detect large changes more easily.
*
* Example FRC applications of filters:
* - Getting rid of noise from an analog sensor input (note: the roboRIO's FPGA
* can do this faster in hardware)
* - Smoothing out joystick input to prevent the wheels from slipping or the
* robot from tipping
* - Smoothing motor commands so that unnecessary strain isn't put on
* electrical or mechanical components
* - If you use clever gains, you can make a PID controller out of this class!
*
* For more on filters, I highly recommend the following articles:<br>
* http://en.wikipedia.org/wiki/Linear_filter<br>
* http://en.wikipedia.org/wiki/Iir_filter<br>
* http://en.wikipedia.org/wiki/Fir_filter<br>
*
* Note 1: PIDGet() should be called by the user on a known, regular period.
* You can set up a Notifier to do this (look at the WPILib PIDController
* class), or do it "inline" with code in a periodic function.
*
* Note 2: For ALL filters, gains are necessarily a function of frequency. If
* you make a filter that works well for you at, say, 100Hz, you will most
* definitely need to adjust the gains if you then want to run it at 200Hz!
* Combining this with Note 1 - the impetus is on YOU as a developer to make
* sure PIDGet() gets called at the desired, constant frequency!
*
* @deprecated Use LinearFilter class instead
*/
class LinearDigitalFilter : public Filter {
public:
/**
* Create a linear FIR or IIR filter.
*
* @param source The PIDSource object that is used to get values
* @param ffGains The "feed forward" or FIR gains
* @param fbGains The "feed back" or IIR gains
*/
WPI_DEPRECATED("Use LinearFilter class instead.")
LinearDigitalFilter(PIDSource& source, wpi::ArrayRef<double> ffGains,
wpi::ArrayRef<double> fbGains);
/**
* Create a linear FIR or IIR filter.
*
* @param source The PIDSource object that is used to get values
* @param ffGains The "feed forward" or FIR gains
* @param fbGains The "feed back" or IIR gains
*/
WPI_DEPRECATED("Use LinearFilter class instead.")
LinearDigitalFilter(PIDSource& source, std::initializer_list<double> ffGains,
std::initializer_list<double> fbGains);
/**
* Create a linear FIR or IIR filter.
*
* @param source The PIDSource object that is used to get values
* @param ffGains The "feed forward" or FIR gains
* @param fbGains The "feed back" or IIR gains
*/
WPI_DEPRECATED("Use LinearFilter class instead.")
LinearDigitalFilter(std::shared_ptr<PIDSource> source,
wpi::ArrayRef<double> ffGains,
wpi::ArrayRef<double> fbGains);
/**
* Create a linear FIR or IIR filter.
*
* @param source The PIDSource object that is used to get values
* @param ffGains The "feed forward" or FIR gains
* @param fbGains The "feed back" or IIR gains
*/
WPI_DEPRECATED("Use LinearFilter class instead.")
LinearDigitalFilter(std::shared_ptr<PIDSource> source,
std::initializer_list<double> ffGains,
std::initializer_list<double> fbGains);
LinearDigitalFilter(LinearDigitalFilter&&) = default;
LinearDigitalFilter& operator=(LinearDigitalFilter&&) = default;
// Static methods to create commonly used filters
/**
* Creates a one-pole IIR low-pass filter of the form:<br>
* y[n] = (1 - gain) * x[n] + gain * y[n-1]<br>
* where gain = e<sup>-dt / T</sup>, T is the time constant in seconds
*
* This filter is stable for time constants greater than zero.
*
* @param source The PIDSource object that is used to get values
* @param timeConstant The discrete-time time constant in seconds
* @param period The period in seconds between samples taken by the user
*/
static LinearDigitalFilter SinglePoleIIR(PIDSource& source,
double timeConstant, double period);
/**
* Creates a first-order high-pass filter of the form:<br>
* y[n] = gain * x[n] + (-gain) * x[n-1] + gain * y[n-1]<br>
* where gain = e<sup>-dt / T</sup>, T is the time constant in seconds
*
* This filter is stable for time constants greater than zero.
*
* @param source The PIDSource object that is used to get values
* @param timeConstant The discrete-time time constant in seconds
* @param period The period in seconds between samples taken by the user
*/
static LinearDigitalFilter HighPass(PIDSource& source, double timeConstant,
double period);
/**
* Creates a K-tap FIR moving average filter of the form:<br>
* y[n] = 1/k * (x[k] + x[k-1] + … + x[0])
*
* This filter is always stable.
*
* @param source The PIDSource object that is used to get values
* @param taps The number of samples to average over. Higher = smoother but
* slower
*/
static LinearDigitalFilter MovingAverage(PIDSource& source, int taps);
/**
* Creates a one-pole IIR low-pass filter of the form:<br>
* y[n] = (1 - gain) * x[n] + gain * y[n-1]<br>
* where gain = e<sup>-dt / T</sup>, T is the time constant in seconds
*
* This filter is stable for time constants greater than zero.
*
* @param source The PIDSource object that is used to get values
* @param timeConstant The discrete-time time constant in seconds
* @param period The period in seconds between samples taken by the user
*/
static LinearDigitalFilter SinglePoleIIR(std::shared_ptr<PIDSource> source,
double timeConstant, double period);
/**
* Creates a first-order high-pass filter of the form:<br>
* y[n] = gain * x[n] + (-gain) * x[n-1] + gain * y[n-1]<br>
* where gain = e<sup>-dt / T</sup>, T is the time constant in seconds
*
* This filter is stable for time constants greater than zero.
*
* @param source The PIDSource object that is used to get values
* @param timeConstant The discrete-time time constant in seconds
* @param period The period in seconds between samples taken by the user
*/
static LinearDigitalFilter HighPass(std::shared_ptr<PIDSource> source,
double timeConstant, double period);
/**
* Creates a K-tap FIR moving average filter of the form:<br>
* y[n] = 1/k * (x[k] + x[k-1] + … + x[0])
*
* This filter is always stable.
*
* @param source The PIDSource object that is used to get values
* @param taps The number of samples to average over. Higher = smoother but
* slower
*/
static LinearDigitalFilter MovingAverage(std::shared_ptr<PIDSource> source,
int taps);
// Filter interface
double Get() const override;
void Reset() override;
// PIDSource interface
/**
* Calculates the next value of the filter
*
* @return The filtered value at this step
*/
double PIDGet() override;
private:
wpi::circular_buffer<double> m_inputs;
wpi::circular_buffer<double> m_outputs;
std::vector<double> m_inputGains;
std::vector<double> m_outputGains;
};
} // namespace frc

View File

@@ -1,32 +0,0 @@
// 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/PIDSource.h"
namespace frc {
/**
* Interface for potentiometers.
*/
class Potentiometer : public PIDSource {
public:
Potentiometer() = default;
~Potentiometer() override = default;
Potentiometer(Potentiometer&&) = default;
Potentiometer& operator=(Potentiometer&&) = default;
/**
* Common interface for getting the current value of a potentiometer.
*
* @return The current set speed. Value is between -1.0 and 1.0.
*/
virtual double Get() const = 0;
void SetPIDSourceType(PIDSourceType pidSource) override;
};
} // namespace frc

View File

@@ -29,7 +29,7 @@ class LiveWindow {
* This is a singleton to guarantee that there is only a single instance
* regardless of how many times GetInstance is called.
*/
static LiveWindow* GetInstance();
static LiveWindow& GetInstance();
/**
* Enable telemetry for a single component.
@@ -69,6 +69,7 @@ class LiveWindow {
private:
LiveWindow();
~LiveWindow() = default;
struct Impl;
std::unique_ptr<Impl> m_impl;

View File

@@ -4,12 +4,12 @@
#pragma once
#include "frc/PWMSpeedController.h"
#include "frc/motorcontrol/PWMMotorController.h"
namespace frc {
/**
* Digilent DMC 60 Speed Controller.
* Digilent DMC 60 Motor Controller.
*
* Note that the DMC 60 uses the following bounds for PWM values. These
* values should work reasonably well for most controllers, but if users
@@ -24,7 +24,7 @@ namespace frc {
* \li 1.480ms = the "low end" of the deadband range
* \li 0.997ms = full "reverse"
*/
class DMC60 : public PWMSpeedController {
class DMC60 : public PWMMotorController {
public:
/**
* Constructor for a Digilent DMC 60.

View File

@@ -4,12 +4,12 @@
#pragma once
#include "frc/PWMSpeedController.h"
#include "frc/motorcontrol/PWMMotorController.h"
namespace frc {
/**
* Luminary Micro / Vex Robotics Jaguar Speed Controller with PWM control.
* Luminary Micro / Vex Robotics Jaguar Motor Controller with PWM control.
*
* Note that the Jaguar uses the following bounds for PWM values. These values
* should work reasonably well for most controllers, but if users experience
@@ -24,7 +24,7 @@ namespace frc {
* \li 1.454ms = the "low end" of the deadband range
* \li 0.697ms = full "reverse"
*/
class Jaguar : public PWMSpeedController {
class Jaguar : public PWMMotorController {
public:
/**
* Constructor for a Jaguar connected via PWM.

View File

@@ -0,0 +1,37 @@
// 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 <units/voltage.h>
#include "frc/SpeedController.h"
namespace frc {
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable : 4996) // was declared deprecated
#elif defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#elif defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
/**
* Interface for motor controlling devices.
*/
class MotorController : public SpeedController {};
#if defined(_MSC_VER)
#pragma warning(pop)
#elif defined(__clang__)
#pragma clang diagnostic pop
#elif defined(__GNUC__)
#pragma GCC diagnostic pop
#endif
} // namespace frc

View File

@@ -0,0 +1,47 @@
// 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 <functional>
#include <vector>
#include "frc/motorcontrol/MotorController.h"
#include "frc/smartdashboard/Sendable.h"
#include "frc/smartdashboard/SendableHelper.h"
namespace frc {
class MotorControllerGroup : public Sendable,
public MotorController,
public SendableHelper<MotorControllerGroup> {
public:
template <class... MotorControllers>
explicit MotorControllerGroup(MotorController& motorController,
MotorControllers&... motorControllers);
explicit MotorControllerGroup(
std::vector<std::reference_wrapper<MotorController>>&& motorControllers);
MotorControllerGroup(MotorControllerGroup&&) = default;
MotorControllerGroup& operator=(MotorControllerGroup&&) = default;
void Set(double speed) override;
double Get() const override;
void SetInverted(bool isInverted) override;
bool GetInverted() const override;
void Disable() override;
void StopMotor() override;
void InitSendable(SendableBuilder& builder) override;
private:
bool m_isInverted = false;
std::vector<std::reference_wrapper<MotorController>> m_motorControllers;
void Initialize();
};
} // namespace frc
#include "frc/motorcontrol/MotorControllerGroup.inc"

View File

@@ -0,0 +1,22 @@
// 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 <functional>
#include <vector>
#include "frc/motorcontrol/MotorControllerGroup.h"
namespace frc {
template <class... MotorControllers>
MotorControllerGroup::MotorControllerGroup(
MotorController& motorController, MotorControllers&... motorControllers)
: m_motorControllers(std::vector<std::reference_wrapper<MotorController>>{
motorController, motorControllers...}) {
Initialize();
}
} // namespace frc

View File

@@ -5,10 +5,9 @@
#pragma once
#include "frc/DigitalOutput.h"
#include "frc/ErrorBase.h"
#include "frc/MotorSafety.h"
#include "frc/PWM.h"
#include "frc/SpeedController.h"
#include "frc/motorcontrol/MotorController.h"
#include "frc/smartdashboard/Sendable.h"
#include "frc/smartdashboard/SendableHelper.h"
@@ -19,7 +18,7 @@ class SendableBuilder;
/**
* Nidec Brushless Motor.
*/
class NidecBrushless : public SpeedController,
class NidecBrushless : public MotorController,
public MotorSafety,
public Sendable,
public SendableHelper<NidecBrushless> {
@@ -39,7 +38,7 @@ class NidecBrushless : public SpeedController,
NidecBrushless(NidecBrushless&&) = default;
NidecBrushless& operator=(NidecBrushless&&) = default;
// SpeedController interface
// MotorController interface
/**
* Set the PWM value.
*
@@ -73,14 +72,6 @@ class NidecBrushless : public SpeedController,
*/
void Enable();
// PIDOutput interface
/**
* Write out the PID value as seen in the PIDOutput base object.
*
* @param output Write out the PWM value as was found in the PIDController
*/
void PIDWrite(double output) override;
// MotorSafety interface
void StopMotor() override;
void GetDescription(wpi::raw_ostream& desc) const override;

View File

@@ -4,18 +4,30 @@
#pragma once
#include <wpi/Twine.h>
#include "frc/MotorSafety.h"
#include "frc/PWM.h"
#include "frc/SpeedController.h"
#include "frc/motorcontrol/MotorController.h"
#include "frc/smartdashboard/Sendable.h"
#include "frc/smartdashboard/SendableHelper.h"
namespace wpi {
class raw_ostream;
} // namespace wpi
namespace frc {
/**
* Common base class for all PWM Speed Controllers.
* Common base class for all PWM Motor Controllers.
*/
class PWMSpeedController : public PWM, public SpeedController {
class PWMMotorController : public MotorController,
public MotorSafety,
public Sendable,
public SendableHelper<PWMMotorController> {
public:
PWMSpeedController(PWMSpeedController&&) = default;
PWMSpeedController& operator=(PWMSpeedController&&) = default;
PWMMotorController(PWMMotorController&&) = default;
PWMMotorController& operator=(PWMMotorController&&) = default;
/**
* Set the PWM value.
@@ -30,7 +42,7 @@ class PWMSpeedController : public PWM, public SpeedController {
/**
* Get the recently set value of the PWM. This value is affected by the
* inversion property. If you want the value that is sent directly to the
* SpeedController, use {@link PWM#getSpeed()} instead.
* MotorController, use {@link PWM#getSpeed()} instead.
*
* @return The most recently set value for the PWM between -1.0 and 1.0.
*/
@@ -42,26 +54,26 @@ class PWMSpeedController : public PWM, public SpeedController {
void Disable() override;
// MotorSafety interface
void StopMotor() override;
void GetDescription(wpi::raw_ostream& desc) const override;
/**
* Write out the PID value as seen in the PIDOutput base object.
*
* @param output Write out the PWM value as was found in the PIDController
*/
void PIDWrite(double output) override;
int GetChannel() const;
protected:
/**
* Constructor for a PWM Speed Controller connected via PWM.
* Constructor for a PWM Motor Controller connected via PWM.
*
* @param name Name to use for SendableRegistry
* @param channel The PWM channel that the controller is attached to. 0-9 are
* on-board, 10-19 are on the MXP port
*/
explicit PWMSpeedController(int channel);
PWMMotorController(const wpi::Twine& name, int channel);
void InitSendable(SendableBuilder& builder) override;
PWM m_pwm;
private:
bool m_isInverted = false;
};

View File

@@ -4,12 +4,12 @@
#pragma once
#include "frc/PWMSpeedController.h"
#include "frc/motorcontrol/PWMMotorController.h"
namespace frc {
/**
* REV Robotics SPARK MAX Speed Controller.
* REV Robotics SPARK MAX Motor Controller.
*
* Note that the SPARK MAX uses the following bounds for PWM values. These
* values should work reasonably well for most controllers, but if users
@@ -24,7 +24,7 @@ namespace frc {
* \li 1.460ms = the "low end" of the deadband range
* \li 0.999ms = full "reverse"
*/
class PWMSparkMax : public PWMSpeedController {
class PWMSparkMax : public PWMMotorController {
public:
/**
* Constructor for a SPARK MAX.

View File

@@ -4,12 +4,12 @@
#pragma once
#include "frc/PWMSpeedController.h"
#include "frc/motorcontrol/PWMMotorController.h"
namespace frc {
/**
* Cross the Road Electronics (CTRE) Talon FX Speed Controller with PWM
* Cross the Road Electronics (CTRE) Talon FX Motor Controller with PWM
* control.
*
* Note that the Talon FX uses the following bounds for PWM values. These
@@ -25,7 +25,7 @@ namespace frc {
* \li 1.480ms = the "low end" of the deadband range
* \li 0.997ms = full "reverse"
*/
class PWMTalonFX : public PWMSpeedController {
class PWMTalonFX : public PWMMotorController {
public:
/**
* Construct a Talon FX connected via PWM.

View File

@@ -4,12 +4,12 @@
#pragma once
#include "frc/PWMSpeedController.h"
#include "frc/motorcontrol/PWMMotorController.h"
namespace frc {
/**
* Cross the Road Electronics (CTRE) Talon SRX Speed Controller with PWM
* Cross the Road Electronics (CTRE) Talon SRX Motor Controller with PWM
* control.
*
* Note that the Talon SRX uses the following bounds for PWM values. These
@@ -25,7 +25,7 @@ namespace frc {
* \li 1.480ms = the "low end" of the deadband range
* \li 0.997ms = full "reverse"
*/
class PWMTalonSRX : public PWMSpeedController {
class PWMTalonSRX : public PWMMotorController {
public:
/**
* Construct a Talon SRX connected via PWM.

View File

@@ -4,7 +4,7 @@
#pragma once
#include "frc/PWMSpeedController.h"
#include "frc/motorcontrol/PWMMotorController.h"
namespace frc {
@@ -23,7 +23,7 @@ namespace frc {
* \li 1.480ms = the "low end" of the deadband range
* \li 0.997ms = full "reverse"
*/
class PWMVenom : public PWMSpeedController {
class PWMVenom : public PWMMotorController {
public:
/**
* Construct a Venom connected via PWM.

View File

@@ -4,12 +4,12 @@
#pragma once
#include "frc/PWMSpeedController.h"
#include "frc/motorcontrol/PWMMotorController.h"
namespace frc {
/**
* Cross the Road Electronics (CTRE) Victor SPX Speed Controller with PWM
* Cross the Road Electronics (CTRE) Victor SPX Motor Controller with PWM
* control.
*
* Note that the Victor SPX uses the following bounds for PWM values. These
@@ -25,7 +25,7 @@ namespace frc {
* \li 1.480ms = the "low end" of the deadband range
* \li 0.997ms = full "reverse"
*/
class PWMVictorSPX : public PWMSpeedController {
class PWMVictorSPX : public PWMMotorController {
public:
/**
* Construct a Victor SPX connected via PWM.

View File

@@ -4,12 +4,12 @@
#pragma once
#include "frc/PWMSpeedController.h"
#include "frc/motorcontrol/PWMMotorController.h"
namespace frc {
/**
* Mindsensors SD540 Speed Controller.
* Mindsensors SD540 Motor Controller.
*
* Note that the SD540 uses the following bounds for PWM values. These values
* should work reasonably well for most controllers, but if users experience
@@ -24,7 +24,7 @@ namespace frc {
* \li 1.44ms = the "low end" of the deadband range
* \li 0.94ms = full "reverse"
*/
class SD540 : public PWMSpeedController {
class SD540 : public PWMMotorController {
public:
/**
* Constructor for a SD540.

View File

@@ -4,12 +4,12 @@
#pragma once
#include "frc/PWMSpeedController.h"
#include "frc/motorcontrol/PWMMotorController.h"
namespace frc {
/**
* REV Robotics SPARK Speed Controller.
* REV Robotics SPARK Motor Controller.
*
* Note that the SPARK uses the following bounds for PWM values. These values
* should work reasonably well for most controllers, but if users experience
@@ -24,7 +24,7 @@ namespace frc {
* \li 1.460ms = the "low end" of the deadband range
* \li 0.999ms = full "reverse"
*/
class Spark : public PWMSpeedController {
class Spark : public PWMMotorController {
public:
/**
* Constructor for a SPARK.

View File

@@ -4,12 +4,12 @@
#pragma once
#include "frc/PWMSpeedController.h"
#include "frc/motorcontrol/PWMMotorController.h"
namespace frc {
/**
* Cross the Road Electronics (CTRE) Talon and Talon SR Speed Controller.
* Cross the Road Electronics (CTRE) Talon and Talon SR Motor Controller.
*
* Note that the Talon uses the following bounds for PWM values. These values
* should work reasonably well for most controllers, but if users experience
@@ -24,7 +24,7 @@ namespace frc {
* \li 1.487ms = the "low end" of the deadband range
* \li 0.989ms = full "reverse"
*/
class Talon : public PWMSpeedController {
class Talon : public PWMMotorController {
public:
/**
* Constructor for a Talon (original or Talon SR).

View File

@@ -4,14 +4,14 @@
#pragma once
#include "frc/PWMSpeedController.h"
#include "frc/motorcontrol/PWMMotorController.h"
namespace frc {
/**
* Vex Robotics Victor 888 Speed Controller.
* Vex Robotics Victor 888 Motor Controller.
*
* The Vex Robotics Victor 884 Speed Controller can also be used with this
* The Vex Robotics Victor 884 Motor Controller can also be used with this
* class but may need to be calibrated per the Victor 884 user manual.
*
* Note that the Victor uses the following bounds for PWM values. These
@@ -28,7 +28,7 @@ namespace frc {
* \li 1.490ms = the "low end" of the deadband range
* \li 1.026ms = full "reverse"
*/
class Victor : public PWMSpeedController {
class Victor : public PWMMotorController {
public:
/**
* Constructor for a Victor.

View File

@@ -4,12 +4,12 @@
#pragma once
#include "frc/PWMSpeedController.h"
#include "frc/motorcontrol/PWMMotorController.h"
namespace frc {
/**
* Vex Robotics Victor SP Speed Controller.
* Vex Robotics Victor SP Motor Controller.
*
* Note that the Victor SP uses the following bounds for PWM values. These
* values should work reasonably well for most controllers, but if users
@@ -24,7 +24,7 @@ namespace frc {
* \li 1.480ms = the "low end" of the deadband range
* \li 0.997ms = full "reverse"
*/
class VictorSP : public PWMSpeedController {
class VictorSP : public PWMMotorController {
public:
/**
* Constructor for a Victor SP.

View File

@@ -200,10 +200,10 @@ enum class BuiltInWidgets {
*/
kEncoder,
/**
* Displays a SpeedController.
* Displays a MotorController.
* The speed controller will be controllable from the dashboard when test mode
* is enabled, but will otherwise be view-only. <br>Supported types: <ul>
* <li>PWMSpeedController</li>
* <li>PWMMotorController</li>
* <li>DMC60</li>
* <li>Jaguar</li>
* <li>PWMTalonSRX</li>
@@ -213,7 +213,7 @@ enum class BuiltInWidgets {
* <li>Talon</li>
* <li>Victor</li>
* <li>VictorSP</li>
* <li>SpeedControllerGroup</li>
* <li>MotorControllerGroup</li>
* <li>Any custom subclass of {@code SpeedContorller}</li>
* </ul>
* <br>Custom properties:
@@ -223,7 +223,7 @@ enum class BuiltInWidgets {
* <td>One of {@code ["HORIZONTAL", "VERTICAL"]}</td></tr>
* </table>
*/
kSpeedController,
kMotorController,
/**
* Displays a command with a toggle button. Pressing the button will start the
* command, and the button will automatically release when the command

View File

@@ -16,8 +16,6 @@
#include <wpi/StringMap.h>
#include <wpi/Twine.h>
#include "frc/ErrorBase.h"
#include "frc/WPIErrors.h"
#include "frc/shuffleboard/BuiltInLayouts.h"
#include "frc/shuffleboard/LayoutType.h"
#include "frc/shuffleboard/ShuffleboardComponentBase.h"
@@ -38,8 +36,7 @@ class SimpleWidget;
/**
* Common interface for objects that can contain shuffleboard components.
*/
class ShuffleboardContainer : public virtual ShuffleboardValue,
public ErrorBase {
class ShuffleboardContainer : public virtual ShuffleboardValue {
public:
explicit ShuffleboardContainer(const wpi::Twine& title);

View File

@@ -68,7 +68,7 @@ class MechanismLigament2d : public MechanismObject2d {
void SetLineWeight(double lineWidth);
protected:
void UpdateEntries(std::shared_ptr<NetworkTable> table) override;
void UpdateEntries(std::shared_ptr<nt::NetworkTable> table) override;
private:
void Flush();

View File

@@ -37,7 +37,7 @@ class MechanismObject2d {
*
* @param table the new table.
*/
virtual void UpdateEntries(std::shared_ptr<NetworkTable> table) = 0;
virtual void UpdateEntries(std::shared_ptr<nt::NetworkTable> table) = 0;
mutable wpi::mutex m_mutex;
@@ -82,7 +82,7 @@ class MechanismObject2d {
private:
std::string m_name;
wpi::StringMap<std::unique_ptr<MechanismObject2d>> m_objects;
std::shared_ptr<NetworkTable> m_table;
void Update(std::shared_ptr<NetworkTable> table);
std::shared_ptr<nt::NetworkTable> m_table;
void Update(std::shared_ptr<nt::NetworkTable> table);
};
} // namespace frc

View File

@@ -40,7 +40,7 @@ class MechanismRoot2d : private MechanismObject2d {
using MechanismObject2d::Append;
private:
void UpdateEntries(std::shared_ptr<NetworkTable> table) override;
void UpdateEntries(std::shared_ptr<nt::NetworkTable> table) override;
inline void Flush();
double m_x;
double m_y;

View File

@@ -1,27 +0,0 @@
// 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 <wpi/deprecated.h>
#include "frc/smartdashboard/Sendable.h"
#include "frc/smartdashboard/SendableHelper.h"
namespace frc {
class SendableBase : public Sendable, public SendableHelper<SendableBase> {
public:
/**
* Creates an instance of the sensor base
*
* @deprecated use Sendable and SendableHelper
*
* @param addLiveWindow if true, add this Sendable to LiveWindow
*/
WPI_DEPRECATED("use Sendable and SendableHelper")
explicit SendableBase(bool addLiveWindow = true);
};
} // namespace frc

View File

@@ -285,7 +285,7 @@ class SendableRegistry {
* @param sendableUid sendable unique id
* @param table network table
*/
void Publish(UID sendableUid, std::shared_ptr<NetworkTable> table);
void Publish(UID sendableUid, std::shared_ptr<nt::NetworkTable> table);
/**
* Updates network table information from an object.

View File

@@ -11,16 +11,13 @@
#include <networktables/NetworkTableEntry.h>
#include <networktables/NetworkTableValue.h>
#include "frc/ErrorBase.h"
#include "frc/smartdashboard/ListenerExecutor.h"
#include "frc/smartdashboard/Sendable.h"
#include "frc/smartdashboard/SendableHelper.h"
namespace frc {
class SmartDashboard : public ErrorBase,
public Sendable,
public SendableHelper<SmartDashboard> {
class SmartDashboard : public Sendable, public SendableHelper<SmartDashboard> {
public:
static void init();