mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Simplify Sendable interface (#1864)
This removes the name and subsystem from individual objects, and instead puts this data into a new singleton class, SendableRegistry. Much of LiveWindow has been refactored into SendableRegistry. In C++, a new CRTP helper class, SendableHelper, has been added to provide move and destruction functionality. Shims for GetName, SetName, GetSubsystem, and SetSubsystem have been added to Command and Subsystem (both old and new), and also to SendableHelper to prevent code breakage. This deprecates SendableBase in preparation for future removal.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <hal/HAL.h>
|
||||
|
||||
#include "frc/smartdashboard/SendableBuilder.h"
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
@@ -22,7 +23,8 @@ ADXL345_I2C::ADXL345_I2C(I2C::Port port, Range range, int deviceAddress)
|
||||
|
||||
HAL_Report(HALUsageReporting::kResourceType_ADXL345,
|
||||
HALUsageReporting::kADXL345_I2C, 0);
|
||||
SetName("ADXL345_I2C", port);
|
||||
|
||||
SendableRegistry::GetInstance().AddLW(this, "ADXL345_I2C", port);
|
||||
}
|
||||
|
||||
void ADXL345_I2C::SetRange(Range range) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <hal/HAL.h>
|
||||
|
||||
#include "frc/smartdashboard/SendableBuilder.h"
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
@@ -32,7 +33,7 @@ ADXL345_SPI::ADXL345_SPI(SPI::Port port, ADXL345_SPI::Range range)
|
||||
HAL_Report(HALUsageReporting::kResourceType_ADXL345,
|
||||
HALUsageReporting::kADXL345_SPI);
|
||||
|
||||
SetName("ADXL345_SPI", port);
|
||||
SendableRegistry::GetInstance().AddLW(this, "ADXL345_SPI", port);
|
||||
}
|
||||
|
||||
void ADXL345_SPI::SetRange(Range range) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include "frc/DriverStation.h"
|
||||
#include "frc/smartdashboard/SendableBuilder.h"
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
@@ -62,7 +63,7 @@ ADXL362::ADXL362(SPI::Port port, Range range) : m_spi(port) {
|
||||
|
||||
HAL_Report(HALUsageReporting::kResourceType_ADXL362, port);
|
||||
|
||||
SetName("ADXL362", port);
|
||||
SendableRegistry::GetInstance().AddLW(this, "ADXL362", port);
|
||||
}
|
||||
|
||||
void ADXL362::SetRange(Range range) {
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include "frc/DriverStation.h"
|
||||
#include "frc/Timer.h"
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
@@ -49,7 +50,8 @@ ADXRS450_Gyro::ADXRS450_Gyro(SPI::Port port) : m_spi(port) {
|
||||
Calibrate();
|
||||
|
||||
HAL_Report(HALUsageReporting::kResourceType_ADXRS450, port);
|
||||
SetName("ADXRS450_Gyro", port);
|
||||
|
||||
SendableRegistry::GetInstance().AddLW(this, "ADXRS450_Gyro", port);
|
||||
}
|
||||
|
||||
static bool CalcParity(int v) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -11,12 +11,13 @@
|
||||
|
||||
#include "frc/WPIErrors.h"
|
||||
#include "frc/smartdashboard/SendableBuilder.h"
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
AnalogAccelerometer::AnalogAccelerometer(int channel)
|
||||
: AnalogAccelerometer(std::make_shared<AnalogInput>(channel)) {
|
||||
AddChild(m_analogInput);
|
||||
SendableRegistry::GetInstance().AddChild(this, m_analogInput.get());
|
||||
}
|
||||
|
||||
AnalogAccelerometer::AnalogAccelerometer(AnalogInput* channel)
|
||||
@@ -58,5 +59,7 @@ void AnalogAccelerometer::InitSendable(SendableBuilder& builder) {
|
||||
void AnalogAccelerometer::InitAccelerometer() {
|
||||
HAL_Report(HALUsageReporting::kResourceType_Accelerometer,
|
||||
m_analogInput->GetChannel());
|
||||
SetName("Accelerometer", m_analogInput->GetChannel());
|
||||
|
||||
SendableRegistry::GetInstance().AddLW(this, "Accelerometer",
|
||||
m_analogInput->GetChannel());
|
||||
}
|
||||
|
||||
@@ -17,12 +17,13 @@
|
||||
#include "frc/AnalogInput.h"
|
||||
#include "frc/Timer.h"
|
||||
#include "frc/WPIErrors.h"
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
AnalogGyro::AnalogGyro(int channel)
|
||||
: AnalogGyro(std::make_shared<AnalogInput>(channel)) {
|
||||
AddChild(m_analog);
|
||||
SendableRegistry::GetInstance().AddChild(this, m_analog.get());
|
||||
}
|
||||
|
||||
AnalogGyro::AnalogGyro(AnalogInput* channel)
|
||||
@@ -41,7 +42,7 @@ AnalogGyro::AnalogGyro(std::shared_ptr<AnalogInput> channel)
|
||||
|
||||
AnalogGyro::AnalogGyro(int channel, int center, double offset)
|
||||
: AnalogGyro(std::make_shared<AnalogInput>(channel), center, offset) {
|
||||
AddChild(m_analog);
|
||||
SendableRegistry::GetInstance().AddChild(this, m_analog.get());
|
||||
}
|
||||
|
||||
AnalogGyro::AnalogGyro(std::shared_ptr<AnalogInput> channel, int center,
|
||||
@@ -148,7 +149,9 @@ void AnalogGyro::InitGyro() {
|
||||
}
|
||||
|
||||
HAL_Report(HALUsageReporting::kResourceType_Gyro, m_analog->GetChannel());
|
||||
SetName("AnalogGyro", m_analog->GetChannel());
|
||||
|
||||
SendableRegistry::GetInstance().AddLW(this, "AnalogGyro",
|
||||
m_analog->GetChannel());
|
||||
}
|
||||
|
||||
void AnalogGyro::Calibrate() {
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "frc/Timer.h"
|
||||
#include "frc/WPIErrors.h"
|
||||
#include "frc/smartdashboard/SendableBuilder.h"
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
@@ -42,7 +43,8 @@ AnalogInput::AnalogInput(int channel) {
|
||||
}
|
||||
|
||||
HAL_Report(HALUsageReporting::kResourceType_AnalogChannel, channel);
|
||||
SetName("AnalogInput", channel);
|
||||
|
||||
SendableRegistry::GetInstance().AddLW(this, "AnalogInput", channel);
|
||||
}
|
||||
|
||||
AnalogInput::~AnalogInput() { HAL_FreeAnalogInputPort(m_port); }
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "frc/SensorUtil.h"
|
||||
#include "frc/WPIErrors.h"
|
||||
#include "frc/smartdashboard/SendableBuilder.h"
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
@@ -42,7 +43,7 @@ AnalogOutput::AnalogOutput(int channel) {
|
||||
}
|
||||
|
||||
HAL_Report(HALUsageReporting::kResourceType_AnalogOutput, m_channel);
|
||||
SetName("AnalogOutput", m_channel);
|
||||
SendableRegistry::GetInstance().AddLW(this, "AnalogOutput", m_channel);
|
||||
}
|
||||
|
||||
AnalogOutput::~AnalogOutput() { HAL_FreeAnalogOutputPort(m_port); }
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -9,26 +9,29 @@
|
||||
|
||||
#include "frc/RobotController.h"
|
||||
#include "frc/smartdashboard/SendableBuilder.h"
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
AnalogPotentiometer::AnalogPotentiometer(int channel, double fullRange,
|
||||
double offset)
|
||||
: m_analog_input(std::make_shared<AnalogInput>(channel)),
|
||||
m_fullRange(fullRange),
|
||||
m_offset(offset) {
|
||||
AddChild(m_analog_input);
|
||||
: AnalogPotentiometer(std::make_shared<AnalogInput>(channel), fullRange,
|
||||
offset) {
|
||||
SendableRegistry::GetInstance().AddChild(this, m_analog_input.get());
|
||||
}
|
||||
|
||||
AnalogPotentiometer::AnalogPotentiometer(AnalogInput* input, double fullRange,
|
||||
double offset)
|
||||
: m_analog_input(input, NullDeleter<AnalogInput>()),
|
||||
m_fullRange(fullRange),
|
||||
m_offset(offset) {}
|
||||
: AnalogPotentiometer(
|
||||
std::shared_ptr<AnalogInput>(input, NullDeleter<AnalogInput>()),
|
||||
fullRange, offset) {}
|
||||
|
||||
AnalogPotentiometer::AnalogPotentiometer(std::shared_ptr<AnalogInput> input,
|
||||
double fullRange, double offset)
|
||||
: m_analog_input(input), m_fullRange(fullRange), m_offset(offset) {}
|
||||
: m_analog_input(input), m_fullRange(fullRange), m_offset(offset) {
|
||||
SendableRegistry::GetInstance().AddLW(this, "AnalogPotentiometer",
|
||||
m_analog_input->GetChannel());
|
||||
}
|
||||
|
||||
double AnalogPotentiometer::Get() const {
|
||||
return (m_analog_input->GetVoltage() / RobotController::GetVoltage5V()) *
|
||||
|
||||
@@ -13,13 +13,14 @@
|
||||
|
||||
#include "frc/AnalogInput.h"
|
||||
#include "frc/WPIErrors.h"
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
AnalogTrigger::AnalogTrigger(int channel)
|
||||
: AnalogTrigger(new AnalogInput(channel)) {
|
||||
m_ownsAnalog = true;
|
||||
AddChild(m_analogInput);
|
||||
SendableRegistry::GetInstance().AddChild(this, m_analogInput);
|
||||
}
|
||||
|
||||
AnalogTrigger::AnalogTrigger(AnalogInput* input) {
|
||||
@@ -36,7 +37,8 @@ AnalogTrigger::AnalogTrigger(AnalogInput* input) {
|
||||
m_index = index;
|
||||
|
||||
HAL_Report(HALUsageReporting::kResourceType_AnalogTrigger, input->m_channel);
|
||||
SetName("AnalogTrigger", input->GetChannel());
|
||||
SendableRegistry::GetInstance().AddLW(this, "AnalogTrigger",
|
||||
input->GetChannel());
|
||||
}
|
||||
|
||||
AnalogTrigger::~AnalogTrigger() {
|
||||
@@ -50,7 +52,7 @@ AnalogTrigger::~AnalogTrigger() {
|
||||
|
||||
AnalogTrigger::AnalogTrigger(AnalogTrigger&& rhs)
|
||||
: ErrorBase(std::move(rhs)),
|
||||
SendableBase(std::move(rhs)),
|
||||
SendableHelper(std::move(rhs)),
|
||||
m_index(std::move(rhs.m_index)),
|
||||
m_trigger(std::move(rhs.m_trigger)) {
|
||||
std::swap(m_analogInput, rhs.m_analogInput);
|
||||
@@ -59,7 +61,7 @@ AnalogTrigger::AnalogTrigger(AnalogTrigger&& rhs)
|
||||
|
||||
AnalogTrigger& AnalogTrigger::operator=(AnalogTrigger&& rhs) {
|
||||
ErrorBase::operator=(std::move(rhs));
|
||||
SendableBase::operator=(std::move(rhs));
|
||||
SendableHelper::operator=(std::move(rhs));
|
||||
|
||||
m_index = std::move(rhs.m_index);
|
||||
m_trigger = std::move(rhs.m_trigger);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2014-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2014-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#include "frc/WPIErrors.h"
|
||||
#include "frc/smartdashboard/SendableBuilder.h"
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
@@ -20,7 +21,7 @@ BuiltInAccelerometer::BuiltInAccelerometer(Range range) {
|
||||
|
||||
HAL_Report(HALUsageReporting::kResourceType_Accelerometer, 0, 0,
|
||||
"Built-in accelerometer");
|
||||
SetName("BuiltInAccel", 0);
|
||||
SendableRegistry::GetInstance().AddLW(this, "BuiltInAccel");
|
||||
}
|
||||
|
||||
void BuiltInAccelerometer::SetRange(Range range) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2014-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2014-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "frc/WPIErrors.h"
|
||||
#include "frc/smartdashboard/SendableBuilder.h"
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
@@ -28,7 +29,7 @@ Compressor::Compressor(int pcmID) : m_module(pcmID) {
|
||||
SetClosedLoopControl(true);
|
||||
|
||||
HAL_Report(HALUsageReporting::kResourceType_Compressor, pcmID);
|
||||
SetName("Compressor", pcmID);
|
||||
SendableRegistry::GetInstance().AddLW(this, "Compressor", pcmID);
|
||||
}
|
||||
|
||||
void Compressor::Start() {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "frc/DigitalInput.h"
|
||||
#include "frc/WPIErrors.h"
|
||||
#include "frc/smartdashboard/SendableBuilder.h"
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
@@ -26,7 +27,7 @@ Counter::Counter(Mode mode) {
|
||||
SetMaxPeriod(.5);
|
||||
|
||||
HAL_Report(HALUsageReporting::kResourceType_Counter, m_index, mode);
|
||||
SetName("Counter", m_index);
|
||||
SendableRegistry::GetInstance().AddLW(this, "Counter", m_index);
|
||||
}
|
||||
|
||||
Counter::Counter(int channel) : Counter(kTwoPulse) {
|
||||
@@ -95,7 +96,7 @@ Counter::~Counter() {
|
||||
void Counter::SetUpSource(int channel) {
|
||||
if (StatusIsFatal()) return;
|
||||
SetUpSource(std::make_shared<DigitalInput>(channel));
|
||||
AddChild(m_upSource);
|
||||
SendableRegistry::GetInstance().AddChild(this, m_upSource.get());
|
||||
}
|
||||
|
||||
void Counter::SetUpSource(AnalogTrigger* analogTrigger,
|
||||
@@ -159,7 +160,7 @@ void Counter::ClearUpSource() {
|
||||
void Counter::SetDownSource(int channel) {
|
||||
if (StatusIsFatal()) return;
|
||||
SetDownSource(std::make_shared<DigitalInput>(channel));
|
||||
AddChild(m_downSource);
|
||||
SendableRegistry::GetInstance().AddChild(this, m_downSource.get());
|
||||
}
|
||||
|
||||
void Counter::SetDownSource(AnalogTrigger* analogTrigger,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
#include <hal/HAL.h>
|
||||
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
DMC60::DMC60(int channel) : PWMSpeedController(channel) {
|
||||
@@ -32,5 +34,5 @@ DMC60::DMC60(int channel) : PWMSpeedController(channel) {
|
||||
SetZeroLatch();
|
||||
|
||||
HAL_Report(HALUsageReporting::kResourceType_DigilentDMC60, GetChannel());
|
||||
SetName("DMC60", GetChannel());
|
||||
SendableRegistry::GetInstance().SetName(this, "DMC60", GetChannel());
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "frc/SensorUtil.h"
|
||||
#include "frc/Utility.h"
|
||||
#include "frc/WPIErrors.h"
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
@@ -38,7 +39,8 @@ DigitalGlitchFilter::DigitalGlitchFilter() {
|
||||
|
||||
HAL_Report(HALUsageReporting::kResourceType_DigitalGlitchFilter,
|
||||
m_channelIndex);
|
||||
SetName("DigitalGlitchFilter", m_channelIndex);
|
||||
SendableRegistry::GetInstance().AddLW(this, "DigitalGlitchFilter",
|
||||
m_channelIndex);
|
||||
}
|
||||
|
||||
DigitalGlitchFilter::~DigitalGlitchFilter() {
|
||||
@@ -49,13 +51,13 @@ DigitalGlitchFilter::~DigitalGlitchFilter() {
|
||||
}
|
||||
|
||||
DigitalGlitchFilter::DigitalGlitchFilter(DigitalGlitchFilter&& rhs)
|
||||
: ErrorBase(std::move(rhs)), SendableBase(std::move(rhs)) {
|
||||
: ErrorBase(std::move(rhs)), SendableHelper(std::move(rhs)) {
|
||||
std::swap(m_channelIndex, rhs.m_channelIndex);
|
||||
}
|
||||
|
||||
DigitalGlitchFilter& DigitalGlitchFilter::operator=(DigitalGlitchFilter&& rhs) {
|
||||
ErrorBase::operator=(std::move(rhs));
|
||||
SendableBase::operator=(std::move(rhs));
|
||||
SendableHelper::operator=(std::move(rhs));
|
||||
|
||||
std::swap(m_channelIndex, rhs.m_channelIndex);
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "frc/SensorUtil.h"
|
||||
#include "frc/WPIErrors.h"
|
||||
#include "frc/smartdashboard/SendableBuilder.h"
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
@@ -40,7 +41,7 @@ DigitalInput::DigitalInput(int channel) {
|
||||
}
|
||||
|
||||
HAL_Report(HALUsageReporting::kResourceType_DigitalInput, channel);
|
||||
SetName("DigitalInput", channel);
|
||||
SendableRegistry::GetInstance().AddLW(this, "DigitalInput", channel);
|
||||
}
|
||||
|
||||
DigitalInput::~DigitalInput() {
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "frc/SensorUtil.h"
|
||||
#include "frc/WPIErrors.h"
|
||||
#include "frc/smartdashboard/SendableBuilder.h"
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
@@ -41,7 +42,7 @@ DigitalOutput::DigitalOutput(int channel) {
|
||||
}
|
||||
|
||||
HAL_Report(HALUsageReporting::kResourceType_DigitalOutput, channel);
|
||||
SetName("DigitalOutput", channel);
|
||||
SendableRegistry::GetInstance().AddLW(this, "DigitalOutput", channel);
|
||||
}
|
||||
|
||||
DigitalOutput::~DigitalOutput() {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "frc/SensorUtil.h"
|
||||
#include "frc/WPIErrors.h"
|
||||
#include "frc/smartdashboard/SendableBuilder.h"
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
@@ -75,7 +76,9 @@ DoubleSolenoid::DoubleSolenoid(int moduleNumber, int forwardChannel,
|
||||
m_moduleNumber);
|
||||
HAL_Report(HALUsageReporting::kResourceType_Solenoid, m_reverseChannel,
|
||||
m_moduleNumber);
|
||||
SetName("DoubleSolenoid", m_moduleNumber, m_forwardChannel);
|
||||
|
||||
SendableRegistry::GetInstance().AddLW(this, "DoubleSolenoid", m_moduleNumber,
|
||||
m_forwardChannel);
|
||||
}
|
||||
|
||||
DoubleSolenoid::~DoubleSolenoid() {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "frc/DigitalInput.h"
|
||||
#include "frc/WPIErrors.h"
|
||||
#include "frc/smartdashboard/SendableBuilder.h"
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
@@ -24,8 +25,9 @@ Encoder::Encoder(int aChannel, int bChannel, bool reverseDirection,
|
||||
m_aSource = std::make_shared<DigitalInput>(aChannel);
|
||||
m_bSource = std::make_shared<DigitalInput>(bChannel);
|
||||
InitEncoder(reverseDirection, encodingType);
|
||||
AddChild(m_aSource);
|
||||
AddChild(m_bSource);
|
||||
auto& registry = SendableRegistry::GetInstance();
|
||||
registry.AddChild(this, m_aSource.get());
|
||||
registry.AddChild(this, m_bSource.get());
|
||||
}
|
||||
|
||||
Encoder::Encoder(DigitalSource* aSource, DigitalSource* bSource,
|
||||
@@ -201,7 +203,7 @@ double Encoder::PIDGet() {
|
||||
void Encoder::SetIndexSource(int channel, Encoder::IndexingType type) {
|
||||
// Force digital input if just given an index
|
||||
m_indexSource = std::make_shared<DigitalInput>(channel);
|
||||
AddChild(m_indexSource);
|
||||
SendableRegistry::GetInstance().AddChild(this, m_indexSource.get());
|
||||
SetIndexSource(*m_indexSource.get(), type);
|
||||
}
|
||||
|
||||
@@ -250,7 +252,8 @@ void Encoder::InitEncoder(bool reverseDirection, EncodingType encodingType) {
|
||||
|
||||
HAL_Report(HALUsageReporting::kResourceType_Encoder, GetFPGAIndex(),
|
||||
encodingType);
|
||||
SetName("Encoder", m_aSource->GetChannel());
|
||||
SendableRegistry::GetInstance().AddLW(this, "Encoder",
|
||||
m_aSource->GetChannel());
|
||||
}
|
||||
|
||||
double Encoder::DecodingScaleFactor() const {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "frc/GearTooth.h"
|
||||
|
||||
#include "frc/smartdashboard/SendableBuilder.h"
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
@@ -15,20 +16,22 @@ constexpr double GearTooth::kGearToothThreshold;
|
||||
|
||||
GearTooth::GearTooth(int channel, bool directionSensitive) : Counter(channel) {
|
||||
EnableDirectionSensing(directionSensitive);
|
||||
SetName("GearTooth", channel);
|
||||
SendableRegistry::GetInstance().SetName(this, "GearTooth", channel);
|
||||
}
|
||||
|
||||
GearTooth::GearTooth(DigitalSource* source, bool directionSensitive)
|
||||
: Counter(source) {
|
||||
EnableDirectionSensing(directionSensitive);
|
||||
SetName("GearTooth", source->GetChannel());
|
||||
SendableRegistry::GetInstance().SetName(this, "GearTooth",
|
||||
source->GetChannel());
|
||||
}
|
||||
|
||||
GearTooth::GearTooth(std::shared_ptr<DigitalSource> source,
|
||||
bool directionSensitive)
|
||||
: Counter(source) {
|
||||
EnableDirectionSensing(directionSensitive);
|
||||
SetName("GearTooth", source->GetChannel());
|
||||
SendableRegistry::GetInstance().SetName(this, "GearTooth",
|
||||
source->GetChannel());
|
||||
}
|
||||
|
||||
void GearTooth::EnableDirectionSensing(bool directionSensitive) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
#include <hal/HAL.h>
|
||||
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
Jaguar::Jaguar(int channel) : PWMSpeedController(channel) {
|
||||
@@ -26,5 +28,5 @@ Jaguar::Jaguar(int channel) : PWMSpeedController(channel) {
|
||||
SetZeroLatch();
|
||||
|
||||
HAL_Report(HALUsageReporting::kResourceType_Jaguar, GetChannel());
|
||||
SetName("Jaguar", GetChannel());
|
||||
SendableRegistry::GetInstance().SetName(this, "Jaguar", GetChannel());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -10,13 +10,15 @@
|
||||
#include <hal/HAL.h>
|
||||
|
||||
#include "frc/smartdashboard/SendableBuilder.h"
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
NidecBrushless::NidecBrushless(int pwmChannel, int dioChannel)
|
||||
: m_dio(dioChannel), m_pwm(pwmChannel) {
|
||||
AddChild(&m_dio);
|
||||
AddChild(&m_pwm);
|
||||
auto& registry = SendableRegistry::GetInstance();
|
||||
registry.AddChild(this, &m_dio);
|
||||
registry.AddChild(this, &m_pwm);
|
||||
SetExpiration(0.0);
|
||||
SetSafetyEnabled(false);
|
||||
|
||||
@@ -25,7 +27,7 @@ NidecBrushless::NidecBrushless(int pwmChannel, int dioChannel)
|
||||
m_dio.EnablePWM(0.5);
|
||||
|
||||
HAL_Report(HALUsageReporting::kResourceType_NidecBrushless, pwmChannel);
|
||||
SetName("Nidec Brushless", pwmChannel);
|
||||
registry.AddLW(this, "Nidec Brushless", pwmChannel);
|
||||
}
|
||||
|
||||
void NidecBrushless::Set(double speed) {
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "frc/PIDOutput.h"
|
||||
#include "frc/smartdashboard/SendableBuilder.h"
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
@@ -27,8 +28,7 @@ PIDBase::PIDBase(double Kp, double Ki, double Kd, PIDSource& source,
|
||||
: PIDBase(Kp, Ki, Kd, 0.0, source, output) {}
|
||||
|
||||
PIDBase::PIDBase(double Kp, double Ki, double Kd, double Kf, PIDSource& source,
|
||||
PIDOutput& output)
|
||||
: SendableBase(false) {
|
||||
PIDOutput& output) {
|
||||
m_P = Kp;
|
||||
m_I = Ki;
|
||||
m_D = Kd;
|
||||
@@ -44,7 +44,7 @@ PIDBase::PIDBase(double Kp, double Ki, double Kd, double Kf, PIDSource& source,
|
||||
static int instances = 0;
|
||||
instances++;
|
||||
HAL_Report(HALUsageReporting::kResourceType_PIDController, instances);
|
||||
SetName("PIDController", instances);
|
||||
SendableRegistry::GetInstance().Add(this, "PIDController", instances);
|
||||
}
|
||||
|
||||
double PIDBase::Get() const {
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "frc/Utility.h"
|
||||
#include "frc/WPIErrors.h"
|
||||
#include "frc/smartdashboard/SendableBuilder.h"
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
@@ -46,7 +47,7 @@ PWM::PWM(int channel) {
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
|
||||
HAL_Report(HALUsageReporting::kResourceType_PWM, channel);
|
||||
SetName("PWM", channel);
|
||||
SendableRegistry::GetInstance().AddLW(this, "PWM", channel);
|
||||
|
||||
SetSafetyEnabled(false);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
#include <hal/HAL.h>
|
||||
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
PWMSparkMax::PWMSparkMax(int channel) : PWMSpeedController(channel) {
|
||||
@@ -26,5 +28,5 @@ PWMSparkMax::PWMSparkMax(int channel) : PWMSpeedController(channel) {
|
||||
SetZeroLatch();
|
||||
|
||||
HAL_Report(HALUsageReporting::kResourceType_RevSparkMaxPWM, GetChannel());
|
||||
SetName("PWMSparkMax", GetChannel());
|
||||
SendableRegistry::GetInstance().SetName(this, "PWMSparkMax", GetChannel());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
#include <hal/HAL.h>
|
||||
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
PWMTalonSRX::PWMTalonSRX(int channel) : PWMSpeedController(channel) {
|
||||
@@ -30,5 +32,5 @@ PWMTalonSRX::PWMTalonSRX(int channel) : PWMSpeedController(channel) {
|
||||
SetZeroLatch();
|
||||
|
||||
HAL_Report(HALUsageReporting::kResourceType_PWMTalonSRX, GetChannel());
|
||||
SetName("PWMTalonSRX", GetChannel());
|
||||
SendableRegistry::GetInstance().SetName(this, "PWMTalonSRX", GetChannel());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
#include <hal/HAL.h>
|
||||
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
PWMVictorSPX::PWMVictorSPX(int channel) : PWMSpeedController(channel) {
|
||||
@@ -30,5 +32,5 @@ PWMVictorSPX::PWMVictorSPX(int channel) : PWMSpeedController(channel) {
|
||||
SetZeroLatch();
|
||||
|
||||
HAL_Report(HALUsageReporting::kResourceType_PWMVictorSPX, GetChannel());
|
||||
SetName("PWMVictorSPX", GetChannel());
|
||||
SendableRegistry::GetInstance().SetName(this, "PWMVictorSPX", GetChannel());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2014-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2014-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "frc/SensorUtil.h"
|
||||
#include "frc/WPIErrors.h"
|
||||
#include "frc/smartdashboard/SendableBuilder.h"
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
@@ -34,7 +35,7 @@ PowerDistributionPanel::PowerDistributionPanel(int module) {
|
||||
}
|
||||
|
||||
HAL_Report(HALUsageReporting::kResourceType_PDP, module);
|
||||
SetName("PowerDistributionPanel", module);
|
||||
SendableRegistry::GetInstance().AddLW(this, "PowerDistributionPanel", module);
|
||||
}
|
||||
|
||||
double PowerDistributionPanel::GetVoltage() const {
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "frc/SensorUtil.h"
|
||||
#include "frc/WPIErrors.h"
|
||||
#include "frc/smartdashboard/SendableBuilder.h"
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
@@ -76,7 +77,7 @@ Relay::Relay(int channel, Relay::Direction direction)
|
||||
}
|
||||
}
|
||||
|
||||
SetName("Relay", m_channel);
|
||||
SendableRegistry::GetInstance().AddLW(this, "Relay", m_channel);
|
||||
}
|
||||
|
||||
Relay::~Relay() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
#include <hal/HAL.h>
|
||||
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
SD540::SD540(int channel) : PWMSpeedController(channel) {
|
||||
@@ -31,5 +33,5 @@ SD540::SD540(int channel) : PWMSpeedController(channel) {
|
||||
SetZeroLatch();
|
||||
|
||||
HAL_Report(HALUsageReporting::kResourceType_MindsensorsSD540, GetChannel());
|
||||
SetName("SD540", GetChannel());
|
||||
SendableRegistry::GetInstance().SetName(this, "SD540", GetChannel());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <hal/HAL.h>
|
||||
|
||||
#include "frc/smartdashboard/SendableBuilder.h"
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
@@ -27,7 +28,7 @@ Servo::Servo(int channel) : PWM(channel) {
|
||||
SetPeriodMultiplier(kPeriodMultiplier_4X);
|
||||
|
||||
HAL_Report(HALUsageReporting::kResourceType_Servo, channel);
|
||||
SetName("Servo", channel);
|
||||
SendableRegistry::GetInstance().SetName(this, "Servo", channel);
|
||||
}
|
||||
|
||||
void Servo::Set(double value) { SetPosition(value); }
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "frc/SensorUtil.h"
|
||||
#include "frc/WPIErrors.h"
|
||||
#include "frc/smartdashboard/SendableBuilder.h"
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
@@ -47,7 +48,8 @@ Solenoid::Solenoid(int moduleNumber, int channel)
|
||||
|
||||
HAL_Report(HALUsageReporting::kResourceType_Solenoid, m_channel,
|
||||
m_moduleNumber);
|
||||
SetName("Solenoid", m_moduleNumber, m_channel);
|
||||
SendableRegistry::GetInstance().AddLW(this, "Solenoid", m_moduleNumber,
|
||||
m_channel);
|
||||
}
|
||||
|
||||
Solenoid::~Solenoid() { HAL_FreeSolenoidPort(m_solenoidHandle); }
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
#include <hal/HAL.h>
|
||||
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
Spark::Spark(int channel) : PWMSpeedController(channel) {
|
||||
@@ -31,5 +33,5 @@ Spark::Spark(int channel) : PWMSpeedController(channel) {
|
||||
SetZeroLatch();
|
||||
|
||||
HAL_Report(HALUsageReporting::kResourceType_RevSPARK, GetChannel());
|
||||
SetName("Spark", GetChannel());
|
||||
SendableRegistry::GetInstance().SetName(this, "Spark", GetChannel());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
#include <hal/HAL.h>
|
||||
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
Talon::Talon(int channel) : PWMSpeedController(channel) {
|
||||
@@ -31,5 +33,5 @@ Talon::Talon(int channel) : PWMSpeedController(channel) {
|
||||
SetZeroLatch();
|
||||
|
||||
HAL_Report(HALUsageReporting::kResourceType_Talon, GetChannel());
|
||||
SetName("Talon", GetChannel());
|
||||
SendableRegistry::GetInstance().SetName(this, "Talon", GetChannel());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "frc/Utility.h"
|
||||
#include "frc/WPIErrors.h"
|
||||
#include "frc/smartdashboard/SendableBuilder.h"
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
@@ -31,8 +32,9 @@ Ultrasonic::Ultrasonic(int pingChannel, int echoChannel, DistanceUnit units)
|
||||
m_counter(m_echoChannel) {
|
||||
m_units = units;
|
||||
Initialize();
|
||||
AddChild(m_pingChannel);
|
||||
AddChild(m_echoChannel);
|
||||
auto& registry = SendableRegistry::GetInstance();
|
||||
registry.AddChild(this, m_pingChannel.get());
|
||||
registry.AddChild(this, m_echoChannel.get());
|
||||
}
|
||||
|
||||
Ultrasonic::Ultrasonic(DigitalOutput* pingChannel, DigitalInput* echoChannel,
|
||||
@@ -189,7 +191,8 @@ void Ultrasonic::Initialize() {
|
||||
static int instances = 0;
|
||||
instances++;
|
||||
HAL_Report(HALUsageReporting::kResourceType_Ultrasonic, instances);
|
||||
SetName("Ultrasonic", m_echoChannel->GetChannel());
|
||||
SendableRegistry::GetInstance().AddLW(this, "Ultrasonic",
|
||||
m_echoChannel->GetChannel());
|
||||
}
|
||||
|
||||
void Ultrasonic::UltrasonicChecker() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
#include <hal/HAL.h>
|
||||
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
Victor::Victor(int channel) : PWMSpeedController(channel) {
|
||||
@@ -32,5 +34,5 @@ Victor::Victor(int channel) : PWMSpeedController(channel) {
|
||||
SetZeroLatch();
|
||||
|
||||
HAL_Report(HALUsageReporting::kResourceType_Victor, GetChannel());
|
||||
SetName("Victor", GetChannel());
|
||||
SendableRegistry::GetInstance().SetName(this, "Victor", GetChannel());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
#include <hal/HAL.h>
|
||||
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
VictorSP::VictorSP(int channel) : PWMSpeedController(channel) {
|
||||
@@ -31,5 +33,5 @@ VictorSP::VictorSP(int channel) : PWMSpeedController(channel) {
|
||||
SetZeroLatch();
|
||||
|
||||
HAL_Report(HALUsageReporting::kResourceType_VictorSP, GetChannel());
|
||||
SetName("VictorSP", GetChannel());
|
||||
SendableRegistry::GetInstance().SetName(this, "VictorSP", GetChannel());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2011-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2011-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "frc/commands/Scheduler.h"
|
||||
#include "frc/livewindow/LiveWindow.h"
|
||||
#include "frc/smartdashboard/SendableBuilder.h"
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
@@ -31,7 +32,7 @@ Command::Command(Subsystem& subsystem) : Command("", -1.0) {
|
||||
Requires(&subsystem);
|
||||
}
|
||||
|
||||
Command::Command(const wpi::Twine& name, double timeout) : SendableBase(false) {
|
||||
Command::Command(const wpi::Twine& name, double timeout) {
|
||||
// We use -1.0 to indicate no timeout.
|
||||
if (timeout < 0.0 && timeout != -1.0)
|
||||
wpi_setWPIErrorWithContext(ParameterOutOfRange, "timeout < 0.0");
|
||||
@@ -41,9 +42,10 @@ Command::Command(const wpi::Twine& name, double timeout) : SendableBase(false) {
|
||||
// If name contains an empty string
|
||||
if (name.isTriviallyEmpty() ||
|
||||
(name.isSingleStringRef() && name.getSingleStringRef().empty())) {
|
||||
SetName("Command_" + wpi::Twine(typeid(*this).name()));
|
||||
SendableRegistry::GetInstance().Add(
|
||||
this, "Command_" + wpi::Twine(typeid(*this).name()));
|
||||
} else {
|
||||
SetName(name);
|
||||
SendableRegistry::GetInstance().Add(this, name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,9 +230,27 @@ void Command::StartRunning() {
|
||||
|
||||
void Command::StartTiming() { m_startTime = Timer::GetFPGATimestamp(); }
|
||||
|
||||
std::string Command::GetName() const {
|
||||
return SendableRegistry::GetInstance().GetName(this);
|
||||
}
|
||||
|
||||
void Command::SetName(const wpi::Twine& name) {
|
||||
SendableRegistry::GetInstance().SetName(this, name);
|
||||
}
|
||||
|
||||
std::string Command::GetSubsystem() const {
|
||||
return SendableRegistry::GetInstance().GetSubsystem(this);
|
||||
}
|
||||
|
||||
void Command::SetSubsystem(const wpi::Twine& name) {
|
||||
SendableRegistry::GetInstance().SetSubsystem(this, name);
|
||||
}
|
||||
|
||||
void Command::InitSendable(SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Command");
|
||||
builder.AddStringProperty(".name", [=]() { return GetName(); }, nullptr);
|
||||
builder.AddStringProperty(
|
||||
".name", [=]() { return SendableRegistry::GetInstance().GetName(this); },
|
||||
nullptr);
|
||||
builder.AddBooleanProperty("running", [=]() { return IsRunning(); },
|
||||
[=](bool value) {
|
||||
if (value) {
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "frc/commands/Command.h"
|
||||
#include "frc/commands/Subsystem.h"
|
||||
#include "frc/smartdashboard/SendableBuilder.h"
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
@@ -182,8 +183,9 @@ void Scheduler::InitSendable(SendableBuilder& builder) {
|
||||
if (m_impl->runningCommandsChanged) {
|
||||
m_impl->commandsBuf.resize(0);
|
||||
m_impl->idsBuf.resize(0);
|
||||
auto& registry = SendableRegistry::GetInstance();
|
||||
for (const auto& command : m_impl->commands) {
|
||||
m_impl->commandsBuf.emplace_back(command->GetName());
|
||||
m_impl->commandsBuf.emplace_back(registry.GetName(command));
|
||||
m_impl->idsBuf.emplace_back(command->GetID());
|
||||
}
|
||||
nt::NetworkTableEntry(namesEntry).SetStringArray(m_impl->commandsBuf);
|
||||
@@ -195,7 +197,7 @@ void Scheduler::InitSendable(SendableBuilder& builder) {
|
||||
Scheduler::Scheduler() : m_impl(new Impl) {
|
||||
HAL_Report(HALUsageReporting::kResourceType_Command,
|
||||
HALUsageReporting::kCommand_Scheduler);
|
||||
SetName("Scheduler");
|
||||
SendableRegistry::GetInstance().AddLW(this, "Scheduler");
|
||||
}
|
||||
|
||||
Scheduler::~Scheduler() {}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2011-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2011-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -12,11 +12,12 @@
|
||||
#include "frc/commands/Scheduler.h"
|
||||
#include "frc/livewindow/LiveWindow.h"
|
||||
#include "frc/smartdashboard/SendableBuilder.h"
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
Subsystem::Subsystem(const wpi::Twine& name) {
|
||||
SetName(name, name);
|
||||
SendableRegistry::GetInstance().AddLW(this, name, name);
|
||||
Scheduler::GetInstance()->RegisterSubsystem(this);
|
||||
}
|
||||
|
||||
@@ -46,7 +47,7 @@ Command* Subsystem::GetDefaultCommand() {
|
||||
wpi::StringRef Subsystem::GetDefaultCommandName() {
|
||||
Command* defaultCommand = GetDefaultCommand();
|
||||
if (defaultCommand) {
|
||||
return defaultCommand->GetName();
|
||||
return SendableRegistry::GetInstance().GetName(defaultCommand);
|
||||
} else {
|
||||
return wpi::StringRef();
|
||||
}
|
||||
@@ -62,7 +63,7 @@ Command* Subsystem::GetCurrentCommand() const { return m_currentCommand; }
|
||||
wpi::StringRef Subsystem::GetCurrentCommandName() const {
|
||||
Command* currentCommand = GetCurrentCommand();
|
||||
if (currentCommand) {
|
||||
return currentCommand->GetName();
|
||||
return SendableRegistry::GetInstance().GetName(currentCommand);
|
||||
} else {
|
||||
return wpi::StringRef();
|
||||
}
|
||||
@@ -72,6 +73,22 @@ void Subsystem::Periodic() {}
|
||||
|
||||
void Subsystem::InitDefaultCommand() {}
|
||||
|
||||
std::string Subsystem::GetName() const {
|
||||
return SendableRegistry::GetInstance().GetName(this);
|
||||
}
|
||||
|
||||
void Subsystem::SetName(const wpi::Twine& name) {
|
||||
SendableRegistry::GetInstance().SetName(this, name);
|
||||
}
|
||||
|
||||
std::string Subsystem::GetSubsystem() const {
|
||||
return SendableRegistry::GetInstance().GetSubsystem(this);
|
||||
}
|
||||
|
||||
void Subsystem::SetSubsystem(const wpi::Twine& name) {
|
||||
SendableRegistry::GetInstance().SetSubsystem(this, name);
|
||||
}
|
||||
|
||||
void Subsystem::AddChild(const wpi::Twine& name,
|
||||
std::shared_ptr<Sendable> child) {
|
||||
AddChild(name, *child);
|
||||
@@ -82,8 +99,9 @@ void Subsystem::AddChild(const wpi::Twine& name, Sendable* child) {
|
||||
}
|
||||
|
||||
void Subsystem::AddChild(const wpi::Twine& name, Sendable& child) {
|
||||
child.SetName(GetSubsystem(), name);
|
||||
LiveWindow::GetInstance()->Add(&child);
|
||||
auto& registry = SendableRegistry::GetInstance();
|
||||
registry.AddLW(&child, registry.GetSubsystem(this), name);
|
||||
registry.AddChild(this, &child);
|
||||
}
|
||||
|
||||
void Subsystem::AddChild(std::shared_ptr<Sendable> child) { AddChild(*child); }
|
||||
@@ -91,8 +109,10 @@ void Subsystem::AddChild(std::shared_ptr<Sendable> child) { AddChild(*child); }
|
||||
void Subsystem::AddChild(Sendable* child) { AddChild(*child); }
|
||||
|
||||
void Subsystem::AddChild(Sendable& child) {
|
||||
child.SetSubsystem(GetSubsystem());
|
||||
LiveWindow::GetInstance()->Add(&child);
|
||||
auto& registry = SendableRegistry::GetInstance();
|
||||
registry.SetSubsystem(&child, registry.GetSubsystem(this));
|
||||
registry.EnableLiveWindow(&child);
|
||||
registry.AddChild(this, &child);
|
||||
}
|
||||
|
||||
void Subsystem::ConfirmCommand() {
|
||||
|
||||
@@ -13,16 +13,17 @@
|
||||
#include <hal/HAL.h>
|
||||
|
||||
#include "frc/smartdashboard/SendableBuilder.h"
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc2;
|
||||
|
||||
PIDController::PIDController(double Kp, double Ki, double Kd,
|
||||
units::second_t period)
|
||||
: frc::SendableBase(false), m_Kp(Kp), m_Ki(Ki), m_Kd(Kd), m_period(period) {
|
||||
: m_Kp(Kp), m_Ki(Ki), m_Kd(Kd), m_period(period) {
|
||||
static int instances = 0;
|
||||
instances++;
|
||||
HAL_Report(HALUsageReporting::kResourceType_PIDController, instances);
|
||||
SetName("PIDController", instances);
|
||||
frc::SendableRegistry::GetInstance().Add(this, "PIDController", instances);
|
||||
}
|
||||
|
||||
void PIDController::SetP(double Kp) { m_Kp = Kp; }
|
||||
|
||||
@@ -14,17 +14,19 @@
|
||||
|
||||
#include "frc/SpeedController.h"
|
||||
#include "frc/smartdashboard/SendableBuilder.h"
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
DifferentialDrive::DifferentialDrive(SpeedController& leftMotor,
|
||||
SpeedController& rightMotor)
|
||||
: m_leftMotor(leftMotor), m_rightMotor(rightMotor) {
|
||||
AddChild(&m_leftMotor);
|
||||
AddChild(&m_rightMotor);
|
||||
auto& registry = SendableRegistry::GetInstance();
|
||||
registry.AddChild(this, &m_leftMotor);
|
||||
registry.AddChild(this, &m_rightMotor);
|
||||
static int instances = 0;
|
||||
++instances;
|
||||
SetName("DifferentialDrive", instances);
|
||||
registry.AddLW(this, "DifferentialDrive", instances);
|
||||
}
|
||||
|
||||
void DifferentialDrive::ArcadeDrive(double xSpeed, double zRotation,
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
#include "frc/SpeedController.h"
|
||||
#include "frc/smartdashboard/SendableBuilder.h"
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
@@ -35,12 +36,13 @@ KilloughDrive::KilloughDrive(SpeedController& leftMotor,
|
||||
std::sin(rightMotorAngle * (wpi::math::pi / 180.0))};
|
||||
m_backVec = {std::cos(backMotorAngle * (wpi::math::pi / 180.0)),
|
||||
std::sin(backMotorAngle * (wpi::math::pi / 180.0))};
|
||||
AddChild(&m_leftMotor);
|
||||
AddChild(&m_rightMotor);
|
||||
AddChild(&m_backMotor);
|
||||
auto& registry = SendableRegistry::GetInstance();
|
||||
registry.AddChild(this, &m_leftMotor);
|
||||
registry.AddChild(this, &m_rightMotor);
|
||||
registry.AddChild(this, &m_backMotor);
|
||||
static int instances = 0;
|
||||
++instances;
|
||||
SetName("KilloughDrive", instances);
|
||||
registry.AddLW(this, "KilloughDrive", instances);
|
||||
}
|
||||
|
||||
void KilloughDrive::DriveCartesian(double ySpeed, double xSpeed,
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "frc/SpeedController.h"
|
||||
#include "frc/drive/Vector2d.h"
|
||||
#include "frc/smartdashboard/SendableBuilder.h"
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
@@ -27,13 +28,14 @@ MecanumDrive::MecanumDrive(SpeedController& frontLeftMotor,
|
||||
m_rearLeftMotor(rearLeftMotor),
|
||||
m_frontRightMotor(frontRightMotor),
|
||||
m_rearRightMotor(rearRightMotor) {
|
||||
AddChild(&m_frontLeftMotor);
|
||||
AddChild(&m_rearLeftMotor);
|
||||
AddChild(&m_frontRightMotor);
|
||||
AddChild(&m_rearRightMotor);
|
||||
auto& registry = SendableRegistry::GetInstance();
|
||||
registry.AddChild(this, &m_frontLeftMotor);
|
||||
registry.AddChild(this, &m_rearLeftMotor);
|
||||
registry.AddChild(this, &m_frontRightMotor);
|
||||
registry.AddChild(this, &m_rearRightMotor);
|
||||
static int instances = 0;
|
||||
++instances;
|
||||
SetName("MecanumDrive", instances);
|
||||
registry.AddLW(this, "MecanumDrive", instances);
|
||||
}
|
||||
|
||||
void MecanumDrive::DriveCartesian(double ySpeed, double xSpeed,
|
||||
|
||||
@@ -24,6 +24,14 @@ using namespace frc2;
|
||||
|
||||
Command::~Command() { CommandScheduler::GetInstance().Cancel(this); }
|
||||
|
||||
Command::Command(const Command& rhs) : ErrorBase(rhs) {}
|
||||
|
||||
Command& Command::operator=(const Command& rhs) {
|
||||
ErrorBase::operator=(rhs);
|
||||
m_isGrouped = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Command::Initialize() {}
|
||||
void Command::Execute() {}
|
||||
void Command::End(bool interrupted) {}
|
||||
|
||||
@@ -8,20 +8,14 @@
|
||||
#include "frc2/command/CommandBase.h"
|
||||
|
||||
#include <frc/smartdashboard/SendableBuilder.h>
|
||||
#include <frc/smartdashboard/SendableRegistry.h>
|
||||
#include <frc2/command/CommandScheduler.h>
|
||||
#include <frc2/command/SetUtilities.h>
|
||||
|
||||
using namespace frc2;
|
||||
|
||||
CommandBase::CommandBase() {
|
||||
m_name = Command::GetName();
|
||||
m_subsystem = "Unknown";
|
||||
}
|
||||
|
||||
CommandBase::CommandBase(const CommandBase& other) : Sendable{}, Command{} {
|
||||
m_name = other.m_name;
|
||||
m_subsystem = other.m_subsystem;
|
||||
m_requirements = other.m_requirements;
|
||||
frc::SendableRegistry::GetInstance().AddLW(this, GetTypeName(*this));
|
||||
}
|
||||
|
||||
void CommandBase::AddRequirements(
|
||||
@@ -37,14 +31,20 @@ wpi::SmallSet<Subsystem*, 4> CommandBase::GetRequirements() const {
|
||||
return m_requirements;
|
||||
}
|
||||
|
||||
void CommandBase::SetName(const wpi::Twine& name) { m_name = name.str(); }
|
||||
void CommandBase::SetName(const wpi::Twine& name) {
|
||||
frc::SendableRegistry::GetInstance().SetName(this, name);
|
||||
}
|
||||
|
||||
std::string CommandBase::GetName() const { return m_name; }
|
||||
std::string CommandBase::GetName() const {
|
||||
return frc::SendableRegistry::GetInstance().GetName(this);
|
||||
}
|
||||
|
||||
std::string CommandBase::GetSubsystem() const { return m_subsystem; }
|
||||
std::string CommandBase::GetSubsystem() const {
|
||||
return frc::SendableRegistry::GetInstance().GetSubsystem(this);
|
||||
}
|
||||
|
||||
void CommandBase::SetSubsystem(const wpi::Twine& subsystem) {
|
||||
m_subsystem = subsystem.str();
|
||||
frc::SendableRegistry::GetInstance().SetSubsystem(this, subsystem);
|
||||
}
|
||||
|
||||
void CommandBase::InitSendable(frc::SendableBuilder& builder) {
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <frc/WPIErrors.h>
|
||||
#include <frc/commands/Scheduler.h>
|
||||
#include <frc/smartdashboard/SendableBuilder.h>
|
||||
#include <frc/smartdashboard/SendableRegistry.h>
|
||||
#include <frc2/command/CommandGroupBase.h>
|
||||
#include <frc2/command/Subsystem.h>
|
||||
|
||||
@@ -22,7 +23,9 @@ static bool ContainsKey(const TMap& map, TKey keyToCheck) {
|
||||
return map.find(keyToCheck) != map.end();
|
||||
}
|
||||
|
||||
CommandScheduler::CommandScheduler() { SetName("Scheduler"); }
|
||||
CommandScheduler::CommandScheduler() {
|
||||
frc::SendableRegistry::GetInstance().AddLW(this, "Scheduler");
|
||||
}
|
||||
|
||||
CommandScheduler& CommandScheduler::GetInstance() {
|
||||
static CommandScheduler scheduler;
|
||||
|
||||
@@ -7,15 +7,15 @@
|
||||
|
||||
#include "frc2/command/SubsystemBase.h"
|
||||
|
||||
#include <frc/livewindow/LiveWindow.h>
|
||||
#include <frc/smartdashboard/SendableBuilder.h>
|
||||
#include <frc/smartdashboard/SendableRegistry.h>
|
||||
#include <frc2/command/Command.h>
|
||||
#include <frc2/command/CommandScheduler.h>
|
||||
|
||||
using namespace frc2;
|
||||
|
||||
SubsystemBase::SubsystemBase() {
|
||||
m_name = GetTypeName(*this);
|
||||
frc::SendableRegistry::GetInstance().AddLW(this, GetTypeName(*this));
|
||||
CommandScheduler::GetInstance().RegisterSubsystem({this});
|
||||
}
|
||||
|
||||
@@ -43,15 +43,24 @@ void SubsystemBase::InitSendable(frc::SendableBuilder& builder) {
|
||||
nullptr);
|
||||
}
|
||||
|
||||
std::string SubsystemBase::GetName() const { return m_name; }
|
||||
std::string SubsystemBase::GetName() const {
|
||||
return frc::SendableRegistry::GetInstance().GetName(this);
|
||||
}
|
||||
|
||||
void SubsystemBase::SetName(const wpi::Twine& name) { m_name = name.str(); }
|
||||
void SubsystemBase::SetName(const wpi::Twine& name) {
|
||||
frc::SendableRegistry::GetInstance().SetName(this, name);
|
||||
}
|
||||
|
||||
std::string SubsystemBase::GetSubsystem() const { return GetName(); }
|
||||
std::string SubsystemBase::GetSubsystem() const {
|
||||
return frc::SendableRegistry::GetInstance().GetSubsystem(this);
|
||||
}
|
||||
|
||||
void SubsystemBase::SetSubsystem(const wpi::Twine& name) { SetName(name); }
|
||||
void SubsystemBase::SetSubsystem(const wpi::Twine& name) {
|
||||
frc::SendableRegistry::GetInstance().SetSubsystem(this, name);
|
||||
}
|
||||
|
||||
void SubsystemBase::AddChild(std::string name, frc::Sendable* child) {
|
||||
child->SetName(name);
|
||||
frc::LiveWindow::GetInstance()->Add(child);
|
||||
auto& registry = frc::SendableRegistry::GetInstance();
|
||||
registry.AddLW(child, GetSubsystem(), name);
|
||||
registry.AddChild(this, child);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ using namespace frc2;
|
||||
|
||||
WaitCommand::WaitCommand(units::second_t duration) : m_duration{duration} {
|
||||
auto durationStr = std::to_string(duration.to<double>());
|
||||
SetName(wpi::Twine(m_name) + ": " + wpi::Twine(durationStr) + " seconds");
|
||||
SetName(wpi::Twine(GetName()) + ": " + wpi::Twine(durationStr) + " seconds");
|
||||
}
|
||||
|
||||
void WaitCommand::Initialize() {
|
||||
|
||||
@@ -7,18 +7,14 @@
|
||||
|
||||
#include "frc/livewindow/LiveWindow.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <networktables/NetworkTable.h>
|
||||
#include <networktables/NetworkTableEntry.h>
|
||||
#include <networktables/NetworkTableInstance.h>
|
||||
#include <wpi/DenseMap.h>
|
||||
#include <wpi/SmallString.h>
|
||||
#include <wpi/mutex.h>
|
||||
#include <wpi/raw_ostream.h>
|
||||
|
||||
#include "frc/commands/Scheduler.h"
|
||||
#include "frc/smartdashboard/SendableBuilderImpl.h"
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
@@ -28,8 +24,6 @@ struct LiveWindow::Impl {
|
||||
Impl();
|
||||
|
||||
struct Component {
|
||||
std::shared_ptr<Sendable> sendable;
|
||||
Sendable* parent = nullptr;
|
||||
SendableBuilderImpl builder;
|
||||
bool firstTime = true;
|
||||
bool telemetryEnabled = true;
|
||||
@@ -37,7 +31,8 @@ struct LiveWindow::Impl {
|
||||
|
||||
wpi::mutex mutex;
|
||||
|
||||
wpi::DenseMap<void*, Component> components;
|
||||
SendableRegistry& registry;
|
||||
int dataHandle;
|
||||
|
||||
std::shared_ptr<nt::NetworkTable> liveWindowTable;
|
||||
std::shared_ptr<nt::NetworkTable> statusTable;
|
||||
@@ -46,64 +41,57 @@ struct LiveWindow::Impl {
|
||||
bool startLiveWindow = false;
|
||||
bool liveWindowEnabled = false;
|
||||
bool telemetryEnabled = true;
|
||||
|
||||
std::shared_ptr<Component> GetOrAdd(Sendable* sendable);
|
||||
};
|
||||
|
||||
LiveWindow::Impl::Impl()
|
||||
: liveWindowTable(
|
||||
: registry(SendableRegistry::GetInstance()),
|
||||
dataHandle(registry.GetDataHandle()),
|
||||
liveWindowTable(
|
||||
nt::NetworkTableInstance::GetDefault().GetTable("LiveWindow")) {
|
||||
statusTable = liveWindowTable->GetSubTable(".status");
|
||||
enabledEntry = statusTable->GetEntry("LW Enabled");
|
||||
}
|
||||
|
||||
std::shared_ptr<LiveWindow::Impl::Component> LiveWindow::Impl::GetOrAdd(
|
||||
Sendable* sendable) {
|
||||
auto data = std::static_pointer_cast<Component>(
|
||||
registry.GetData(sendable, dataHandle));
|
||||
if (!data) {
|
||||
data = std::make_shared<Component>();
|
||||
registry.SetData(sendable, dataHandle, data);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
LiveWindow* LiveWindow::GetInstance() {
|
||||
static LiveWindow instance;
|
||||
return &instance;
|
||||
}
|
||||
|
||||
void LiveWindow::Add(std::shared_ptr<Sendable> sendable) {
|
||||
std::scoped_lock lock(m_impl->mutex);
|
||||
auto& comp = m_impl->components[sendable.get()];
|
||||
comp.sendable = sendable;
|
||||
}
|
||||
|
||||
void LiveWindow::Add(Sendable* sendable) {
|
||||
Add(std::shared_ptr<Sendable>(sendable, NullDeleter<Sendable>()));
|
||||
}
|
||||
|
||||
void LiveWindow::AddChild(Sendable* parent, std::shared_ptr<Sendable> child) {
|
||||
AddChild(parent, child.get());
|
||||
}
|
||||
|
||||
void LiveWindow::AddChild(Sendable* parent, void* child) {
|
||||
std::scoped_lock lock(m_impl->mutex);
|
||||
auto& comp = m_impl->components[child];
|
||||
comp.parent = parent;
|
||||
comp.telemetryEnabled = false;
|
||||
}
|
||||
|
||||
bool LiveWindow::Remove(Sendable* sendable) {
|
||||
std::scoped_lock lock(m_impl->mutex);
|
||||
return m_impl->components.erase(sendable);
|
||||
}
|
||||
|
||||
void LiveWindow::EnableTelemetry(Sendable* sendable) {
|
||||
std::scoped_lock lock(m_impl->mutex);
|
||||
// Re-enable global setting in case DisableAllTelemetry() was called.
|
||||
m_impl->telemetryEnabled = true;
|
||||
auto i = m_impl->components.find(sendable);
|
||||
if (i != m_impl->components.end()) i->getSecond().telemetryEnabled = true;
|
||||
m_impl->GetOrAdd(sendable)->telemetryEnabled = true;
|
||||
}
|
||||
|
||||
void LiveWindow::DisableTelemetry(Sendable* sendable) {
|
||||
std::scoped_lock lock(m_impl->mutex);
|
||||
auto i = m_impl->components.find(sendable);
|
||||
if (i != m_impl->components.end()) i->getSecond().telemetryEnabled = false;
|
||||
m_impl->GetOrAdd(sendable)->telemetryEnabled = false;
|
||||
}
|
||||
|
||||
void LiveWindow::DisableAllTelemetry() {
|
||||
std::scoped_lock lock(m_impl->mutex);
|
||||
m_impl->telemetryEnabled = false;
|
||||
for (auto& i : m_impl->components) i.getSecond().telemetryEnabled = false;
|
||||
m_impl->registry.ForeachLiveWindow(
|
||||
m_impl->dataHandle, [&](Sendable*, wpi::StringRef, wpi::StringRef,
|
||||
Sendable*, std::shared_ptr<void>& data) {
|
||||
if (!data) data = std::make_shared<Impl::Component>();
|
||||
std::static_pointer_cast<Impl::Component>(data)->telemetryEnabled =
|
||||
false;
|
||||
});
|
||||
}
|
||||
|
||||
bool LiveWindow::IsEnabled() const {
|
||||
@@ -123,9 +111,13 @@ void LiveWindow::SetEnabled(bool enabled) {
|
||||
scheduler->SetEnabled(false);
|
||||
scheduler->RemoveAll();
|
||||
} else {
|
||||
for (auto& i : m_impl->components) {
|
||||
i.getSecond().builder.StopLiveWindowMode();
|
||||
}
|
||||
m_impl->registry.ForeachLiveWindow(
|
||||
m_impl->dataHandle, [&](Sendable*, wpi::StringRef, wpi::StringRef,
|
||||
Sendable*, std::shared_ptr<void>& data) {
|
||||
if (data)
|
||||
std::static_pointer_cast<Impl::Component>(data)
|
||||
->builder.StopLiveWindowMode();
|
||||
});
|
||||
scheduler->SetEnabled(true);
|
||||
}
|
||||
m_impl->enabledEntry.SetBoolean(enabled);
|
||||
@@ -140,37 +132,42 @@ void LiveWindow::UpdateValuesUnsafe() {
|
||||
// Only do this if either LiveWindow mode or telemetry is enabled.
|
||||
if (!m_impl->liveWindowEnabled && !m_impl->telemetryEnabled) return;
|
||||
|
||||
for (auto& i : m_impl->components) {
|
||||
auto& comp = i.getSecond();
|
||||
if (comp.sendable && !comp.parent &&
|
||||
(m_impl->liveWindowEnabled || comp.telemetryEnabled)) {
|
||||
if (comp.firstTime) {
|
||||
// By holding off creating the NetworkTable entries, it allows the
|
||||
// components to be redefined. This allows default sensor and actuator
|
||||
// values to be created that are replaced with the custom names from
|
||||
// users calling setName.
|
||||
auto name = comp.sendable->GetName();
|
||||
if (name.empty()) continue;
|
||||
auto subsystem = comp.sendable->GetSubsystem();
|
||||
auto ssTable = m_impl->liveWindowTable->GetSubTable(subsystem);
|
||||
std::shared_ptr<NetworkTable> table;
|
||||
// Treat name==subsystem as top level of subsystem
|
||||
if (name == subsystem)
|
||||
table = ssTable;
|
||||
else
|
||||
table = ssTable->GetSubTable(name);
|
||||
table->GetEntry(".name").SetString(name);
|
||||
comp.builder.SetTable(table);
|
||||
comp.sendable->InitSendable(comp.builder);
|
||||
ssTable->GetEntry(".type").SetString("LW Subsystem");
|
||||
m_impl->registry.ForeachLiveWindow(
|
||||
m_impl->dataHandle,
|
||||
[&](Sendable* sendable, wpi::StringRef name, wpi::StringRef subsystem,
|
||||
Sendable* parent, std::shared_ptr<void>& data) {
|
||||
if (!sendable || parent) return;
|
||||
|
||||
comp.firstTime = false;
|
||||
}
|
||||
if (!data) data = std::make_shared<Impl::Component>();
|
||||
|
||||
if (m_impl->startLiveWindow) comp.builder.StartLiveWindowMode();
|
||||
comp.builder.UpdateTable();
|
||||
}
|
||||
}
|
||||
auto& comp = *std::static_pointer_cast<Impl::Component>(data);
|
||||
|
||||
if (!m_impl->liveWindowEnabled && !comp.telemetryEnabled) return;
|
||||
|
||||
if (comp.firstTime) {
|
||||
// By holding off creating the NetworkTable entries, it allows the
|
||||
// components to be redefined. This allows default sensor and actuator
|
||||
// values to be created that are replaced with the custom names from
|
||||
// users calling setName.
|
||||
if (name.empty()) return;
|
||||
auto ssTable = m_impl->liveWindowTable->GetSubTable(subsystem);
|
||||
std::shared_ptr<NetworkTable> table;
|
||||
// Treat name==subsystem as top level of subsystem
|
||||
if (name == subsystem)
|
||||
table = ssTable;
|
||||
else
|
||||
table = ssTable->GetSubTable(name);
|
||||
table->GetEntry(".name").SetString(name);
|
||||
comp.builder.SetTable(table);
|
||||
sendable->InitSendable(comp.builder);
|
||||
ssTable->GetEntry(".type").SetString("LW Subsystem");
|
||||
|
||||
comp.firstTime = false;
|
||||
}
|
||||
|
||||
if (m_impl->startLiveWindow) comp.builder.StartLiveWindowMode();
|
||||
comp.builder.UpdateTable();
|
||||
});
|
||||
|
||||
m_impl->startLiveWindow = false;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <wpi/DenseMap.h>
|
||||
|
||||
#include "frc/smartdashboard/SendableBuilder.h"
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
@@ -33,10 +34,10 @@ SendableCameraWrapper& SendableCameraWrapper::Wrap(CS_Source source) {
|
||||
|
||||
SendableCameraWrapper::SendableCameraWrapper(CS_Source source,
|
||||
const private_init&)
|
||||
: SendableBase(false), m_uri(kProtocol) {
|
||||
: m_uri(kProtocol) {
|
||||
CS_Status status = 0;
|
||||
auto name = cs::GetSourceName(source, &status);
|
||||
SetName(name);
|
||||
SendableRegistry::GetInstance().Add(this, name);
|
||||
m_uri += name;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "frc/shuffleboard/ShuffleboardComponent.h"
|
||||
#include "frc/shuffleboard/ShuffleboardLayout.h"
|
||||
#include "frc/shuffleboard/SimpleWidget.h"
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
@@ -80,10 +81,11 @@ ComplexWidget& ShuffleboardContainer::Add(const wpi::Twine& title,
|
||||
}
|
||||
|
||||
ComplexWidget& ShuffleboardContainer::Add(Sendable& sendable) {
|
||||
if (sendable.GetName().empty()) {
|
||||
auto name = SendableRegistry::GetInstance().GetName(&sendable);
|
||||
if (name.empty()) {
|
||||
wpi::outs() << "Sendable must have a name\n";
|
||||
}
|
||||
return Add(sendable.GetName(), sendable);
|
||||
return Add(name, sendable);
|
||||
}
|
||||
|
||||
ComplexWidget& ShuffleboardContainer::Add(const cs::VideoSource& video) {
|
||||
|
||||
@@ -7,62 +7,13 @@
|
||||
|
||||
#include "frc/smartdashboard/SendableBase.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "frc/livewindow/LiveWindow.h"
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
SendableBase::SendableBase(bool addLiveWindow) {
|
||||
if (addLiveWindow) LiveWindow::GetInstance()->Add(this);
|
||||
}
|
||||
|
||||
SendableBase::SendableBase(SendableBase&& other)
|
||||
: m_name(std::move(other.m_name)),
|
||||
m_subsystem(std::move(other.m_subsystem)) {
|
||||
auto&& lw = LiveWindow::GetInstance();
|
||||
if (lw->Remove(&other)) {
|
||||
lw->Add(this);
|
||||
}
|
||||
}
|
||||
|
||||
SendableBase& SendableBase::operator=(SendableBase&& other) {
|
||||
m_name = std::move(other.m_name);
|
||||
m_subsystem = std::move(other.m_subsystem);
|
||||
auto&& lw = LiveWindow::GetInstance();
|
||||
if (lw->Remove(&other)) {
|
||||
lw->Add(this);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
SendableBase::~SendableBase() { LiveWindow::GetInstance()->Remove(this); }
|
||||
|
||||
std::string SendableBase::GetName() const { return m_name; }
|
||||
|
||||
void SendableBase::SetName(const wpi::Twine& name) { m_name = name.str(); }
|
||||
|
||||
std::string SendableBase::GetSubsystem() const { return m_subsystem; }
|
||||
|
||||
void SendableBase::SetSubsystem(const wpi::Twine& subsystem) {
|
||||
m_subsystem = subsystem.str();
|
||||
}
|
||||
|
||||
void SendableBase::AddChild(std::shared_ptr<Sendable> child) {
|
||||
LiveWindow::GetInstance()->AddChild(this, child);
|
||||
}
|
||||
|
||||
void SendableBase::AddChild(void* child) {
|
||||
LiveWindow::GetInstance()->AddChild(this, child);
|
||||
}
|
||||
|
||||
void SendableBase::SetName(const wpi::Twine& moduleType, int channel) {
|
||||
SetName(moduleType + wpi::Twine('[') + wpi::Twine(channel) + wpi::Twine(']'));
|
||||
}
|
||||
|
||||
void SendableBase::SetName(const wpi::Twine& moduleType, int moduleNumber,
|
||||
int channel) {
|
||||
SetName(moduleType + wpi::Twine('[') + wpi::Twine(moduleNumber) +
|
||||
wpi::Twine(',') + wpi::Twine(channel) + wpi::Twine(']'));
|
||||
if (addLiveWindow)
|
||||
SendableRegistry::GetInstance().AddLW(this, "");
|
||||
else
|
||||
SendableRegistry::GetInstance().Add(this, "");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -7,9 +7,12 @@
|
||||
|
||||
#include "frc/smartdashboard/SendableChooserBase.h"
|
||||
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
std::atomic_int SendableChooserBase::s_instances{0};
|
||||
|
||||
SendableChooserBase::SendableChooserBase()
|
||||
: SendableBase(false), m_instance{s_instances++} {}
|
||||
SendableChooserBase::SendableChooserBase() : m_instance{s_instances++} {
|
||||
SendableRegistry::GetInstance().Add(this, "SendableChooser", m_instance);
|
||||
}
|
||||
|
||||
263
wpilibc/src/main/native/cpp/smartdashboard/SendableRegistry.cpp
Normal file
263
wpilibc/src/main/native/cpp/smartdashboard/SendableRegistry.cpp
Normal file
@@ -0,0 +1,263 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
#include <wpi/DenseMap.h>
|
||||
#include <wpi/SmallVector.h>
|
||||
#include <wpi/mutex.h>
|
||||
|
||||
using namespace frc;
|
||||
|
||||
struct SendableRegistry::Impl {
|
||||
struct Component {
|
||||
Sendable* sendable = nullptr;
|
||||
std::string name;
|
||||
std::string subsystem = "Ungrouped";
|
||||
Sendable* parent = nullptr;
|
||||
bool liveWindow = false;
|
||||
wpi::SmallVector<std::shared_ptr<void>, 2> data;
|
||||
|
||||
void SetName(const wpi::Twine& moduleType, int channel) {
|
||||
name =
|
||||
(moduleType + wpi::Twine('[') + wpi::Twine(channel) + wpi::Twine(']'))
|
||||
.str();
|
||||
}
|
||||
|
||||
void SetName(const wpi::Twine& moduleType, int moduleNumber, int channel) {
|
||||
name = (moduleType + wpi::Twine('[') + wpi::Twine(moduleNumber) +
|
||||
wpi::Twine(',') + wpi::Twine(channel) + wpi::Twine(']'))
|
||||
.str();
|
||||
}
|
||||
};
|
||||
|
||||
wpi::mutex mutex;
|
||||
|
||||
wpi::DenseMap<void*, Component> components;
|
||||
int nextDataHandle = 0;
|
||||
|
||||
Component& GetOrAdd(Sendable* sendable);
|
||||
};
|
||||
|
||||
SendableRegistry::Impl::Component& SendableRegistry::Impl::GetOrAdd(
|
||||
Sendable* sendable) {
|
||||
auto& comp = components[sendable];
|
||||
comp.sendable = sendable;
|
||||
return comp;
|
||||
}
|
||||
|
||||
SendableRegistry& SendableRegistry::GetInstance() {
|
||||
static SendableRegistry instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
void SendableRegistry::Add(Sendable* sendable, const wpi::Twine& name) {
|
||||
std::scoped_lock lock(m_impl->mutex);
|
||||
auto& comp = m_impl->GetOrAdd(sendable);
|
||||
comp.name = name.str();
|
||||
}
|
||||
|
||||
void SendableRegistry::Add(Sendable* sendable, const wpi::Twine& moduleType,
|
||||
int channel) {
|
||||
std::scoped_lock lock(m_impl->mutex);
|
||||
auto& comp = m_impl->GetOrAdd(sendable);
|
||||
comp.SetName(moduleType, channel);
|
||||
}
|
||||
|
||||
void SendableRegistry::Add(Sendable* sendable, const wpi::Twine& moduleType,
|
||||
int moduleNumber, int channel) {
|
||||
std::scoped_lock lock(m_impl->mutex);
|
||||
auto& comp = m_impl->GetOrAdd(sendable);
|
||||
comp.SetName(moduleType, moduleNumber, channel);
|
||||
}
|
||||
|
||||
void SendableRegistry::Add(Sendable* sendable, const wpi::Twine& subsystem,
|
||||
const wpi::Twine& name) {
|
||||
std::scoped_lock lock(m_impl->mutex);
|
||||
auto& comp = m_impl->GetOrAdd(sendable);
|
||||
comp.name = name.str();
|
||||
comp.subsystem = subsystem.str();
|
||||
}
|
||||
|
||||
void SendableRegistry::AddLW(Sendable* sendable, const wpi::Twine& name) {
|
||||
std::scoped_lock lock(m_impl->mutex);
|
||||
auto& comp = m_impl->GetOrAdd(sendable);
|
||||
comp.liveWindow = true;
|
||||
comp.name = name.str();
|
||||
}
|
||||
|
||||
void SendableRegistry::AddLW(Sendable* sendable, const wpi::Twine& moduleType,
|
||||
int channel) {
|
||||
std::scoped_lock lock(m_impl->mutex);
|
||||
auto& comp = m_impl->GetOrAdd(sendable);
|
||||
comp.liveWindow = true;
|
||||
comp.SetName(moduleType, channel);
|
||||
}
|
||||
|
||||
void SendableRegistry::AddLW(Sendable* sendable, const wpi::Twine& moduleType,
|
||||
int moduleNumber, int channel) {
|
||||
std::scoped_lock lock(m_impl->mutex);
|
||||
auto& comp = m_impl->GetOrAdd(sendable);
|
||||
comp.liveWindow = true;
|
||||
comp.SetName(moduleType, moduleNumber, channel);
|
||||
}
|
||||
|
||||
void SendableRegistry::AddLW(Sendable* sendable, const wpi::Twine& subsystem,
|
||||
const wpi::Twine& name) {
|
||||
std::scoped_lock lock(m_impl->mutex);
|
||||
auto& comp = m_impl->GetOrAdd(sendable);
|
||||
comp.liveWindow = true;
|
||||
comp.name = name.str();
|
||||
comp.subsystem = subsystem.str();
|
||||
}
|
||||
|
||||
void SendableRegistry::AddChild(Sendable* parent, void* child) {
|
||||
std::scoped_lock lock(m_impl->mutex);
|
||||
auto& comp = m_impl->components[child];
|
||||
comp.parent = parent;
|
||||
}
|
||||
|
||||
bool SendableRegistry::Remove(Sendable* sendable) {
|
||||
std::scoped_lock lock(m_impl->mutex);
|
||||
return m_impl->components.erase(sendable);
|
||||
}
|
||||
|
||||
void SendableRegistry::Move(Sendable* to, Sendable* from) {
|
||||
std::scoped_lock lock(m_impl->mutex);
|
||||
auto it = m_impl->components.find(from);
|
||||
if (it == m_impl->components.end()) return;
|
||||
Impl::Component old = std::move(it->getSecond());
|
||||
m_impl->components.erase(it);
|
||||
m_impl->components[to] = std::move(old);
|
||||
m_impl->components[to].sendable = to;
|
||||
}
|
||||
|
||||
bool SendableRegistry::Contains(const Sendable* sendable) const {
|
||||
std::scoped_lock lock(m_impl->mutex);
|
||||
return m_impl->components.count(sendable) != 0;
|
||||
}
|
||||
|
||||
std::string SendableRegistry::GetName(const Sendable* sendable) const {
|
||||
std::scoped_lock lock(m_impl->mutex);
|
||||
auto it = m_impl->components.find(sendable);
|
||||
if (it == m_impl->components.end()) return std::string{};
|
||||
return it->getSecond().name;
|
||||
}
|
||||
|
||||
void SendableRegistry::SetName(Sendable* sendable, const wpi::Twine& name) {
|
||||
std::scoped_lock lock(m_impl->mutex);
|
||||
auto it = m_impl->components.find(sendable);
|
||||
if (it == m_impl->components.end()) return;
|
||||
it->getSecond().name = name.str();
|
||||
}
|
||||
|
||||
void SendableRegistry::SetName(Sendable* sendable, const wpi::Twine& moduleType,
|
||||
int channel) {
|
||||
std::scoped_lock lock(m_impl->mutex);
|
||||
auto it = m_impl->components.find(sendable);
|
||||
if (it == m_impl->components.end()) return;
|
||||
it->getSecond().SetName(moduleType, channel);
|
||||
}
|
||||
|
||||
void SendableRegistry::SetName(Sendable* sendable, const wpi::Twine& moduleType,
|
||||
int moduleNumber, int channel) {
|
||||
std::scoped_lock lock(m_impl->mutex);
|
||||
auto it = m_impl->components.find(sendable);
|
||||
if (it == m_impl->components.end()) return;
|
||||
it->getSecond().SetName(moduleType, moduleNumber, channel);
|
||||
}
|
||||
|
||||
void SendableRegistry::SetName(Sendable* sendable, const wpi::Twine& subsystem,
|
||||
const wpi::Twine& name) {
|
||||
std::scoped_lock lock(m_impl->mutex);
|
||||
auto it = m_impl->components.find(sendable);
|
||||
if (it == m_impl->components.end()) return;
|
||||
it->getSecond().name = name.str();
|
||||
it->getSecond().subsystem = subsystem.str();
|
||||
}
|
||||
|
||||
std::string SendableRegistry::GetSubsystem(const Sendable* sendable) const {
|
||||
std::scoped_lock lock(m_impl->mutex);
|
||||
auto it = m_impl->components.find(sendable);
|
||||
if (it == m_impl->components.end()) return std::string{};
|
||||
return it->getSecond().subsystem;
|
||||
}
|
||||
|
||||
void SendableRegistry::SetSubsystem(Sendable* sendable,
|
||||
const wpi::Twine& subsystem) {
|
||||
std::scoped_lock lock(m_impl->mutex);
|
||||
auto it = m_impl->components.find(sendable);
|
||||
if (it == m_impl->components.end()) return;
|
||||
it->getSecond().subsystem = subsystem.str();
|
||||
}
|
||||
|
||||
int SendableRegistry::GetDataHandle() {
|
||||
std::scoped_lock lock(m_impl->mutex);
|
||||
return m_impl->nextDataHandle++;
|
||||
}
|
||||
|
||||
std::shared_ptr<void> SendableRegistry::SetData(Sendable* sendable, int handle,
|
||||
std::shared_ptr<void> data) {
|
||||
assert(handle >= 0);
|
||||
std::scoped_lock lock(m_impl->mutex);
|
||||
auto it = m_impl->components.find(sendable);
|
||||
if (it == m_impl->components.end()) return nullptr;
|
||||
auto& comp = it->getSecond();
|
||||
std::shared_ptr<void> rv;
|
||||
if (static_cast<size_t>(handle) < comp.data.size())
|
||||
rv = std::move(comp.data[handle]);
|
||||
else
|
||||
comp.data.resize(handle + 1);
|
||||
comp.data[handle] = std::move(data);
|
||||
return rv;
|
||||
}
|
||||
|
||||
std::shared_ptr<void> SendableRegistry::GetData(Sendable* sendable,
|
||||
int handle) {
|
||||
assert(handle >= 0);
|
||||
std::scoped_lock lock(m_impl->mutex);
|
||||
auto it = m_impl->components.find(sendable);
|
||||
if (it == m_impl->components.end()) return nullptr;
|
||||
auto& comp = it->getSecond();
|
||||
if (static_cast<size_t>(handle) >= comp.data.size()) return nullptr;
|
||||
return comp.data[handle];
|
||||
}
|
||||
|
||||
void SendableRegistry::EnableLiveWindow(Sendable* sendable) {
|
||||
std::scoped_lock lock(m_impl->mutex);
|
||||
auto it = m_impl->components.find(sendable);
|
||||
if (it == m_impl->components.end()) return;
|
||||
it->getSecond().liveWindow = true;
|
||||
}
|
||||
|
||||
void SendableRegistry::DisableLiveWindow(Sendable* sendable) {
|
||||
std::scoped_lock lock(m_impl->mutex);
|
||||
auto it = m_impl->components.find(sendable);
|
||||
if (it == m_impl->components.end()) return;
|
||||
it->getSecond().liveWindow = false;
|
||||
}
|
||||
|
||||
void SendableRegistry::ForeachLiveWindow(
|
||||
int dataHandle,
|
||||
wpi::function_ref<void(Sendable* sendable, wpi::StringRef name,
|
||||
wpi::StringRef subsystem, Sendable* parent,
|
||||
std::shared_ptr<void>& data)>
|
||||
callback) const {
|
||||
assert(dataHandle >= 0);
|
||||
std::scoped_lock lock(m_impl->mutex);
|
||||
for (auto& i : m_impl->components) {
|
||||
auto& comp = i.getSecond();
|
||||
if (comp.sendable && comp.liveWindow) {
|
||||
if (static_cast<size_t>(dataHandle) >= comp.data.size())
|
||||
comp.data.resize(dataHandle + 1);
|
||||
callback(comp.sendable, comp.name, comp.subsystem, comp.parent,
|
||||
comp.data[dataHandle]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SendableRegistry::SendableRegistry() : m_impl(new Impl) {}
|
||||
@@ -14,8 +14,8 @@
|
||||
#include <wpi/mutex.h>
|
||||
|
||||
#include "frc/WPIErrors.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableBuilderImpl.h"
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
@@ -115,7 +115,8 @@ void SmartDashboard::PutData(Sendable* value) {
|
||||
wpi_setGlobalWPIErrorWithContext(NullParameter, "value");
|
||||
return;
|
||||
}
|
||||
PutData(value->GetName(), value);
|
||||
auto name = SendableRegistry::GetInstance().GetName(value);
|
||||
if (!name.empty()) PutData(name, value);
|
||||
}
|
||||
|
||||
Sendable* SmartDashboard::GetData(wpi::StringRef key) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -10,10 +10,13 @@
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/I2C.h"
|
||||
#include "frc/interfaces/Accelerometer.h"
|
||||
#include "frc/smartdashboard/SendableBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class SendableBuilder;
|
||||
|
||||
/**
|
||||
* ADXL345 Accelerometer on I2C.
|
||||
*
|
||||
@@ -22,8 +25,9 @@ namespace frc {
|
||||
* 0x1D (7-bit address).
|
||||
*/
|
||||
class ADXL345_I2C : public ErrorBase,
|
||||
public SendableBase,
|
||||
public Accelerometer {
|
||||
public Accelerometer,
|
||||
public Sendable,
|
||||
public SendableHelper<ADXL345_I2C> {
|
||||
public:
|
||||
enum Axes { kAxis_X = 0x00, kAxis_Y = 0x02, kAxis_Z = 0x04 };
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -10,7 +10,8 @@
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/SPI.h"
|
||||
#include "frc/interfaces/Accelerometer.h"
|
||||
#include "frc/smartdashboard/SendableBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -21,8 +22,9 @@ namespace frc {
|
||||
* via SPI. This class assumes the sensor is wired in 4-wire SPI mode.
|
||||
*/
|
||||
class ADXL345_SPI : public ErrorBase,
|
||||
public SendableBase,
|
||||
public Accelerometer {
|
||||
public Accelerometer,
|
||||
public Sendable,
|
||||
public SendableHelper<ADXL345_SPI> {
|
||||
public:
|
||||
enum Axes { kAxis_X = 0x00, kAxis_Y = 0x02, kAxis_Z = 0x04 };
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -10,16 +10,22 @@
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/SPI.h"
|
||||
#include "frc/interfaces/Accelerometer.h"
|
||||
#include "frc/smartdashboard/SendableBase.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 ErrorBase, public SendableBase, public Accelerometer {
|
||||
class ADXL362 : public ErrorBase,
|
||||
public Accelerometer,
|
||||
public Sendable,
|
||||
public SendableHelper<ADXL362> {
|
||||
public:
|
||||
enum Axes { kAxis_X = 0x00, kAxis_Y = 0x02, kAxis_Z = 0x04 };
|
||||
struct AllAxes {
|
||||
@@ -44,7 +50,7 @@ class ADXL362 : public ErrorBase, public SendableBase, public Accelerometer {
|
||||
*/
|
||||
explicit ADXL362(SPI::Port port, Range range = kRange_2G);
|
||||
|
||||
virtual ~ADXL362() = default;
|
||||
~ADXL362() override = default;
|
||||
|
||||
ADXL362(ADXL362&&) = default;
|
||||
ADXL362& operator=(ADXL362&&) = default;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2015-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2015-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -40,7 +40,7 @@ class ADXRS450_Gyro : public GyroBase {
|
||||
*/
|
||||
explicit ADXRS450_Gyro(SPI::Port port);
|
||||
|
||||
virtual ~ADXRS450_Gyro() = default;
|
||||
~ADXRS450_Gyro() override = default;
|
||||
|
||||
ADXRS450_Gyro(ADXRS450_Gyro&&) = default;
|
||||
ADXRS450_Gyro& operator=(ADXRS450_Gyro&&) = default;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -12,10 +12,13 @@
|
||||
#include "frc/AnalogInput.h"
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/PIDSource.h"
|
||||
#include "frc/smartdashboard/SendableBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class SendableBuilder;
|
||||
|
||||
/**
|
||||
* Handle operation of an analog accelerometer.
|
||||
*
|
||||
@@ -24,8 +27,9 @@ namespace frc {
|
||||
* calibrated by finding the center value over a period of time.
|
||||
*/
|
||||
class AnalogAccelerometer : public ErrorBase,
|
||||
public SendableBase,
|
||||
public PIDSource {
|
||||
public PIDSource,
|
||||
public Sendable,
|
||||
public SendableHelper<AnalogAccelerometer> {
|
||||
public:
|
||||
/**
|
||||
* Create a new instance of an accelerometer.
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
#include <hal/Types.h>
|
||||
|
||||
#include "frc/GyroBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -100,7 +102,7 @@ class AnalogGyro : public GyroBase {
|
||||
*/
|
||||
AnalogGyro(std::shared_ptr<AnalogInput> channel, int center, double offset);
|
||||
|
||||
virtual ~AnalogGyro();
|
||||
~AnalogGyro() override;
|
||||
|
||||
AnalogGyro(AnalogGyro&& rhs);
|
||||
AnalogGyro& operator=(AnalogGyro&& rhs);
|
||||
|
||||
@@ -13,10 +13,13 @@
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/PIDSource.h"
|
||||
#include "frc/smartdashboard/SendableBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class SendableBuilder;
|
||||
|
||||
/**
|
||||
* Analog input class.
|
||||
*
|
||||
@@ -29,7 +32,10 @@ namespace frc {
|
||||
* are divided by the number of samples to retain the resolution, but get more
|
||||
* stable values.
|
||||
*/
|
||||
class AnalogInput : public ErrorBase, public SendableBase, public PIDSource {
|
||||
class AnalogInput : public ErrorBase,
|
||||
public PIDSource,
|
||||
public Sendable,
|
||||
public SendableHelper<AnalogInput> {
|
||||
friend class AnalogTrigger;
|
||||
friend class AnalogGyro;
|
||||
|
||||
|
||||
@@ -10,14 +10,19 @@
|
||||
#include <hal/Types.h>
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/smartdashboard/SendableBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class SendableBuilder;
|
||||
|
||||
/**
|
||||
* MXP analog output class.
|
||||
*/
|
||||
class AnalogOutput : public ErrorBase, public SendableBase {
|
||||
class AnalogOutput : public ErrorBase,
|
||||
public Sendable,
|
||||
public SendableHelper<AnalogOutput> {
|
||||
public:
|
||||
/**
|
||||
* Construct an analog output on the given channel.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -12,10 +12,13 @@
|
||||
#include "frc/AnalogInput.h"
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/interfaces/Potentiometer.h"
|
||||
#include "frc/smartdashboard/SendableBase.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
|
||||
@@ -23,8 +26,9 @@ namespace frc {
|
||||
* constructor.
|
||||
*/
|
||||
class AnalogPotentiometer : public ErrorBase,
|
||||
public SendableBase,
|
||||
public Potentiometer {
|
||||
public Potentiometer,
|
||||
public Sendable,
|
||||
public SendableHelper<AnalogPotentiometer> {
|
||||
public:
|
||||
/**
|
||||
* Construct an Analog Potentiometer object from a channel number.
|
||||
|
||||
@@ -13,13 +13,17 @@
|
||||
|
||||
#include "frc/AnalogTriggerOutput.h"
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/smartdashboard/SendableBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class AnalogInput;
|
||||
class SendableBuilder;
|
||||
|
||||
class AnalogTrigger : public ErrorBase, public SendableBase {
|
||||
class AnalogTrigger : public ErrorBase,
|
||||
public Sendable,
|
||||
public SendableHelper<AnalogTrigger> {
|
||||
friend class AnalogTriggerOutput;
|
||||
|
||||
public:
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "frc/DigitalSource.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -44,7 +46,9 @@ class AnalogTrigger;
|
||||
* rollover transition is not sharp / clean enough. Using the averaging engine
|
||||
* may help with this, but rotational speeds of the sensor will then be limited.
|
||||
*/
|
||||
class AnalogTriggerOutput : public DigitalSource {
|
||||
class AnalogTriggerOutput : public DigitalSource,
|
||||
public Sendable,
|
||||
public SendableHelper<AnalogTriggerOutput> {
|
||||
friend class AnalogTrigger;
|
||||
|
||||
public:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2014-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2014-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -9,18 +9,22 @@
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/interfaces/Accelerometer.h"
|
||||
#include "frc/smartdashboard/SendableBase.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 ErrorBase,
|
||||
public SendableBase,
|
||||
public Accelerometer {
|
||||
public Accelerometer,
|
||||
public Sendable,
|
||||
public SendableHelper<BuiltInAccelerometer> {
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
|
||||
@@ -11,10 +11,13 @@
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/SensorUtil.h"
|
||||
#include "frc/smartdashboard/SendableBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class SendableBuilder;
|
||||
|
||||
/**
|
||||
* Class for operating a compressor connected to a %PCM (Pneumatic Control
|
||||
* Module).
|
||||
@@ -30,7 +33,9 @@ namespace frc {
|
||||
* loop control. You can only turn off closed loop control, thereby stopping
|
||||
* the compressor from operating.
|
||||
*/
|
||||
class Compressor : public ErrorBase, public SendableBase {
|
||||
class Compressor : public ErrorBase,
|
||||
public Sendable,
|
||||
public SendableHelper<Compressor> {
|
||||
public:
|
||||
/**
|
||||
* Constructor. The default PCM ID is 0.
|
||||
|
||||
@@ -14,11 +14,13 @@
|
||||
#include "frc/AnalogTrigger.h"
|
||||
#include "frc/CounterBase.h"
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/smartdashboard/SendableBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class DigitalGlitchFilter;
|
||||
class SendableBuilder;
|
||||
|
||||
/**
|
||||
* Class for counting the number of ticks on a digital input channel.
|
||||
@@ -30,7 +32,10 @@ class DigitalGlitchFilter;
|
||||
* All counters will immediately start counting - Reset() them if you need them
|
||||
* to be zeroed before use.
|
||||
*/
|
||||
class Counter : public ErrorBase, public SendableBase, public CounterBase {
|
||||
class Counter : public ErrorBase,
|
||||
public CounterBase,
|
||||
public Sendable,
|
||||
public SendableHelper<Counter> {
|
||||
public:
|
||||
enum Mode {
|
||||
kTwoPulse = 0,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2015-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2015-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -15,7 +15,8 @@
|
||||
|
||||
#include "frc/DigitalSource.h"
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/smartdashboard/SendableBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -29,7 +30,9 @@ 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 SendableBase {
|
||||
class DigitalGlitchFilter : public ErrorBase,
|
||||
public Sendable,
|
||||
public SendableHelper<DigitalGlitchFilter> {
|
||||
public:
|
||||
DigitalGlitchFilter();
|
||||
~DigitalGlitchFilter() override;
|
||||
|
||||
@@ -8,10 +8,13 @@
|
||||
#pragma once
|
||||
|
||||
#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.
|
||||
@@ -22,7 +25,9 @@ class DigitalGlitchFilter;
|
||||
* as required. This class is only for devices like switches etc. that aren't
|
||||
* implemented anywhere else.
|
||||
*/
|
||||
class DigitalInput : public DigitalSource {
|
||||
class DigitalInput : public DigitalSource,
|
||||
public Sendable,
|
||||
public SendableHelper<DigitalInput> {
|
||||
public:
|
||||
/**
|
||||
* Create an instance of a Digital Input class.
|
||||
|
||||
@@ -10,10 +10,13 @@
|
||||
#include <hal/Types.h>
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/smartdashboard/SendableBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class SendableBuilder;
|
||||
|
||||
/**
|
||||
* Class to write to digital outputs.
|
||||
*
|
||||
@@ -21,7 +24,9 @@ namespace frc {
|
||||
* elsewhere will allocate channels automatically so for those devices it
|
||||
* shouldn't be done here.
|
||||
*/
|
||||
class DigitalOutput : public ErrorBase, public SendableBase {
|
||||
class DigitalOutput : public ErrorBase,
|
||||
public Sendable,
|
||||
public SendableHelper<DigitalOutput> {
|
||||
public:
|
||||
/**
|
||||
* Create an instance of a digital output.
|
||||
|
||||
@@ -10,9 +10,13 @@
|
||||
#include <hal/Types.h>
|
||||
|
||||
#include "frc/SolenoidBase.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).
|
||||
@@ -20,7 +24,9 @@ namespace frc {
|
||||
* The DoubleSolenoid class is typically used for pneumatics solenoids that
|
||||
* have two positions controlled by two separate channels.
|
||||
*/
|
||||
class DoubleSolenoid : public SolenoidBase {
|
||||
class DoubleSolenoid : public SolenoidBase,
|
||||
public Sendable,
|
||||
public SendableHelper<DoubleSolenoid> {
|
||||
public:
|
||||
enum Value { kOff, kForward, kReverse };
|
||||
|
||||
|
||||
@@ -15,12 +15,14 @@
|
||||
#include "frc/CounterBase.h"
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/PIDSource.h"
|
||||
#include "frc/smartdashboard/SendableBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class DigitalSource;
|
||||
class DigitalGlitchFilter;
|
||||
class SendableBuilder;
|
||||
|
||||
/**
|
||||
* Class to read quad encoders.
|
||||
@@ -38,9 +40,10 @@ class DigitalGlitchFilter;
|
||||
* to be zeroed before use.
|
||||
*/
|
||||
class Encoder : public ErrorBase,
|
||||
public SendableBase,
|
||||
public CounterBase,
|
||||
public PIDSource {
|
||||
public PIDSource,
|
||||
public Sendable,
|
||||
public SendableHelper<Encoder> {
|
||||
public:
|
||||
enum IndexingType {
|
||||
kResetWhileHigh,
|
||||
|
||||
@@ -79,6 +79,8 @@ class ErrorBase {
|
||||
ErrorBase();
|
||||
virtual ~ErrorBase() = default;
|
||||
|
||||
ErrorBase(const ErrorBase&) = default;
|
||||
ErrorBase& operator=(const ErrorBase&) = default;
|
||||
ErrorBase(ErrorBase&&) = default;
|
||||
ErrorBase& operator=(ErrorBase&&) = default;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -10,7 +10,8 @@
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/PIDSource.h"
|
||||
#include "frc/interfaces/Gyro.h"
|
||||
#include "frc/smartdashboard/SendableBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -20,8 +21,9 @@ namespace frc {
|
||||
*/
|
||||
class GyroBase : public Gyro,
|
||||
public ErrorBase,
|
||||
public SendableBase,
|
||||
public PIDSource {
|
||||
public PIDSource,
|
||||
public Sendable,
|
||||
public SendableHelper<GyroBase> {
|
||||
public:
|
||||
GyroBase() = default;
|
||||
GyroBase(GyroBase&&) = default;
|
||||
|
||||
@@ -14,11 +14,10 @@
|
||||
|
||||
#include "frc/AnalogTriggerType.h"
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/smartdashboard/SendableBase.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class InterruptableSensorBase : public ErrorBase, public SendableBase {
|
||||
class InterruptableSensorBase : public ErrorBase {
|
||||
public:
|
||||
enum WaitResult {
|
||||
kTimeout = 0x0,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -14,16 +14,20 @@
|
||||
#include "frc/MotorSafety.h"
|
||||
#include "frc/PWM.h"
|
||||
#include "frc/SpeedController.h"
|
||||
#include "frc/smartdashboard/SendableBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class SendableBuilder;
|
||||
|
||||
/**
|
||||
* Nidec Brushless Motor.
|
||||
*/
|
||||
class NidecBrushless : public SendableBase,
|
||||
public SpeedController,
|
||||
public MotorSafety {
|
||||
class NidecBrushless : public SpeedController,
|
||||
public MotorSafety,
|
||||
public Sendable,
|
||||
public SendableHelper<NidecBrushless> {
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
|
||||
@@ -19,10 +19,13 @@
|
||||
#include "frc/PIDOutput.h"
|
||||
#include "frc/PIDSource.h"
|
||||
#include "frc/Timer.h"
|
||||
#include "frc/smartdashboard/SendableBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class SendableBuilder;
|
||||
|
||||
/**
|
||||
* Class implements a PID Control Loop.
|
||||
*
|
||||
@@ -33,7 +36,10 @@ namespace frc {
|
||||
* in the integral and derivative calculations. Therefore, the sample rate
|
||||
* affects the controller's behavior for a given set of PID constants.
|
||||
*/
|
||||
class PIDBase : public SendableBase, public PIDInterface, public PIDOutput {
|
||||
class PIDBase : public PIDInterface,
|
||||
public PIDOutput,
|
||||
public Sendable,
|
||||
public SendableHelper<PIDBase> {
|
||||
public:
|
||||
/**
|
||||
* Allocate a PID object with the given constants for P, I, D.
|
||||
@@ -58,7 +64,7 @@ class PIDBase : public SendableBase, public PIDInterface, public PIDOutput {
|
||||
PIDBase(double p, double i, double d, double f, PIDSource& source,
|
||||
PIDOutput& output);
|
||||
|
||||
~PIDBase() override = default;
|
||||
virtual ~PIDBase() = default;
|
||||
|
||||
PIDBase(PIDBase&&) = default;
|
||||
PIDBase& operator=(PIDBase&&) = default;
|
||||
|
||||
@@ -13,10 +13,13 @@
|
||||
#include <wpi/raw_ostream.h>
|
||||
|
||||
#include "frc/MotorSafety.h"
|
||||
#include "frc/smartdashboard/SendableBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class SendableBuilder;
|
||||
|
||||
/**
|
||||
* Class implements the PWM generation in the FPGA.
|
||||
*
|
||||
@@ -34,7 +37,7 @@ namespace frc {
|
||||
* - 1 = minimum pulse width (currently .5ms)
|
||||
* - 0 = disabled (i.e. PWM output is held low)
|
||||
*/
|
||||
class PWM : public MotorSafety, public SendableBase {
|
||||
class PWM : public MotorSafety, public Sendable, public SendableHelper<PWM> {
|
||||
public:
|
||||
/**
|
||||
* Represents the amount to multiply the minimum servo-pulse pwm period by.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
|
||||
@@ -10,15 +10,20 @@
|
||||
#include <hal/Types.h>
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/smartdashboard/SendableBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class SendableBuilder;
|
||||
|
||||
/**
|
||||
* Class for getting voltage, current, temperature, power and energy from the
|
||||
* CAN PDP.
|
||||
*/
|
||||
class PowerDistributionPanel : public ErrorBase, public SendableBase {
|
||||
class PowerDistributionPanel : public ErrorBase,
|
||||
public Sendable,
|
||||
public SendableHelper<PowerDistributionPanel> {
|
||||
public:
|
||||
PowerDistributionPanel();
|
||||
explicit PowerDistributionPanel(int module);
|
||||
|
||||
@@ -14,10 +14,13 @@
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/MotorSafety.h"
|
||||
#include "frc/smartdashboard/SendableBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class SendableBuilder;
|
||||
|
||||
/**
|
||||
* Class for Spike style relay outputs.
|
||||
*
|
||||
@@ -30,7 +33,9 @@ namespace frc {
|
||||
* independently for something that does not care about voltage polarity (like
|
||||
* a solenoid).
|
||||
*/
|
||||
class Relay : public MotorSafety, public SendableBase {
|
||||
class Relay : public MotorSafety,
|
||||
public Sendable,
|
||||
public SendableHelper<Relay> {
|
||||
public:
|
||||
enum Value { kOff, kOn, kForward, kReverse };
|
||||
enum Direction { kBothDirections, kForwardOnly, kReverseOnly };
|
||||
|
||||
@@ -10,16 +10,22 @@
|
||||
#include <hal/Types.h>
|
||||
|
||||
#include "frc/SolenoidBase.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 SolenoidBase {
|
||||
class Solenoid : public SolenoidBase,
|
||||
public Sendable,
|
||||
public SendableHelper<Solenoid> {
|
||||
public:
|
||||
/**
|
||||
* Constructor using the default PCM ID (0).
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -8,7 +8,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/smartdashboard/SendableBase.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -16,7 +15,7 @@ namespace frc {
|
||||
* SolenoidBase class is the common base class for the Solenoid and
|
||||
* DoubleSolenoid classes.
|
||||
*/
|
||||
class SolenoidBase : public ErrorBase, public SendableBase {
|
||||
class SolenoidBase : public ErrorBase {
|
||||
public:
|
||||
/**
|
||||
* Read all 8 solenoids as a single byte
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -11,11 +11,14 @@
|
||||
#include <vector>
|
||||
|
||||
#include "frc/SpeedController.h"
|
||||
#include "frc/smartdashboard/SendableBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class SpeedControllerGroup : public SendableBase, public SpeedController {
|
||||
class SpeedControllerGroup : public Sendable,
|
||||
public SpeedController,
|
||||
public SendableHelper<SpeedControllerGroup> {
|
||||
public:
|
||||
template <class... SpeedControllers>
|
||||
explicit SpeedControllerGroup(SpeedController& speedController,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
template <class... SpeedControllers>
|
||||
@@ -14,10 +16,10 @@ SpeedControllerGroup::SpeedControllerGroup(
|
||||
SpeedController& speedController, SpeedControllers&... speedControllers)
|
||||
: m_speedControllers{speedController, speedControllers...} {
|
||||
for (auto& speedController : m_speedControllers)
|
||||
AddChild(&speedController.get());
|
||||
SendableRegistry::GetInstance().AddChild(this, &speedController.get());
|
||||
static int instances = 0;
|
||||
++instances;
|
||||
SetName("SpeedControllerGroup", instances);
|
||||
SendableRegistry::GetInstance().Add(this, "SpeedControllerGroup", instances);
|
||||
}
|
||||
|
||||
} // namespace frc
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -15,7 +15,8 @@
|
||||
#include "frc/Counter.h"
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/PIDSource.h"
|
||||
#include "frc/smartdashboard/SendableBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -34,7 +35,10 @@ class DigitalOutput;
|
||||
* received. The time that the line is high determines the round trip distance
|
||||
* (time of flight).
|
||||
*/
|
||||
class Ultrasonic : public ErrorBase, public SendableBase, public PIDSource {
|
||||
class Ultrasonic : public ErrorBase,
|
||||
public Sendable,
|
||||
public PIDSource,
|
||||
public SendableHelper<Ultrasonic> {
|
||||
public:
|
||||
enum DistanceUnit { kInches = 0, kMilliMeters = 1 };
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2011-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2011-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -9,7 +9,8 @@
|
||||
|
||||
#include <atomic>
|
||||
|
||||
#include "frc/smartdashboard/SendableBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -28,7 +29,7 @@ class Command;
|
||||
* only have to write the {@link Trigger#Get()} method to get the full
|
||||
* functionality of the Trigger class.
|
||||
*/
|
||||
class Trigger : public SendableBase {
|
||||
class Trigger : public Sendable, public SendableHelper<Trigger> {
|
||||
public:
|
||||
Trigger() = default;
|
||||
~Trigger() override = default;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2011-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2011-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -15,7 +15,8 @@
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/commands/Subsystem.h"
|
||||
#include "frc/smartdashboard/SendableBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -45,7 +46,9 @@ class CommandGroup;
|
||||
* @see CommandGroup
|
||||
* @see Subsystem
|
||||
*/
|
||||
class Command : public ErrorBase, public SendableBase {
|
||||
class Command : public ErrorBase,
|
||||
public Sendable,
|
||||
public SendableHelper<Command> {
|
||||
friend class CommandGroup;
|
||||
friend class Scheduler;
|
||||
|
||||
@@ -385,6 +388,34 @@ class Command : public ErrorBase, public SendableBase {
|
||||
|
||||
friend class ConditionalCommand;
|
||||
|
||||
/**
|
||||
* Gets the name of this Command.
|
||||
*
|
||||
* @return Name
|
||||
*/
|
||||
std::string GetName() const;
|
||||
|
||||
/**
|
||||
* Sets the name of this Command.
|
||||
*
|
||||
* @param name name
|
||||
*/
|
||||
void SetName(const wpi::Twine& name);
|
||||
|
||||
/**
|
||||
* Gets the subsystem name of this Command.
|
||||
*
|
||||
* @return Subsystem name
|
||||
*/
|
||||
std::string GetSubsystem() const;
|
||||
|
||||
/**
|
||||
* Sets the subsystem name of this Command.
|
||||
*
|
||||
* @param subsystem subsystem name
|
||||
*/
|
||||
void SetSubsystem(const wpi::Twine& subsystem);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Prevents further changes from being made.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2011-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2011-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -10,7 +10,8 @@
|
||||
#include <memory>
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/smartdashboard/SendableBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -18,7 +19,9 @@ class ButtonScheduler;
|
||||
class Command;
|
||||
class Subsystem;
|
||||
|
||||
class Scheduler : public ErrorBase, public SendableBase {
|
||||
class Scheduler : public ErrorBase,
|
||||
public Sendable,
|
||||
public SendableHelper<Scheduler> {
|
||||
public:
|
||||
/**
|
||||
* Returns the Scheduler, creating it if one does not exist.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2011-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2011-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -8,19 +8,22 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include <wpi/StringRef.h>
|
||||
#include <wpi/Twine.h>
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableBase.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class Command;
|
||||
|
||||
class Subsystem : public ErrorBase, public SendableBase {
|
||||
class Subsystem : public ErrorBase,
|
||||
public Sendable,
|
||||
public SendableHelper<Subsystem> {
|
||||
friend class Scheduler;
|
||||
|
||||
public:
|
||||
@@ -97,6 +100,34 @@ class Subsystem : public ErrorBase, public SendableBase {
|
||||
*/
|
||||
virtual void InitDefaultCommand();
|
||||
|
||||
/**
|
||||
* Gets the name of this Subsystem.
|
||||
*
|
||||
* @return Name
|
||||
*/
|
||||
std::string GetName() const;
|
||||
|
||||
/**
|
||||
* Sets the name of this Subsystem.
|
||||
*
|
||||
* @param name name
|
||||
*/
|
||||
void SetName(const wpi::Twine& name);
|
||||
|
||||
/**
|
||||
* Gets the subsystem name of this Subsystem.
|
||||
*
|
||||
* @return Subsystem name
|
||||
*/
|
||||
std::string GetSubsystem() const;
|
||||
|
||||
/**
|
||||
* Sets the subsystem name of this Subsystem.
|
||||
*
|
||||
* @param subsystem subsystem name
|
||||
*/
|
||||
void SetSubsystem(const wpi::Twine& subsystem);
|
||||
|
||||
/**
|
||||
* Associate a Sendable with this Subsystem.
|
||||
* Also update the child's name.
|
||||
|
||||
@@ -12,14 +12,16 @@
|
||||
|
||||
#include <units/units.h>
|
||||
|
||||
#include "frc/smartdashboard/SendableBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc2 {
|
||||
|
||||
/**
|
||||
* Implements a PID control loop.
|
||||
*/
|
||||
class PIDController : public frc::SendableBase {
|
||||
class PIDController : public frc::Sendable,
|
||||
public frc::SendableHelper<PIDController> {
|
||||
public:
|
||||
/**
|
||||
* Allocates a PIDController with the given constants for Kp, Ki, and Kd.
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
#include <units/units.h>
|
||||
|
||||
#include "frc/controller/PIDController.h"
|
||||
#include "frc/smartdashboard/SendableBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
#include "frc/trajectory/TrapezoidProfile.h"
|
||||
|
||||
namespace frc {
|
||||
@@ -22,7 +23,8 @@ namespace frc {
|
||||
* Implements a PID control loop whose setpoint is constrained by a trapezoid
|
||||
* profile.
|
||||
*/
|
||||
class ProfiledPIDController : public SendableBase {
|
||||
class ProfiledPIDController : public Sendable,
|
||||
public SendableHelper<ProfiledPIDController> {
|
||||
public:
|
||||
/**
|
||||
* Allocates a ProfiledPIDController with the given constants for Kp, Ki, and
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#include <wpi/raw_ostream.h>
|
||||
|
||||
#include "frc/drive/RobotDriveBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -96,7 +98,9 @@ class SpeedController;
|
||||
* RobotDrive#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 {
|
||||
class DifferentialDrive : public RobotDriveBase,
|
||||
public Sendable,
|
||||
public SendableHelper<DifferentialDrive> {
|
||||
public:
|
||||
static constexpr double kDefaultQuickStopThreshold = 0.2;
|
||||
static constexpr double kDefaultQuickStopAlpha = 0.1;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -13,6 +13,8 @@
|
||||
|
||||
#include "frc/drive/RobotDriveBase.h"
|
||||
#include "frc/drive/Vector2d.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -44,7 +46,9 @@ class SpeedController;
|
||||
* and the positive Z axis points down. Rotations follow the right-hand rule, so
|
||||
* clockwise rotation around the Z axis is positive.
|
||||
*/
|
||||
class KilloughDrive : public RobotDriveBase {
|
||||
class KilloughDrive : public RobotDriveBase,
|
||||
public Sendable,
|
||||
public SendableHelper<KilloughDrive> {
|
||||
public:
|
||||
static constexpr double kDefaultLeftMotorAngle = 60.0;
|
||||
static constexpr double kDefaultRightMotorAngle = 120.0;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -12,6 +12,8 @@
|
||||
#include <wpi/raw_ostream.h>
|
||||
|
||||
#include "frc/drive/RobotDriveBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -62,7 +64,9 @@ class SpeedController;
|
||||
* RobotDrive#MecanumDrive_Polar(double, double, double) if a
|
||||
* deadband of 0 is used.
|
||||
*/
|
||||
class MecanumDrive : public RobotDriveBase {
|
||||
class MecanumDrive : public RobotDriveBase,
|
||||
public Sendable,
|
||||
public SendableHelper<MecanumDrive> {
|
||||
public:
|
||||
/**
|
||||
* Construct a MecanumDrive.
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include <wpi/raw_ostream.h>
|
||||
|
||||
#include "frc/MotorSafety.h"
|
||||
#include "frc/smartdashboard/SendableBase.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -22,7 +21,7 @@ class SpeedController;
|
||||
/**
|
||||
* Common base class for drive platforms.
|
||||
*/
|
||||
class RobotDriveBase : public MotorSafety, public SendableBase {
|
||||
class RobotDriveBase : public MotorSafety {
|
||||
public:
|
||||
/**
|
||||
* The location of a motor on the robot for the purpose of driving.
|
||||
|
||||
@@ -9,13 +9,10 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <wpi/Twine.h>
|
||||
#include <wpi/deprecated.h>
|
||||
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class Sendable;
|
||||
|
||||
/**
|
||||
* The LiveWindow class is the public interface for putting sensors and
|
||||
* actuators on the LiveWindow.
|
||||
@@ -33,44 +30,6 @@ class LiveWindow {
|
||||
*/
|
||||
static LiveWindow* GetInstance();
|
||||
|
||||
/**
|
||||
* Add a component to the LiveWindow.
|
||||
*
|
||||
* @param sendable component to add
|
||||
*/
|
||||
void Add(std::shared_ptr<Sendable> component);
|
||||
|
||||
/**
|
||||
* Add a component to the LiveWindow.
|
||||
*
|
||||
* @param sendable component to add
|
||||
*/
|
||||
void Add(Sendable* component);
|
||||
|
||||
/**
|
||||
* Add a child component to a component.
|
||||
*
|
||||
* @param parent parent component
|
||||
* @param child child component
|
||||
*/
|
||||
void AddChild(Sendable* parent, std::shared_ptr<Sendable> component);
|
||||
|
||||
/**
|
||||
* Add a child component to a component.
|
||||
*
|
||||
* @param parent parent component
|
||||
* @param child child component
|
||||
*/
|
||||
void AddChild(Sendable* parent, void* component);
|
||||
|
||||
/**
|
||||
* Remove the component from the LiveWindow.
|
||||
*
|
||||
* @param sendable component to remove
|
||||
* @return true if the component was removed; false if it was not present
|
||||
*/
|
||||
bool Remove(Sendable* component);
|
||||
|
||||
/**
|
||||
* Enable telemetry for a single component.
|
||||
*
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user