mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-27 02:01:42 +00:00
Split Sendable into NT and non-NT portions (#3432)
The non-NT portion has been moved to wpiutil. The NT portion has been moved to ntcore (as NTSendable). SendableBuilder similarly split and moved. SendableRegistry moved to wpiutil. In C++, SendableHelper also moved to wpiutil. This enables use of Sendable from wpimath and also enables moving several classes from wpilib to wpimath.
This commit is contained in:
@@ -5,16 +5,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <hal/SimDevice.h>
|
||||
#include <networktables/NTSendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
#include "frc/I2C.h"
|
||||
#include "frc/interfaces/Accelerometer.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class SendableBuilder;
|
||||
|
||||
/**
|
||||
* ADXL345 Accelerometer on I2C.
|
||||
*
|
||||
@@ -23,8 +21,8 @@ class SendableBuilder;
|
||||
* 0x1D (7-bit address).
|
||||
*/
|
||||
class ADXL345_I2C : public Accelerometer,
|
||||
public Sendable,
|
||||
public SendableHelper<ADXL345_I2C> {
|
||||
public nt::NTSendable,
|
||||
public wpi::SendableHelper<ADXL345_I2C> {
|
||||
public:
|
||||
enum Axes { kAxis_X = 0x00, kAxis_Y = 0x02, kAxis_Z = 0x04 };
|
||||
|
||||
@@ -70,7 +68,7 @@ class ADXL345_I2C : public Accelerometer,
|
||||
*/
|
||||
virtual AllAxes GetAccelerations();
|
||||
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
void InitSendable(nt::NTSendableBuilder& builder) override;
|
||||
|
||||
protected:
|
||||
I2C m_i2c;
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <hal/SimDevice.h>
|
||||
#include <networktables/NTSendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
#include "frc/SPI.h"
|
||||
#include "frc/interfaces/Accelerometer.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -20,8 +20,8 @@ namespace frc {
|
||||
* via SPI. This class assumes the sensor is wired in 4-wire SPI mode.
|
||||
*/
|
||||
class ADXL345_SPI : public Accelerometer,
|
||||
public Sendable,
|
||||
public SendableHelper<ADXL345_SPI> {
|
||||
public nt::NTSendable,
|
||||
public wpi::SendableHelper<ADXL345_SPI> {
|
||||
public:
|
||||
enum Axes { kAxis_X = 0x00, kAxis_Y = 0x02, kAxis_Z = 0x04 };
|
||||
|
||||
@@ -66,7 +66,7 @@ class ADXL345_SPI : public Accelerometer,
|
||||
*/
|
||||
virtual AllAxes GetAccelerations();
|
||||
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
void InitSendable(nt::NTSendableBuilder& builder) override;
|
||||
|
||||
protected:
|
||||
SPI m_spi;
|
||||
|
||||
@@ -5,24 +5,22 @@
|
||||
#pragma once
|
||||
|
||||
#include <hal/SimDevice.h>
|
||||
#include <networktables/NTSendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
#include "frc/SPI.h"
|
||||
#include "frc/interfaces/Accelerometer.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class SendableBuilder;
|
||||
|
||||
/**
|
||||
* ADXL362 SPI Accelerometer.
|
||||
*
|
||||
* This class allows access to an Analog Devices ADXL362 3-axis accelerometer.
|
||||
*/
|
||||
class ADXL362 : public Accelerometer,
|
||||
public Sendable,
|
||||
public SendableHelper<ADXL362> {
|
||||
public nt::NTSendable,
|
||||
public wpi::SendableHelper<ADXL362> {
|
||||
public:
|
||||
enum Axes { kAxis_X = 0x00, kAxis_Y = 0x02, kAxis_Z = 0x04 };
|
||||
struct AllAxes {
|
||||
@@ -74,7 +72,7 @@ class ADXL362 : public Accelerometer,
|
||||
*/
|
||||
virtual AllAxes GetAccelerations();
|
||||
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
void InitSendable(nt::NTSendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
SPI m_spi;
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include <hal/SimDevice.h>
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
#include "frc/SPI.h"
|
||||
#include "frc/interfaces/Gyro.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -29,8 +29,8 @@ namespace frc {
|
||||
* Only one instance of an ADXRS Gyro is supported.
|
||||
*/
|
||||
class ADXRS450_Gyro : public Gyro,
|
||||
public Sendable,
|
||||
public SendableHelper<ADXRS450_Gyro> {
|
||||
public wpi::Sendable,
|
||||
public wpi::SendableHelper<ADXRS450_Gyro> {
|
||||
public:
|
||||
/**
|
||||
* Gyro constructor on onboard CS0.
|
||||
@@ -100,7 +100,7 @@ class ADXRS450_Gyro : public Gyro,
|
||||
*/
|
||||
int GetPort() const;
|
||||
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
SPI m_spi;
|
||||
|
||||
@@ -6,14 +6,13 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
#include "frc/AnalogInput.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class SendableBuilder;
|
||||
|
||||
/**
|
||||
* Handle operation of an analog accelerometer.
|
||||
*
|
||||
@@ -21,8 +20,8 @@ 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 Sendable,
|
||||
public SendableHelper<AnalogAccelerometer> {
|
||||
class AnalogAccelerometer : public wpi::Sendable,
|
||||
public wpi::SendableHelper<AnalogAccelerometer> {
|
||||
public:
|
||||
/**
|
||||
* Create a new instance of an accelerometer.
|
||||
@@ -93,7 +92,7 @@ class AnalogAccelerometer : public Sendable,
|
||||
*/
|
||||
void SetZero(double zero);
|
||||
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
/**
|
||||
|
||||
@@ -9,11 +9,11 @@
|
||||
#include <hal/SimDevice.h>
|
||||
#include <hal/Types.h>
|
||||
#include <units/angle.h>
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
#include "frc/AnalogTrigger.h"
|
||||
#include "frc/Counter.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
class AnalogInput;
|
||||
@@ -21,7 +21,8 @@ class AnalogInput;
|
||||
/**
|
||||
* Class for supporting continuous analog encoders, such as the US Digital MA3.
|
||||
*/
|
||||
class AnalogEncoder : public Sendable, public SendableHelper<AnalogEncoder> {
|
||||
class AnalogEncoder : public wpi::Sendable,
|
||||
public wpi::SendableHelper<AnalogEncoder> {
|
||||
public:
|
||||
/**
|
||||
* Construct a new AnalogEncoder attached to a specific AnalogIn channel.
|
||||
@@ -116,7 +117,7 @@ class AnalogEncoder : public Sendable, public SendableHelper<AnalogEncoder> {
|
||||
*/
|
||||
int GetChannel() const;
|
||||
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
void Init();
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
#include <memory>
|
||||
|
||||
#include <hal/Types.h>
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
#include "frc/interfaces/Gyro.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -30,8 +30,8 @@ class AnalogInput;
|
||||
* This class is for gyro sensors that connect to an analog input.
|
||||
*/
|
||||
class AnalogGyro : public Gyro,
|
||||
public Sendable,
|
||||
public SendableHelper<AnalogGyro> {
|
||||
public wpi::Sendable,
|
||||
public wpi::SendableHelper<AnalogGyro> {
|
||||
public:
|
||||
static constexpr int kOversampleBits = 10;
|
||||
static constexpr int kAverageBits = 0;
|
||||
@@ -192,7 +192,7 @@ class AnalogGyro : public Gyro,
|
||||
*/
|
||||
std::shared_ptr<AnalogInput> GetAnalogInput() const;
|
||||
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
|
||||
protected:
|
||||
std::shared_ptr<AnalogInput> m_analog;
|
||||
|
||||
@@ -7,13 +7,11 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include <hal/Types.h>
|
||||
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
namespace frc {
|
||||
|
||||
class SendableBuilder;
|
||||
class DMA;
|
||||
class DMASample;
|
||||
|
||||
@@ -29,7 +27,8 @@ class DMASample;
|
||||
* are divided by the number of samples to retain the resolution, but get more
|
||||
* stable values.
|
||||
*/
|
||||
class AnalogInput : public Sendable, public SendableHelper<AnalogInput> {
|
||||
class AnalogInput : public wpi::Sendable,
|
||||
public wpi::SendableHelper<AnalogInput> {
|
||||
friend class AnalogTrigger;
|
||||
friend class AnalogGyro;
|
||||
friend class DMA;
|
||||
@@ -282,7 +281,7 @@ class AnalogInput : public Sendable, public SendableHelper<AnalogInput> {
|
||||
*/
|
||||
void SetSimDevice(HAL_SimDeviceHandle device);
|
||||
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
int m_channel;
|
||||
|
||||
@@ -5,18 +5,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <hal/Types.h>
|
||||
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
namespace frc {
|
||||
|
||||
class SendableBuilder;
|
||||
|
||||
/**
|
||||
* MXP analog output class.
|
||||
*/
|
||||
class AnalogOutput : public Sendable, public SendableHelper<AnalogOutput> {
|
||||
class AnalogOutput : public wpi::Sendable,
|
||||
public wpi::SendableHelper<AnalogOutput> {
|
||||
public:
|
||||
/**
|
||||
* Construct an analog output on the given channel.
|
||||
@@ -51,7 +49,7 @@ class AnalogOutput : public Sendable, public SendableHelper<AnalogOutput> {
|
||||
*/
|
||||
int GetChannel() const;
|
||||
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
|
||||
protected:
|
||||
int m_channel;
|
||||
|
||||
@@ -6,22 +6,21 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
#include "frc/AnalogInput.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class SendableBuilder;
|
||||
|
||||
/**
|
||||
* Class for reading analog potentiometers. Analog potentiometers read in an
|
||||
* analog voltage that corresponds to a position. The position is in whichever
|
||||
* units you choose, by way of the scaling and offset constants passed to the
|
||||
* constructor.
|
||||
*/
|
||||
class AnalogPotentiometer : public Sendable,
|
||||
public SendableHelper<AnalogPotentiometer> {
|
||||
class AnalogPotentiometer : public wpi::Sendable,
|
||||
public wpi::SendableHelper<AnalogPotentiometer> {
|
||||
public:
|
||||
/**
|
||||
* Construct an Analog Potentiometer object from a channel number.
|
||||
@@ -103,7 +102,7 @@ class AnalogPotentiometer : public Sendable,
|
||||
*/
|
||||
double Get() const;
|
||||
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<AnalogInput> m_analog_input;
|
||||
|
||||
@@ -7,18 +7,18 @@
|
||||
#include <memory>
|
||||
|
||||
#include <hal/Types.h>
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
#include "frc/AnalogTriggerOutput.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class AnalogInput;
|
||||
class DutyCycle;
|
||||
class SendableBuilder;
|
||||
|
||||
class AnalogTrigger : public Sendable, public SendableHelper<AnalogTrigger> {
|
||||
class AnalogTrigger : public wpi::Sendable,
|
||||
public wpi::SendableHelper<AnalogTrigger> {
|
||||
friend class AnalogTriggerOutput;
|
||||
|
||||
public:
|
||||
@@ -148,7 +148,7 @@ class AnalogTrigger : public Sendable, public SendableHelper<AnalogTrigger> {
|
||||
std::shared_ptr<AnalogTriggerOutput> CreateOutput(
|
||||
AnalogTriggerType type) const;
|
||||
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
int GetSourceChannel() const;
|
||||
|
||||
@@ -4,9 +4,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
#include "frc/DigitalSource.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -44,8 +45,8 @@ class AnalogTrigger;
|
||||
* may help with this, but rotational speeds of the sensor will then be limited.
|
||||
*/
|
||||
class AnalogTriggerOutput : public DigitalSource,
|
||||
public Sendable,
|
||||
public SendableHelper<AnalogTriggerOutput> {
|
||||
public wpi::Sendable,
|
||||
public wpi::SendableHelper<AnalogTriggerOutput> {
|
||||
friend class AnalogTrigger;
|
||||
|
||||
public:
|
||||
@@ -77,7 +78,7 @@ class AnalogTriggerOutput : public DigitalSource,
|
||||
*/
|
||||
int GetChannel() const override;
|
||||
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
|
||||
protected:
|
||||
/**
|
||||
|
||||
@@ -4,22 +4,21 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
#include "frc/interfaces/Accelerometer.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class SendableBuilder;
|
||||
|
||||
/**
|
||||
* Built-in accelerometer.
|
||||
*
|
||||
* This class allows access to the roboRIO's internal accelerometer.
|
||||
*/
|
||||
class BuiltInAccelerometer : public Accelerometer,
|
||||
public Sendable,
|
||||
public SendableHelper<BuiltInAccelerometer> {
|
||||
public wpi::Sendable,
|
||||
public wpi::SendableHelper<BuiltInAccelerometer> {
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -56,7 +55,7 @@ class BuiltInAccelerometer : public Accelerometer,
|
||||
*/
|
||||
double GetZ() override;
|
||||
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
@@ -8,16 +8,15 @@
|
||||
|
||||
#include <hal/Types.h>
|
||||
#include <units/time.h>
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
#include "frc/AnalogTrigger.h"
|
||||
#include "frc/CounterBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class DigitalGlitchFilter;
|
||||
class SendableBuilder;
|
||||
class DMA;
|
||||
class DMASample;
|
||||
|
||||
@@ -32,8 +31,8 @@ class DMASample;
|
||||
* to be zeroed before use.
|
||||
*/
|
||||
class Counter : public CounterBase,
|
||||
public Sendable,
|
||||
public SendableHelper<Counter> {
|
||||
public wpi::Sendable,
|
||||
public wpi::SendableHelper<Counter> {
|
||||
friend class DMA;
|
||||
friend class DMASample;
|
||||
|
||||
@@ -421,7 +420,7 @@ class Counter : public CounterBase,
|
||||
*/
|
||||
bool GetDirection() const override;
|
||||
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
|
||||
protected:
|
||||
// Makes the counter count up.
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
#include <array>
|
||||
|
||||
#include <wpi/mutex.h>
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
#include "frc/DigitalSource.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -26,8 +26,8 @@ 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 Sendable,
|
||||
public SendableHelper<DigitalGlitchFilter> {
|
||||
class DigitalGlitchFilter : public wpi::Sendable,
|
||||
public wpi::SendableHelper<DigitalGlitchFilter> {
|
||||
public:
|
||||
DigitalGlitchFilter();
|
||||
~DigitalGlitchFilter() override;
|
||||
@@ -114,7 +114,7 @@ class DigitalGlitchFilter : public Sendable,
|
||||
*/
|
||||
uint64_t GetPeriodNanoSeconds();
|
||||
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
// Sets the filter for the input to be the requested index. A value of 0
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
#include "frc/DigitalSource.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class DigitalGlitchFilter;
|
||||
class SendableBuilder;
|
||||
|
||||
/**
|
||||
* Class to read a digital input.
|
||||
@@ -23,8 +23,8 @@ class SendableBuilder;
|
||||
* implemented anywhere else.
|
||||
*/
|
||||
class DigitalInput : public DigitalSource,
|
||||
public Sendable,
|
||||
public SendableHelper<DigitalInput> {
|
||||
public wpi::Sendable,
|
||||
public wpi::SendableHelper<DigitalInput> {
|
||||
public:
|
||||
/**
|
||||
* Create an instance of a Digital Input class.
|
||||
@@ -75,7 +75,7 @@ class DigitalInput : public DigitalSource,
|
||||
*/
|
||||
void SetSimDevice(HAL_SimDeviceHandle device);
|
||||
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
int m_channel;
|
||||
|
||||
@@ -5,15 +5,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <hal/Types.h>
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
#include "frc/DigitalSource.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class SendableBuilder;
|
||||
|
||||
/**
|
||||
* Class to write to digital outputs.
|
||||
*
|
||||
@@ -22,8 +20,8 @@ class SendableBuilder;
|
||||
* shouldn't be done here.
|
||||
*/
|
||||
class DigitalOutput : public DigitalSource,
|
||||
public Sendable,
|
||||
public SendableHelper<DigitalOutput> {
|
||||
public wpi::Sendable,
|
||||
public wpi::SendableHelper<DigitalOutput> {
|
||||
public:
|
||||
/**
|
||||
* Create an instance of a digital output.
|
||||
@@ -145,7 +143,7 @@ class DigitalOutput : public DigitalSource,
|
||||
*/
|
||||
void SetSimDevice(HAL_SimDeviceHandle device);
|
||||
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
int m_channel;
|
||||
|
||||
@@ -7,15 +7,13 @@
|
||||
#include <memory>
|
||||
|
||||
#include <hal/Types.h>
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
#include "frc/PneumaticsBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class SendableBuilder;
|
||||
|
||||
/**
|
||||
* DoubleSolenoid class for running 2 channels of high voltage Digital Output
|
||||
* (PCM).
|
||||
@@ -23,7 +21,8 @@ class SendableBuilder;
|
||||
* The DoubleSolenoid class is typically used for pneumatics solenoids that
|
||||
* have two positions controlled by two separate channels.
|
||||
*/
|
||||
class DoubleSolenoid : public Sendable, public SendableHelper<DoubleSolenoid> {
|
||||
class DoubleSolenoid : public wpi::Sendable,
|
||||
public wpi::SendableHelper<DoubleSolenoid> {
|
||||
public:
|
||||
enum Value { kOff, kForward, kReverse };
|
||||
|
||||
@@ -98,7 +97,7 @@ class DoubleSolenoid : public Sendable, public SendableHelper<DoubleSolenoid> {
|
||||
*/
|
||||
bool IsRevSolenoidDisabled() const;
|
||||
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
int m_forwardChannel; // The forward channel on the module to control.
|
||||
|
||||
@@ -7,9 +7,8 @@
|
||||
#include <memory>
|
||||
|
||||
#include <hal/Types.h>
|
||||
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
namespace frc {
|
||||
class DigitalSource;
|
||||
@@ -28,7 +27,7 @@ class DMASample;
|
||||
* order to implement rollover checking.
|
||||
*
|
||||
*/
|
||||
class DutyCycle : public Sendable, public SendableHelper<DutyCycle> {
|
||||
class DutyCycle : public wpi::Sendable, public wpi::SendableHelper<DutyCycle> {
|
||||
friend class AnalogTrigger;
|
||||
friend class DMA;
|
||||
friend class DMASample;
|
||||
@@ -119,7 +118,7 @@ class DutyCycle : public Sendable, public SendableHelper<DutyCycle> {
|
||||
int GetSourceChannel() const;
|
||||
|
||||
protected:
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
void InitDutyCycle();
|
||||
|
||||
@@ -9,11 +9,11 @@
|
||||
#include <hal/SimDevice.h>
|
||||
#include <hal/Types.h>
|
||||
#include <units/angle.h>
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
#include "frc/AnalogTrigger.h"
|
||||
#include "frc/Counter.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
class DutyCycle;
|
||||
@@ -24,8 +24,8 @@ class DigitalSource;
|
||||
* PWM Output, the CTRE Mag Encoder, the Rev Hex Encoder, and the AM Mag
|
||||
* Encoder.
|
||||
*/
|
||||
class DutyCycleEncoder : public Sendable,
|
||||
public SendableHelper<DutyCycleEncoder> {
|
||||
class DutyCycleEncoder : public wpi::Sendable,
|
||||
public wpi::SendableHelper<DutyCycleEncoder> {
|
||||
public:
|
||||
/**
|
||||
* Construct a new DutyCycleEncoder on a specific channel.
|
||||
@@ -163,7 +163,7 @@ class DutyCycleEncoder : public Sendable,
|
||||
*/
|
||||
int GetSourceChannel() const;
|
||||
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
void Init();
|
||||
|
||||
@@ -7,17 +7,16 @@
|
||||
#include <memory>
|
||||
|
||||
#include <hal/Types.h>
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
#include "frc/Counter.h"
|
||||
#include "frc/CounterBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class DigitalSource;
|
||||
class DigitalGlitchFilter;
|
||||
class SendableBuilder;
|
||||
class DMA;
|
||||
class DMASample;
|
||||
|
||||
@@ -37,8 +36,8 @@ class DMASample;
|
||||
* to be zeroed before use.
|
||||
*/
|
||||
class Encoder : public CounterBase,
|
||||
public Sendable,
|
||||
public SendableHelper<Encoder> {
|
||||
public wpi::Sendable,
|
||||
public wpi::SendableHelper<Encoder> {
|
||||
friend class DMA;
|
||||
friend class DMASample;
|
||||
|
||||
@@ -340,7 +339,7 @@ class Encoder : public CounterBase,
|
||||
|
||||
int GetFPGAIndex() const;
|
||||
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
/**
|
||||
|
||||
@@ -7,13 +7,11 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include <hal/Types.h>
|
||||
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
namespace frc {
|
||||
class AddressableLED;
|
||||
class SendableBuilder;
|
||||
|
||||
/**
|
||||
* Class implements the PWM generation in the FPGA.
|
||||
@@ -32,7 +30,7 @@ class SendableBuilder;
|
||||
* - 1 = minimum pulse width (currently 0.5ms)
|
||||
* - 0 = disabled (i.e. PWM output is held low)
|
||||
*/
|
||||
class PWM : public Sendable, public SendableHelper<PWM> {
|
||||
class PWM : public wpi::Sendable, public wpi::SendableHelper<PWM> {
|
||||
public:
|
||||
friend class AddressableLED;
|
||||
/**
|
||||
@@ -224,7 +222,7 @@ class PWM : public Sendable, public SendableHelper<PWM> {
|
||||
int GetChannel() const;
|
||||
|
||||
protected:
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
int m_channel;
|
||||
|
||||
@@ -5,20 +5,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <hal/Types.h>
|
||||
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
namespace frc {
|
||||
|
||||
class SendableBuilder;
|
||||
|
||||
/**
|
||||
* Class for getting voltage, current, temperature, power and energy from the
|
||||
* CAN PDP.
|
||||
*/
|
||||
class PowerDistributionPanel : public Sendable,
|
||||
public SendableHelper<PowerDistributionPanel> {
|
||||
class PowerDistributionPanel
|
||||
: public wpi::Sendable,
|
||||
public wpi::SendableHelper<PowerDistributionPanel> {
|
||||
public:
|
||||
/**
|
||||
* Constructs a PowerDistributionPanel.
|
||||
@@ -96,7 +94,7 @@ class PowerDistributionPanel : public Sendable,
|
||||
*/
|
||||
int GetModule() const;
|
||||
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
hal::Handle<HAL_PDPHandle> m_handle;
|
||||
|
||||
@@ -8,15 +8,13 @@
|
||||
#include <string>
|
||||
|
||||
#include <hal/Types.h>
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
#include "frc/MotorSafety.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class SendableBuilder;
|
||||
|
||||
/**
|
||||
* Class for Spike style relay outputs.
|
||||
*
|
||||
@@ -30,8 +28,8 @@ class SendableBuilder;
|
||||
* a solenoid).
|
||||
*/
|
||||
class Relay : public MotorSafety,
|
||||
public Sendable,
|
||||
public SendableHelper<Relay> {
|
||||
public wpi::Sendable,
|
||||
public wpi::SendableHelper<Relay> {
|
||||
public:
|
||||
enum Value { kOff, kOn, kForward, kReverse };
|
||||
enum Direction { kBothDirections, kForwardOnly, kReverseOnly };
|
||||
@@ -93,7 +91,7 @@ class Relay : public MotorSafety,
|
||||
|
||||
std::string GetDescription() const override;
|
||||
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
int m_channel;
|
||||
|
||||
@@ -92,7 +92,7 @@ class Servo : public PWM {
|
||||
*/
|
||||
double GetMinAngle() const;
|
||||
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
double GetServoAngleRange() const;
|
||||
|
||||
@@ -8,22 +8,20 @@
|
||||
|
||||
#include <hal/Types.h>
|
||||
#include <units/time.h>
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
#include "frc/PneumaticsBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class SendableBuilder;
|
||||
|
||||
/**
|
||||
* Solenoid class for running high voltage Digital Output (PCM).
|
||||
*
|
||||
* The Solenoid class is typically used for pneumatics solenoids, but could be
|
||||
* used for any device within the current spec of the PCM.
|
||||
*/
|
||||
class Solenoid : public Sendable, public SendableHelper<Solenoid> {
|
||||
class Solenoid : public wpi::Sendable, public wpi::SendableHelper<Solenoid> {
|
||||
public:
|
||||
Solenoid(PneumaticsBase& module, int channel);
|
||||
Solenoid(PneumaticsBase* module, int channel);
|
||||
@@ -93,7 +91,7 @@ class Solenoid : public Sendable, public SendableHelper<Solenoid> {
|
||||
*/
|
||||
void StartPulse();
|
||||
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<PneumaticsBase> m_module;
|
||||
|
||||
@@ -8,17 +8,17 @@
|
||||
#include <vector>
|
||||
|
||||
#include <wpi/deprecated.h>
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
#include "frc/motorcontrol/MotorController.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class WPI_DEPRECATED("use MotorControllerGroup") SpeedControllerGroup
|
||||
: public Sendable,
|
||||
: public wpi::Sendable,
|
||||
public MotorController,
|
||||
public SendableHelper<SpeedControllerGroup> {
|
||||
public wpi::SendableHelper<SpeedControllerGroup> {
|
||||
public:
|
||||
template <class... SpeedControllers>
|
||||
explicit SpeedControllerGroup(SpeedController& speedController,
|
||||
@@ -36,7 +36,7 @@ class WPI_DEPRECATED("use MotorControllerGroup") SpeedControllerGroup
|
||||
void Disable() override;
|
||||
void StopMotor() override;
|
||||
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
bool m_isInverted = false;
|
||||
|
||||
@@ -13,10 +13,10 @@
|
||||
#include <units/length.h>
|
||||
#include <units/time.h>
|
||||
#include <units/velocity.h>
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
#include "frc/Counter.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -35,7 +35,8 @@ class DigitalOutput;
|
||||
* received. The time that the line is high determines the round trip distance
|
||||
* (time of flight).
|
||||
*/
|
||||
class Ultrasonic : public Sendable, public SendableHelper<Ultrasonic> {
|
||||
class Ultrasonic : public wpi::Sendable,
|
||||
public wpi::SendableHelper<Ultrasonic> {
|
||||
public:
|
||||
/**
|
||||
* Create an instance of the Ultrasonic Sensor.
|
||||
@@ -136,7 +137,7 @@ class Ultrasonic : public Sendable, public SendableHelper<Ultrasonic> {
|
||||
|
||||
void SetEnabled(bool enable);
|
||||
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
/**
|
||||
|
||||
@@ -8,17 +8,16 @@
|
||||
#include <limits>
|
||||
|
||||
#include <units/time.h>
|
||||
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
namespace frc2 {
|
||||
|
||||
/**
|
||||
* Implements a PID control loop.
|
||||
*/
|
||||
class PIDController : public frc::Sendable,
|
||||
public frc::SendableHelper<PIDController> {
|
||||
class PIDController : public wpi::Sendable,
|
||||
public wpi::SendableHelper<PIDController> {
|
||||
public:
|
||||
/**
|
||||
* Allocates a PIDController with the given constants for Kp, Ki, and Kd.
|
||||
@@ -193,7 +192,7 @@ class PIDController : public frc::Sendable,
|
||||
*/
|
||||
void Reset();
|
||||
|
||||
void InitSendable(frc::SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
// Factor for "proportional" control
|
||||
|
||||
@@ -10,12 +10,12 @@
|
||||
#include <limits>
|
||||
|
||||
#include <units/time.h>
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableBuilder.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
#include "frc/MathUtil.h"
|
||||
#include "frc/controller/PIDController.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableBuilder.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
#include "frc/trajectory/TrapezoidProfile.h"
|
||||
|
||||
namespace frc {
|
||||
@@ -29,8 +29,8 @@ void ReportProfiledPIDController();
|
||||
*/
|
||||
template <class Distance>
|
||||
class ProfiledPIDController
|
||||
: public Sendable,
|
||||
public SendableHelper<ProfiledPIDController<Distance>> {
|
||||
: public wpi::Sendable,
|
||||
public wpi::SendableHelper<ProfiledPIDController<Distance>> {
|
||||
public:
|
||||
using Distance_t = units::unit_t<Distance>;
|
||||
using Velocity =
|
||||
@@ -340,7 +340,7 @@ class ProfiledPIDController
|
||||
Reset(measuredPosition, Velocity_t(0));
|
||||
}
|
||||
|
||||
void InitSendable(frc::SendableBuilder& builder) override {
|
||||
void InitSendable(wpi::SendableBuilder& builder) override {
|
||||
builder.SetSmartDashboardType("ProfiledPIDController");
|
||||
builder.AddDoubleProperty(
|
||||
"p", [this] { return GetP(); }, [this](double value) { SetP(value); });
|
||||
|
||||
@@ -6,9 +6,10 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
#include "frc/drive/RobotDriveBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -97,8 +98,8 @@ class SpeedController;
|
||||
* with SetDeadband().
|
||||
*/
|
||||
class DifferentialDrive : public RobotDriveBase,
|
||||
public Sendable,
|
||||
public SendableHelper<DifferentialDrive> {
|
||||
public wpi::Sendable,
|
||||
public wpi::SendableHelper<DifferentialDrive> {
|
||||
public:
|
||||
struct WheelSpeeds {
|
||||
double left = 0.0;
|
||||
@@ -208,7 +209,7 @@ class DifferentialDrive : public RobotDriveBase,
|
||||
void StopMotor() override;
|
||||
std::string GetDescription() const override;
|
||||
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
SpeedController* m_leftMotor;
|
||||
|
||||
@@ -7,10 +7,11 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
#include "frc/drive/RobotDriveBase.h"
|
||||
#include "frc/drive/Vector2d.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -54,8 +55,8 @@ class SpeedController;
|
||||
* clockwise rotation around the Z axis is positive.
|
||||
*/
|
||||
class KilloughDrive : public RobotDriveBase,
|
||||
public Sendable,
|
||||
public SendableHelper<KilloughDrive> {
|
||||
public wpi::Sendable,
|
||||
public wpi::SendableHelper<KilloughDrive> {
|
||||
public:
|
||||
static constexpr double kDefaultLeftMotorAngle = 60.0;
|
||||
static constexpr double kDefaultRightMotorAngle = 120.0;
|
||||
@@ -160,7 +161,7 @@ class KilloughDrive : public RobotDriveBase,
|
||||
void StopMotor() override;
|
||||
std::string GetDescription() const override;
|
||||
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
SpeedController* m_leftMotor;
|
||||
|
||||
@@ -7,9 +7,10 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
#include "frc/drive/RobotDriveBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -72,8 +73,8 @@ class SpeedController;
|
||||
* deadband of 0 is used.
|
||||
*/
|
||||
class MecanumDrive : public RobotDriveBase,
|
||||
public Sendable,
|
||||
public SendableHelper<MecanumDrive> {
|
||||
public wpi::Sendable,
|
||||
public wpi::SendableHelper<MecanumDrive> {
|
||||
public:
|
||||
struct WheelSpeeds {
|
||||
double frontLeft = 0.0;
|
||||
@@ -150,7 +151,7 @@ class MecanumDrive : public RobotDriveBase,
|
||||
void StopMotor() override;
|
||||
std::string GetDescription() const override;
|
||||
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
SpeedController* m_frontLeftMotor;
|
||||
|
||||
@@ -7,9 +7,11 @@
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
namespace frc {
|
||||
|
||||
namespace wpi {
|
||||
class Sendable;
|
||||
} // namespace wpi
|
||||
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
* The LiveWindow class is the public interface for putting sensors and
|
||||
@@ -36,14 +38,14 @@ class LiveWindow {
|
||||
*
|
||||
* @param sendable component
|
||||
*/
|
||||
void EnableTelemetry(Sendable* component);
|
||||
void EnableTelemetry(wpi::Sendable* component);
|
||||
|
||||
/**
|
||||
* Disable telemetry for a single component.
|
||||
*
|
||||
* @param sendable component
|
||||
*/
|
||||
void DisableTelemetry(Sendable* component);
|
||||
void DisableTelemetry(wpi::Sendable* component);
|
||||
|
||||
/**
|
||||
* Disable ALL telemetry.
|
||||
|
||||
@@ -7,15 +7,16 @@
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
#include "frc/motorcontrol/MotorController.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class MotorControllerGroup : public Sendable,
|
||||
class MotorControllerGroup : public wpi::Sendable,
|
||||
public MotorController,
|
||||
public SendableHelper<MotorControllerGroup> {
|
||||
public wpi::SendableHelper<MotorControllerGroup> {
|
||||
public:
|
||||
template <class... MotorControllers>
|
||||
explicit MotorControllerGroup(MotorController& motorController,
|
||||
@@ -33,7 +34,7 @@ class MotorControllerGroup : public Sendable,
|
||||
void Disable() override;
|
||||
void StopMotor() override;
|
||||
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
bool m_isInverted = false;
|
||||
|
||||
@@ -6,24 +6,23 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
#include "frc/DigitalOutput.h"
|
||||
#include "frc/MotorSafety.h"
|
||||
#include "frc/PWM.h"
|
||||
#include "frc/motorcontrol/MotorController.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class SendableBuilder;
|
||||
|
||||
/**
|
||||
* Nidec Brushless Motor.
|
||||
*/
|
||||
class NidecBrushless : public MotorController,
|
||||
public MotorSafety,
|
||||
public Sendable,
|
||||
public SendableHelper<NidecBrushless> {
|
||||
public wpi::Sendable,
|
||||
public wpi::SendableHelper<NidecBrushless> {
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -86,7 +85,7 @@ class NidecBrushless : public MotorController,
|
||||
int GetChannel() const;
|
||||
|
||||
// Sendable interface
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
bool m_isInverted = false;
|
||||
|
||||
@@ -7,11 +7,12 @@
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
#include "frc/MotorSafety.h"
|
||||
#include "frc/PWM.h"
|
||||
#include "frc/motorcontrol/MotorController.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -20,8 +21,8 @@ namespace frc {
|
||||
*/
|
||||
class PWMMotorController : public MotorController,
|
||||
public MotorSafety,
|
||||
public Sendable,
|
||||
public SendableHelper<PWMMotorController> {
|
||||
public wpi::Sendable,
|
||||
public wpi::SendableHelper<PWMMotorController> {
|
||||
public:
|
||||
PWMMotorController(PWMMotorController&&) = default;
|
||||
PWMMotorController& operator=(PWMMotorController&&) = default;
|
||||
@@ -67,7 +68,7 @@ class PWMMotorController : public MotorController,
|
||||
*/
|
||||
PWMMotorController(std::string_view name, int channel);
|
||||
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
|
||||
PWM m_pwm;
|
||||
|
||||
|
||||
@@ -10,12 +10,14 @@
|
||||
#include <networktables/NetworkTable.h>
|
||||
|
||||
#include "frc/shuffleboard/ShuffleboardWidget.h"
|
||||
#include "frc/smartdashboard/SendableBuilder.h"
|
||||
#include "frc/smartdashboard/SendableBuilderImpl.h"
|
||||
|
||||
namespace wpi {
|
||||
class Sendable;
|
||||
class SendableBuilder;
|
||||
} // namespace wpi
|
||||
|
||||
namespace frc {
|
||||
|
||||
class Sendable;
|
||||
class ShuffleboardContainer;
|
||||
|
||||
/**
|
||||
@@ -25,7 +27,9 @@ class ShuffleboardContainer;
|
||||
class ComplexWidget final : public ShuffleboardWidget<ComplexWidget> {
|
||||
public:
|
||||
ComplexWidget(ShuffleboardContainer& parent, std::string_view title,
|
||||
Sendable& sendable);
|
||||
wpi::Sendable& sendable);
|
||||
|
||||
~ComplexWidget() override;
|
||||
|
||||
void EnableIfActuator() override;
|
||||
|
||||
@@ -35,9 +39,8 @@ class ComplexWidget final : public ShuffleboardWidget<ComplexWidget> {
|
||||
std::shared_ptr<nt::NetworkTable> metaTable) override;
|
||||
|
||||
private:
|
||||
Sendable& m_sendable;
|
||||
SendableBuilderImpl m_builder;
|
||||
bool m_builderInit = false;
|
||||
wpi::Sendable& m_sendable;
|
||||
std::unique_ptr<wpi::SendableBuilder> m_builder;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
@@ -18,8 +18,8 @@ using CS_Handle = int; // NOLINT
|
||||
using CS_Source = CS_Handle; // NOLINT
|
||||
#endif
|
||||
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -29,14 +29,15 @@ namespace detail {
|
||||
constexpr const char* kProtocol = "camera_server://";
|
||||
std::shared_ptr<SendableCameraWrapper>& GetSendableCameraWrapper(
|
||||
CS_Source source);
|
||||
void AddToSendableRegistry(Sendable* sendable, std::string name);
|
||||
void AddToSendableRegistry(wpi::Sendable* sendable, std::string name);
|
||||
} // namespace detail
|
||||
|
||||
/**
|
||||
* A wrapper to make video sources sendable and usable from Shuffleboard.
|
||||
*/
|
||||
class SendableCameraWrapper : public Sendable,
|
||||
public SendableHelper<SendableCameraWrapper> {
|
||||
class SendableCameraWrapper
|
||||
: public wpi::Sendable,
|
||||
public wpi::SendableHelper<SendableCameraWrapper> {
|
||||
private:
|
||||
struct private_init {};
|
||||
|
||||
@@ -60,7 +61,7 @@ class SendableCameraWrapper : public Sendable,
|
||||
static SendableCameraWrapper& Wrap(const cs::VideoSource& source);
|
||||
static SendableCameraWrapper& Wrap(CS_Source source);
|
||||
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
std::string m_uri;
|
||||
|
||||
@@ -29,8 +29,6 @@ class ShuffleboardComponent : public ShuffleboardComponentBase {
|
||||
ShuffleboardComponent(ShuffleboardContainer& parent, std::string_view title,
|
||||
std::string_view type = "");
|
||||
|
||||
~ShuffleboardComponent() override = default;
|
||||
|
||||
/**
|
||||
* Sets custom properties for this component. Property names are
|
||||
* case-sensitive and whitespace-insensitive (capitalization and spaces do not
|
||||
|
||||
@@ -26,8 +26,6 @@ class ShuffleboardComponentBase : public virtual ShuffleboardValue {
|
||||
ShuffleboardComponentBase(ShuffleboardContainer& parent,
|
||||
std::string_view title, std::string_view type = "");
|
||||
|
||||
~ShuffleboardComponentBase() override = default;
|
||||
|
||||
void SetType(std::string_view type);
|
||||
|
||||
void BuildMetadata(std::shared_ptr<nt::NetworkTable> metaTable);
|
||||
|
||||
@@ -26,10 +26,13 @@ namespace cs {
|
||||
class VideoSource;
|
||||
} // namespace cs
|
||||
|
||||
namespace wpi {
|
||||
class Sendable;
|
||||
} // namespace wpi
|
||||
|
||||
namespace frc {
|
||||
|
||||
class ComplexWidget;
|
||||
class Sendable;
|
||||
class ShuffleboardLayout;
|
||||
class SimpleWidget;
|
||||
|
||||
@@ -111,7 +114,7 @@ class ShuffleboardContainer : public virtual ShuffleboardValue {
|
||||
* @throws IllegalArgumentException if a widget already exists in this
|
||||
* container with the given title
|
||||
*/
|
||||
ComplexWidget& Add(std::string_view title, Sendable& sendable);
|
||||
ComplexWidget& Add(std::string_view title, wpi::Sendable& sendable);
|
||||
|
||||
/**
|
||||
* Adds a widget to this container to display the given video stream.
|
||||
@@ -133,7 +136,7 @@ class ShuffleboardContainer : public virtual ShuffleboardValue {
|
||||
* container with the given title, or if the sendable's name has not been
|
||||
* specified
|
||||
*/
|
||||
ComplexWidget& Add(Sendable& sendable);
|
||||
ComplexWidget& Add(wpi::Sendable& sendable);
|
||||
|
||||
/**
|
||||
* Adds a widget to this container to display the given video stream.
|
||||
|
||||
@@ -8,16 +8,16 @@
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include <networktables/NTSendable.h>
|
||||
#include <networktables/NetworkTable.h>
|
||||
#include <networktables/NetworkTableEntry.h>
|
||||
#include <units/length.h>
|
||||
#include <wpi/mutex.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
#include "frc/geometry/Pose2d.h"
|
||||
#include "frc/geometry/Rotation2d.h"
|
||||
#include "frc/smartdashboard/FieldObject2d.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace frc {
|
||||
* also be shown by using the GetObject() function. Other objects can
|
||||
* also have multiple poses (which will show the object at multiple locations).
|
||||
*/
|
||||
class Field2d : public Sendable, public SendableHelper<Field2d> {
|
||||
class Field2d : public nt::NTSendable, public wpi::SendableHelper<Field2d> {
|
||||
public:
|
||||
using Entry = size_t;
|
||||
|
||||
@@ -85,7 +85,7 @@ class Field2d : public Sendable, public SendableHelper<Field2d> {
|
||||
*/
|
||||
FieldObject2d* GetRobotObject();
|
||||
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
void InitSendable(nt::NTSendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<nt::NetworkTable> m_table;
|
||||
|
||||
@@ -7,13 +7,13 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include <networktables/NTSendable.h>
|
||||
#include <networktables/NetworkTableEntry.h>
|
||||
#include <wpi/StringMap.h>
|
||||
#include <wpi/mutex.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
#include "frc/smartdashboard/MechanismRoot2d.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
#include "frc/util/Color8Bit.h"
|
||||
|
||||
namespace frc {
|
||||
@@ -36,7 +36,8 @@ namespace frc {
|
||||
* @see MechanismLigament2d
|
||||
* @see MechanismRoot2d
|
||||
*/
|
||||
class Mechanism2d : public Sendable, public SendableHelper<Mechanism2d> {
|
||||
class Mechanism2d : public nt::NTSendable,
|
||||
public wpi::SendableHelper<Mechanism2d> {
|
||||
public:
|
||||
/**
|
||||
* Create a new Mechanism2d with the given dimensions and background color.
|
||||
@@ -68,7 +69,7 @@ class Mechanism2d : public Sendable, public SendableHelper<Mechanism2d> {
|
||||
*/
|
||||
void SetBackgroundColor(const Color8Bit& color);
|
||||
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
void InitSendable(nt::NTSendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
double m_width;
|
||||
|
||||
@@ -1,26 +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 {
|
||||
|
||||
class SendableBuilder;
|
||||
|
||||
/**
|
||||
* Interface for Sendable objects.
|
||||
*/
|
||||
class Sendable {
|
||||
public:
|
||||
virtual ~Sendable() = default;
|
||||
|
||||
/**
|
||||
* Initializes this Sendable object.
|
||||
*
|
||||
* @param builder sendable builder
|
||||
*/
|
||||
virtual void InitSendable(SendableBuilder& builder) = 0;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
@@ -1,227 +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 <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include <networktables/NetworkTable.h>
|
||||
#include <networktables/NetworkTableEntry.h>
|
||||
#include <networktables/NetworkTableValue.h>
|
||||
#include <wpi/SmallVector.h>
|
||||
#include <wpi/span.h>
|
||||
|
||||
namespace frc {
|
||||
|
||||
class SendableBuilder {
|
||||
public:
|
||||
virtual ~SendableBuilder() = default;
|
||||
|
||||
/**
|
||||
* Set the string representation of the named data type that will be used
|
||||
* by the smart dashboard for this sendable.
|
||||
*
|
||||
* @param type data type
|
||||
*/
|
||||
virtual void SetSmartDashboardType(std::string_view type) = 0;
|
||||
|
||||
/**
|
||||
* Set a flag indicating if this sendable should be treated as an actuator.
|
||||
* By default this flag is false.
|
||||
*
|
||||
* @param value true if actuator, false if not
|
||||
*/
|
||||
virtual void SetActuator(bool value) = 0;
|
||||
|
||||
/**
|
||||
* Set the function that should be called to set the Sendable into a safe
|
||||
* state. This is called when entering and exiting Live Window mode.
|
||||
*
|
||||
* @param func function
|
||||
*/
|
||||
virtual void SetSafeState(std::function<void()> func) = 0;
|
||||
|
||||
/**
|
||||
* Set the function that should be called to update the network table
|
||||
* for things other than properties. Note this function is not passed
|
||||
* the network table object; instead it should use the entry handles
|
||||
* returned by GetEntry().
|
||||
*
|
||||
* @param func function
|
||||
*/
|
||||
virtual void SetUpdateTable(std::function<void()> func) = 0;
|
||||
|
||||
/**
|
||||
* Add a property without getters or setters. This can be used to get
|
||||
* entry handles for the function called by SetUpdateTable().
|
||||
*
|
||||
* @param key property name
|
||||
* @return Network table entry
|
||||
*/
|
||||
virtual nt::NetworkTableEntry GetEntry(std::string_view key) = 0;
|
||||
|
||||
/**
|
||||
* Add a boolean property.
|
||||
*
|
||||
* @param key property name
|
||||
* @param getter getter function (returns current value)
|
||||
* @param setter setter function (sets new value)
|
||||
*/
|
||||
virtual void AddBooleanProperty(std::string_view key,
|
||||
std::function<bool()> getter,
|
||||
std::function<void(bool)> setter) = 0;
|
||||
|
||||
/**
|
||||
* Add a double property.
|
||||
*
|
||||
* @param key property name
|
||||
* @param getter getter function (returns current value)
|
||||
* @param setter setter function (sets new value)
|
||||
*/
|
||||
virtual void AddDoubleProperty(std::string_view key,
|
||||
std::function<double()> getter,
|
||||
std::function<void(double)> setter) = 0;
|
||||
|
||||
/**
|
||||
* Add a string property.
|
||||
*
|
||||
* @param key property name
|
||||
* @param getter getter function (returns current value)
|
||||
* @param setter setter function (sets new value)
|
||||
*/
|
||||
virtual void AddStringProperty(
|
||||
std::string_view key, std::function<std::string()> getter,
|
||||
std::function<void(std::string_view)> setter) = 0;
|
||||
|
||||
/**
|
||||
* Add a boolean array property.
|
||||
*
|
||||
* @param key property name
|
||||
* @param getter getter function (returns current value)
|
||||
* @param setter setter function (sets new value)
|
||||
*/
|
||||
virtual void AddBooleanArrayProperty(
|
||||
std::string_view key, std::function<std::vector<int>()> getter,
|
||||
std::function<void(wpi::span<const int>)> setter) = 0;
|
||||
|
||||
/**
|
||||
* Add a double array property.
|
||||
*
|
||||
* @param key property name
|
||||
* @param getter getter function (returns current value)
|
||||
* @param setter setter function (sets new value)
|
||||
*/
|
||||
virtual void AddDoubleArrayProperty(
|
||||
std::string_view key, std::function<std::vector<double>()> getter,
|
||||
std::function<void(wpi::span<const double>)> setter) = 0;
|
||||
|
||||
/**
|
||||
* Add a string array property.
|
||||
*
|
||||
* @param key property name
|
||||
* @param getter getter function (returns current value)
|
||||
* @param setter setter function (sets new value)
|
||||
*/
|
||||
virtual void AddStringArrayProperty(
|
||||
std::string_view key, std::function<std::vector<std::string>()> getter,
|
||||
std::function<void(wpi::span<const std::string>)> setter) = 0;
|
||||
|
||||
/**
|
||||
* Add a raw property.
|
||||
*
|
||||
* @param key property name
|
||||
* @param getter getter function (returns current value)
|
||||
* @param setter setter function (sets new value)
|
||||
*/
|
||||
virtual void AddRawProperty(std::string_view key,
|
||||
std::function<std::string()> getter,
|
||||
std::function<void(std::string_view)> setter) = 0;
|
||||
|
||||
/**
|
||||
* Add a NetworkTableValue property.
|
||||
*
|
||||
* @param key property name
|
||||
* @param getter getter function (returns current value)
|
||||
* @param setter setter function (sets new value)
|
||||
*/
|
||||
virtual void AddValueProperty(
|
||||
std::string_view key, std::function<std::shared_ptr<nt::Value>()> getter,
|
||||
std::function<void(std::shared_ptr<nt::Value>)> setter) = 0;
|
||||
|
||||
/**
|
||||
* Add a string property (SmallString form).
|
||||
*
|
||||
* @param key property name
|
||||
* @param getter getter function (returns current value)
|
||||
* @param setter setter function (sets new value)
|
||||
*/
|
||||
virtual void AddSmallStringProperty(
|
||||
std::string_view key,
|
||||
std::function<std::string_view(wpi::SmallVectorImpl<char>& buf)> getter,
|
||||
std::function<void(std::string_view)> setter) = 0;
|
||||
|
||||
/**
|
||||
* Add a boolean array property (SmallVector form).
|
||||
*
|
||||
* @param key property name
|
||||
* @param getter getter function (returns current value)
|
||||
* @param setter setter function (sets new value)
|
||||
*/
|
||||
virtual void AddSmallBooleanArrayProperty(
|
||||
std::string_view key,
|
||||
std::function<wpi::span<const int>(wpi::SmallVectorImpl<int>& buf)>
|
||||
getter,
|
||||
std::function<void(wpi::span<const int>)> setter) = 0;
|
||||
|
||||
/**
|
||||
* Add a double array property (SmallVector form).
|
||||
*
|
||||
* @param key property name
|
||||
* @param getter getter function (returns current value)
|
||||
* @param setter setter function (sets new value)
|
||||
*/
|
||||
virtual void AddSmallDoubleArrayProperty(
|
||||
std::string_view key,
|
||||
std::function<wpi::span<const double>(wpi::SmallVectorImpl<double>& buf)>
|
||||
getter,
|
||||
std::function<void(wpi::span<const double>)> setter) = 0;
|
||||
|
||||
/**
|
||||
* Add a string array property (SmallVector form).
|
||||
*
|
||||
* @param key property name
|
||||
* @param getter getter function (returns current value)
|
||||
* @param setter setter function (sets new value)
|
||||
*/
|
||||
virtual void AddSmallStringArrayProperty(
|
||||
std::string_view key,
|
||||
std::function<
|
||||
wpi::span<const std::string>(wpi::SmallVectorImpl<std::string>& buf)>
|
||||
getter,
|
||||
std::function<void(wpi::span<const std::string>)> setter) = 0;
|
||||
|
||||
/**
|
||||
* Add a raw property (SmallVector form).
|
||||
*
|
||||
* @param key property name
|
||||
* @param getter getter function (returns current value)
|
||||
* @param setter setter function (sets new value)
|
||||
*/
|
||||
virtual void AddSmallRawProperty(
|
||||
std::string_view key,
|
||||
std::function<std::string_view(wpi::SmallVectorImpl<char>& buf)> getter,
|
||||
std::function<void(std::string_view)> setter) = 0;
|
||||
|
||||
/**
|
||||
* Get the network table.
|
||||
* @return The network table
|
||||
*/
|
||||
virtual std::shared_ptr<nt::NetworkTable> GetTable() = 0;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
@@ -11,17 +11,16 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <networktables/NTSendableBuilder.h>
|
||||
#include <networktables/NetworkTable.h>
|
||||
#include <networktables/NetworkTableEntry.h>
|
||||
#include <networktables/NetworkTableValue.h>
|
||||
#include <wpi/SmallVector.h>
|
||||
#include <wpi/span.h>
|
||||
|
||||
#include "frc/smartdashboard/SendableBuilder.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class SendableBuilderImpl : public SendableBuilder {
|
||||
class SendableBuilderImpl : public nt::NTSendableBuilder {
|
||||
public:
|
||||
SendableBuilderImpl() = default;
|
||||
~SendableBuilderImpl() override = default;
|
||||
@@ -46,7 +45,7 @@ class SendableBuilderImpl : public SendableBuilder {
|
||||
* Return whether this sendable has an associated table.
|
||||
* @return True if it has a table, false if not.
|
||||
*/
|
||||
bool HasTable() const;
|
||||
bool IsPublished() const override;
|
||||
|
||||
/**
|
||||
* Return whether this sendable should be treated as an actuator.
|
||||
@@ -57,7 +56,7 @@ class SendableBuilderImpl : public SendableBuilder {
|
||||
/**
|
||||
* Update the network table values by calling the getters for all properties.
|
||||
*/
|
||||
void UpdateTable();
|
||||
void Update() override;
|
||||
|
||||
/**
|
||||
* Hook setters for all properties.
|
||||
@@ -84,7 +83,7 @@ class SendableBuilderImpl : public SendableBuilder {
|
||||
/**
|
||||
* Clear properties.
|
||||
*/
|
||||
void ClearProperties();
|
||||
void ClearProperties() override;
|
||||
|
||||
void SetSmartDashboardType(std::string_view type) override;
|
||||
void SetActuator(bool value) override;
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <wpi/StringMap.h>
|
||||
#include <wpi/deprecated.h>
|
||||
|
||||
#include "frc/smartdashboard/SendableBuilder.h"
|
||||
#include "frc/smartdashboard/SendableChooserBase.h"
|
||||
|
||||
namespace frc {
|
||||
@@ -112,7 +111,7 @@ class SendableChooser : public SendableChooserBase {
|
||||
*/
|
||||
auto GetSelected() -> decltype(_unwrap_smart_ptr(m_choices[""]));
|
||||
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
void InitSendable(nt::NTSendableBuilder& builder) override;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <networktables/NTSendableBuilder.h>
|
||||
|
||||
#include "frc/smartdashboard/SendableChooser.h"
|
||||
|
||||
namespace frc {
|
||||
@@ -44,7 +46,7 @@ auto SendableChooser<T>::GetSelected()
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void SendableChooser<T>::InitSendable(SendableBuilder& builder) {
|
||||
void SendableChooser<T>::InitSendable(nt::NTSendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("String Chooser");
|
||||
builder.GetEntry(kInstance).SetDouble(m_instance);
|
||||
builder.AddStringArrayProperty(
|
||||
|
||||
@@ -7,12 +7,11 @@
|
||||
#include <atomic>
|
||||
#include <string>
|
||||
|
||||
#include <networktables/NTSendable.h>
|
||||
#include <networktables/NetworkTableEntry.h>
|
||||
#include <wpi/SmallVector.h>
|
||||
#include <wpi/mutex.h>
|
||||
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -22,8 +21,8 @@ namespace frc {
|
||||
* It contains static, non-templated variables to avoid their duplication in the
|
||||
* template class.
|
||||
*/
|
||||
class SendableChooserBase : public Sendable,
|
||||
public SendableHelper<SendableChooserBase> {
|
||||
class SendableChooserBase : public nt::NTSendable,
|
||||
public wpi::SendableHelper<SendableChooserBase> {
|
||||
public:
|
||||
SendableChooserBase();
|
||||
~SendableChooserBase() override = default;
|
||||
|
||||
@@ -1,176 +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 <string_view>
|
||||
|
||||
#include <wpi/deprecated.h>
|
||||
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
* A helper class for use with objects that add themselves to SendableRegistry.
|
||||
* It takes care of properly calling Move() and Remove() on move and
|
||||
* destruction. No action is taken if the object is copied.
|
||||
* Use public inheritance with CRTP when using this class.
|
||||
* @tparam CRTP derived class
|
||||
*/
|
||||
template <typename Derived>
|
||||
class SendableHelper {
|
||||
public:
|
||||
SendableHelper(const SendableHelper& rhs) = default;
|
||||
SendableHelper& operator=(const SendableHelper& rhs) = default;
|
||||
|
||||
SendableHelper(SendableHelper&& rhs) {
|
||||
// it is safe to call Move() multiple times with the same rhs
|
||||
SendableRegistry::GetInstance().Move(static_cast<Derived*>(this),
|
||||
static_cast<Derived*>(&rhs));
|
||||
}
|
||||
|
||||
SendableHelper& operator=(SendableHelper&& rhs) {
|
||||
// it is safe to call Move() multiple times with the same rhs
|
||||
SendableRegistry::GetInstance().Move(static_cast<Derived*>(this),
|
||||
static_cast<Derived*>(&rhs));
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of this Sendable object.
|
||||
*
|
||||
* @deprecated use SendableRegistry::GetName()
|
||||
*
|
||||
* @return Name
|
||||
*/
|
||||
WPI_DEPRECATED("use SendableRegistry::GetName()")
|
||||
std::string GetName() const {
|
||||
return SendableRegistry::GetInstance().GetName(
|
||||
static_cast<const Derived*>(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name of this Sendable object.
|
||||
*
|
||||
* @deprecated use SendableRegistry::SetName()
|
||||
*
|
||||
* @param name name
|
||||
*/
|
||||
WPI_DEPRECATED("use SendableRegistry::SetName()")
|
||||
void SetName(std::string_view name) {
|
||||
SendableRegistry::GetInstance().SetName(static_cast<Derived*>(this), name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets both the subsystem name and device name of this Sendable object.
|
||||
*
|
||||
* @deprecated use SendableRegistry::SetName()
|
||||
*
|
||||
* @param subsystem subsystem name
|
||||
* @param name device name
|
||||
*/
|
||||
WPI_DEPRECATED("use SendableRegistry::SetName()")
|
||||
void SetName(std::string_view subsystem, std::string_view name) {
|
||||
SendableRegistry::GetInstance().SetName(static_cast<Derived*>(this),
|
||||
subsystem, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the subsystem name of this Sendable object.
|
||||
*
|
||||
* @deprecated use SendableRegistry::GetSubsystem().
|
||||
*
|
||||
* @return Subsystem name
|
||||
*/
|
||||
WPI_DEPRECATED("use SendableRegistry::GetSubsystem()")
|
||||
std::string GetSubsystem() const {
|
||||
return SendableRegistry::GetInstance().GetSubsystem(
|
||||
static_cast<const Derived*>(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the subsystem name of this Sendable object.
|
||||
*
|
||||
* @deprecated use SendableRegistry::SetSubsystem()
|
||||
*
|
||||
* @param subsystem subsystem name
|
||||
*/
|
||||
WPI_DEPRECATED("use SendableRegistry::SetSubsystem()")
|
||||
void SetSubsystem(std::string_view subsystem) {
|
||||
SendableRegistry::GetInstance().SetSubsystem(static_cast<Derived*>(this),
|
||||
subsystem);
|
||||
}
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Add a child component.
|
||||
*
|
||||
* @deprecated use SendableRegistry::AddChild()
|
||||
*
|
||||
* @param child child component
|
||||
*/
|
||||
WPI_DEPRECATED("use SendableRegistry::AddChild()")
|
||||
void AddChild(std::shared_ptr<Sendable> child) {
|
||||
SendableRegistry::GetInstance().AddChild(static_cast<Derived*>(this),
|
||||
child.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a child component.
|
||||
*
|
||||
* @deprecated use SendableRegistry::AddChild()
|
||||
*
|
||||
* @param child child component
|
||||
*/
|
||||
WPI_DEPRECATED("use SendableRegistry::AddChild()")
|
||||
void AddChild(void* child) {
|
||||
SendableRegistry::GetInstance().AddChild(static_cast<Derived*>(this),
|
||||
child);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name of the sensor with a channel number.
|
||||
*
|
||||
* @deprecated use SendableRegistry::SetName()
|
||||
*
|
||||
* @param moduleType A string that defines the module name in the label for
|
||||
* the value
|
||||
* @param channel The channel number the device is plugged into
|
||||
*/
|
||||
WPI_DEPRECATED("use SendableRegistry::SetName()")
|
||||
void SetName(std::string_view moduleType, int channel) {
|
||||
SendableRegistry::GetInstance().SetName(static_cast<Derived*>(this),
|
||||
moduleType, channel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name of the sensor with a module and channel number.
|
||||
*
|
||||
* @deprecated use SendableRegistry::SetName()
|
||||
*
|
||||
* @param moduleType A string that defines the module name in the label for
|
||||
* the value
|
||||
* @param moduleNumber The number of the particular module type
|
||||
* @param channel The channel number the device is plugged into (usually
|
||||
* PWM)
|
||||
*/
|
||||
WPI_DEPRECATED("use SendableRegistry::SetName()")
|
||||
void SetName(std::string_view moduleType, int moduleNumber, int channel) {
|
||||
SendableRegistry::GetInstance().SetName(static_cast<Derived*>(this),
|
||||
moduleType, moduleNumber, channel);
|
||||
}
|
||||
|
||||
protected:
|
||||
SendableHelper() = default;
|
||||
|
||||
~SendableHelper() {
|
||||
// it is safe to call Remove() multiple times with the same object
|
||||
SendableRegistry::GetInstance().Remove(static_cast<Derived*>(this));
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
@@ -1,338 +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 <string_view>
|
||||
|
||||
#include <networktables/NetworkTable.h>
|
||||
#include <wpi/function_ref.h>
|
||||
|
||||
namespace frc {
|
||||
|
||||
class Sendable;
|
||||
class SendableBuilderImpl;
|
||||
|
||||
/**
|
||||
* The SendableRegistry class is the public interface for registering sensors
|
||||
* and actuators for use on dashboards and LiveWindow.
|
||||
*/
|
||||
class SendableRegistry {
|
||||
public:
|
||||
SendableRegistry(const SendableRegistry&) = delete;
|
||||
SendableRegistry& operator=(const SendableRegistry&) = delete;
|
||||
|
||||
using UID = size_t;
|
||||
|
||||
/**
|
||||
* Gets an instance of the SendableRegistry class.
|
||||
*
|
||||
* This is a singleton to guarantee that there is only a single instance
|
||||
* regardless of how many times GetInstance is called.
|
||||
*/
|
||||
static SendableRegistry& GetInstance();
|
||||
|
||||
/**
|
||||
* Adds an object to the registry.
|
||||
*
|
||||
* @param sendable object to add
|
||||
* @param name component name
|
||||
*/
|
||||
void Add(Sendable* sendable, std::string_view name);
|
||||
|
||||
/**
|
||||
* Adds an object to the registry.
|
||||
*
|
||||
* @param sendable object to add
|
||||
* @param moduleType A string that defines the module name in the label for
|
||||
* the value
|
||||
* @param channel The channel number the device is plugged into
|
||||
*/
|
||||
void Add(Sendable* sendable, std::string_view moduleType, int channel);
|
||||
|
||||
/**
|
||||
* Adds an object to the registry.
|
||||
*
|
||||
* @param sendable object to add
|
||||
* @param moduleType A string that defines the module name in the label for
|
||||
* the value
|
||||
* @param moduleNumber The number of the particular module type
|
||||
* @param channel The channel number the device is plugged into
|
||||
*/
|
||||
void Add(Sendable* sendable, std::string_view moduleType, int moduleNumber,
|
||||
int channel);
|
||||
|
||||
/**
|
||||
* Adds an object to the registry.
|
||||
*
|
||||
* @param sendable object to add
|
||||
* @param subsystem subsystem name
|
||||
* @param name component name
|
||||
*/
|
||||
void Add(Sendable* sendable, std::string_view subsystem,
|
||||
std::string_view name);
|
||||
|
||||
/**
|
||||
* Adds an object to the registry and LiveWindow.
|
||||
*
|
||||
* @param sendable object to add
|
||||
* @param name component name
|
||||
*/
|
||||
void AddLW(Sendable* sendable, std::string_view name);
|
||||
|
||||
/**
|
||||
* Adds an object to the registry and LiveWindow.
|
||||
*
|
||||
* @param sendable object to add
|
||||
* @param moduleType A string that defines the module name in the label for
|
||||
* the value
|
||||
* @param channel The channel number the device is plugged into
|
||||
*/
|
||||
void AddLW(Sendable* sendable, std::string_view moduleType, int channel);
|
||||
|
||||
/**
|
||||
* Adds an object to the registry and LiveWindow.
|
||||
*
|
||||
* @param sendable object to add
|
||||
* @param moduleType A string that defines the module name in the label for
|
||||
* the value
|
||||
* @param moduleNumber The number of the particular module type
|
||||
* @param channel The channel number the device is plugged into
|
||||
*/
|
||||
void AddLW(Sendable* sendable, std::string_view moduleType, int moduleNumber,
|
||||
int channel);
|
||||
|
||||
/**
|
||||
* Adds an object to the registry and LiveWindow.
|
||||
*
|
||||
* @param sendable object to add
|
||||
* @param subsystem subsystem name
|
||||
* @param name component name
|
||||
*/
|
||||
void AddLW(Sendable* sendable, std::string_view subsystem,
|
||||
std::string_view name);
|
||||
|
||||
/**
|
||||
* Adds a child object to an object. Adds the child object to the registry
|
||||
* if it's not already present.
|
||||
*
|
||||
* @param parent parent object
|
||||
* @param child child object
|
||||
*/
|
||||
void AddChild(Sendable* parent, Sendable* child);
|
||||
|
||||
/**
|
||||
* Adds a child object to an object. Adds the child object to the registry
|
||||
* if it's not already present.
|
||||
*
|
||||
* @param parent parent object
|
||||
* @param child child object
|
||||
*/
|
||||
void AddChild(Sendable* parent, void* child);
|
||||
|
||||
/**
|
||||
* Removes an object from the registry.
|
||||
*
|
||||
* @param sendable object to remove
|
||||
* @return true if the object was removed; false if it was not present
|
||||
*/
|
||||
bool Remove(Sendable* sendable);
|
||||
|
||||
/**
|
||||
* Moves an object in the registry (for use in move constructors/assignments).
|
||||
*
|
||||
* @param to new object
|
||||
* @param from old object
|
||||
*/
|
||||
void Move(Sendable* to, Sendable* from);
|
||||
|
||||
/**
|
||||
* Determines if an object is in the registry.
|
||||
*
|
||||
* @param sendable object to check
|
||||
* @return True if in registry, false if not.
|
||||
*/
|
||||
bool Contains(const Sendable* sendable) const;
|
||||
|
||||
/**
|
||||
* Gets the name of an object.
|
||||
*
|
||||
* @param sendable object
|
||||
* @return Name (empty if object is not in registry)
|
||||
*/
|
||||
std::string GetName(const Sendable* sendable) const;
|
||||
|
||||
/**
|
||||
* Sets the name of an object.
|
||||
*
|
||||
* @param sendable object
|
||||
* @param name name
|
||||
*/
|
||||
void SetName(Sendable* sendable, std::string_view name);
|
||||
|
||||
/**
|
||||
* Sets the name of an object with a channel number.
|
||||
*
|
||||
* @param sendable object
|
||||
* @param moduleType A string that defines the module name in the label for
|
||||
* the value
|
||||
* @param channel The channel number the device is plugged into
|
||||
*/
|
||||
void SetName(Sendable* sendable, std::string_view moduleType, int channel);
|
||||
|
||||
/**
|
||||
* Sets the name of an object with a module and channel number.
|
||||
*
|
||||
* @param sendable object
|
||||
* @param moduleType A string that defines the module name in the label for
|
||||
* the value
|
||||
* @param moduleNumber The number of the particular module type
|
||||
* @param channel The channel number the device is plugged into
|
||||
*/
|
||||
void SetName(Sendable* sendable, std::string_view moduleType,
|
||||
int moduleNumber, int channel);
|
||||
|
||||
/**
|
||||
* Sets both the subsystem name and device name of an object.
|
||||
*
|
||||
* @param sendable object
|
||||
* @param subsystem subsystem name
|
||||
* @param name device name
|
||||
*/
|
||||
void SetName(Sendable* sendable, std::string_view subsystem,
|
||||
std::string_view name);
|
||||
|
||||
/**
|
||||
* Gets the subsystem name of an object.
|
||||
*
|
||||
* @param sendable object
|
||||
* @return Subsystem name (empty if object is not in registry)
|
||||
*/
|
||||
std::string GetSubsystem(const Sendable* sendable) const;
|
||||
|
||||
/**
|
||||
* Sets the subsystem name of an object.
|
||||
*
|
||||
* @param sendable object
|
||||
* @param subsystem subsystem name
|
||||
*/
|
||||
void SetSubsystem(Sendable* sendable, std::string_view subsystem);
|
||||
|
||||
/**
|
||||
* Gets a unique handle for setting/getting data with SetData() and GetData().
|
||||
*
|
||||
* @return Handle
|
||||
*/
|
||||
int GetDataHandle();
|
||||
|
||||
/**
|
||||
* Associates arbitrary data with an object in the registry.
|
||||
*
|
||||
* @param sendable object
|
||||
* @param handle data handle returned by GetDataHandle()
|
||||
* @param data data to set
|
||||
* @return Previous data (may be null)
|
||||
*/
|
||||
std::shared_ptr<void> SetData(Sendable* sendable, int handle,
|
||||
std::shared_ptr<void> data);
|
||||
|
||||
/**
|
||||
* Gets arbitrary data associated with an object in the registry.
|
||||
*
|
||||
* @param sendable object
|
||||
* @param handle data handle returned by GetDataHandle()
|
||||
* @return data (may be null if none associated)
|
||||
*/
|
||||
std::shared_ptr<void> GetData(Sendable* sendable, int handle);
|
||||
|
||||
/**
|
||||
* Enables LiveWindow for an object.
|
||||
*
|
||||
* @param sendable object
|
||||
*/
|
||||
void EnableLiveWindow(Sendable* sendable);
|
||||
|
||||
/**
|
||||
* Disables LiveWindow for an object.
|
||||
*
|
||||
* @param sendable object
|
||||
*/
|
||||
void DisableLiveWindow(Sendable* sendable);
|
||||
|
||||
/**
|
||||
* Get unique id for an object. Since objects can move, use this instead
|
||||
* of storing Sendable* directly if ownership is in question.
|
||||
*
|
||||
* @param sendable object
|
||||
* @return unique id
|
||||
*/
|
||||
UID GetUniqueId(Sendable* sendable);
|
||||
|
||||
/**
|
||||
* Get sendable object for a given unique id.
|
||||
*
|
||||
* @param uid unique id
|
||||
* @return sendable object (may be null)
|
||||
*/
|
||||
Sendable* GetSendable(UID uid);
|
||||
|
||||
/**
|
||||
* Publishes an object in the registry to a network table.
|
||||
*
|
||||
* @param sendableUid sendable unique id
|
||||
* @param table network table
|
||||
*/
|
||||
void Publish(UID sendableUid, std::shared_ptr<nt::NetworkTable> table);
|
||||
|
||||
/**
|
||||
* Updates network table information from an object.
|
||||
*
|
||||
* @param sendableUid sendable unique id
|
||||
*/
|
||||
void Update(UID sendableUid);
|
||||
|
||||
/**
|
||||
* Data passed to ForeachLiveWindow() callback function
|
||||
*/
|
||||
struct CallbackData {
|
||||
CallbackData(Sendable* sendable_, std::string_view name_,
|
||||
std::string_view subsystem_, Sendable* parent_,
|
||||
std::shared_ptr<void>& data_, SendableBuilderImpl& builder_)
|
||||
: sendable(sendable_),
|
||||
name(name_),
|
||||
subsystem(subsystem_),
|
||||
parent(parent_),
|
||||
data(data_),
|
||||
builder(builder_) {}
|
||||
|
||||
Sendable* sendable;
|
||||
std::string_view name;
|
||||
std::string_view subsystem;
|
||||
Sendable* parent;
|
||||
std::shared_ptr<void>& data;
|
||||
SendableBuilderImpl& builder;
|
||||
};
|
||||
|
||||
/**
|
||||
* Iterates over LiveWindow-enabled objects in the registry.
|
||||
* It is *not* safe to call other SendableRegistry functions from the
|
||||
* callback (this will likely deadlock).
|
||||
*
|
||||
* @param dataHandle data handle to get data pointer passed to callback
|
||||
* @param callback function to call for each object
|
||||
*/
|
||||
void ForeachLiveWindow(
|
||||
int dataHandle,
|
||||
wpi::function_ref<void(CallbackData& cbdata)> callback) const;
|
||||
|
||||
private:
|
||||
SendableRegistry();
|
||||
|
||||
struct Impl;
|
||||
std::unique_ptr<Impl> m_impl;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
@@ -11,15 +11,16 @@
|
||||
|
||||
#include <networktables/NetworkTableEntry.h>
|
||||
#include <networktables/NetworkTableValue.h>
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
#include <wpi/span.h>
|
||||
|
||||
#include "frc/smartdashboard/ListenerExecutor.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class SmartDashboard : public Sendable, public SendableHelper<SmartDashboard> {
|
||||
class SmartDashboard : public wpi::Sendable,
|
||||
public wpi::SendableHelper<SmartDashboard> {
|
||||
public:
|
||||
static void init();
|
||||
|
||||
@@ -115,7 +116,7 @@ class SmartDashboard : public Sendable, public SendableHelper<SmartDashboard> {
|
||||
* @param keyName the key
|
||||
* @param value the value
|
||||
*/
|
||||
static void PutData(std::string_view key, Sendable* data);
|
||||
static void PutData(std::string_view key, wpi::Sendable* data);
|
||||
|
||||
/**
|
||||
* Maps the specified key (where the key is the name of the Sendable)
|
||||
@@ -129,7 +130,7 @@ class SmartDashboard : public Sendable, public SendableHelper<SmartDashboard> {
|
||||
*
|
||||
* @param value the value
|
||||
*/
|
||||
static void PutData(Sendable* value);
|
||||
static void PutData(wpi::Sendable* value);
|
||||
|
||||
/**
|
||||
* Returns the value at the specified key.
|
||||
@@ -137,7 +138,7 @@ class SmartDashboard : public Sendable, public SendableHelper<SmartDashboard> {
|
||||
* @param keyName the key
|
||||
* @return the value
|
||||
*/
|
||||
static Sendable* GetData(std::string_view keyName);
|
||||
static wpi::Sendable* GetData(std::string_view keyName);
|
||||
|
||||
/**
|
||||
* Maps the specified key to the specified value in this table.
|
||||
|
||||
Reference in New Issue
Block a user