mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-02 02:51:42 +00:00
Split Sendable into NT and non-NT portions (#3432)
The non-NT portion has been moved to wpiutil. The NT portion has been moved to ntcore (as NTSendable). SendableBuilder similarly split and moved. SendableRegistry moved to wpiutil. In C++, SendableHelper also moved to wpiutil. This enables use of Sendable from wpimath and also enables moving several classes from wpilib to wpimath.
This commit is contained in:
@@ -4,13 +4,13 @@
|
||||
|
||||
#include "frc2/command/CommandBase.h"
|
||||
|
||||
#include <frc/smartdashboard/SendableBuilder.h>
|
||||
#include <frc/smartdashboard/SendableRegistry.h>
|
||||
#include <wpi/sendable/SendableBuilder.h>
|
||||
#include <wpi/sendable/SendableRegistry.h>
|
||||
|
||||
using namespace frc2;
|
||||
|
||||
CommandBase::CommandBase() {
|
||||
frc::SendableRegistry::GetInstance().Add(this, GetTypeName(*this));
|
||||
wpi::SendableRegistry::GetInstance().Add(this, GetTypeName(*this));
|
||||
}
|
||||
|
||||
void CommandBase::AddRequirements(
|
||||
@@ -31,22 +31,22 @@ wpi::SmallSet<Subsystem*, 4> CommandBase::GetRequirements() const {
|
||||
}
|
||||
|
||||
void CommandBase::SetName(std::string_view name) {
|
||||
frc::SendableRegistry::GetInstance().SetName(this, name);
|
||||
wpi::SendableRegistry::GetInstance().SetName(this, name);
|
||||
}
|
||||
|
||||
std::string CommandBase::GetName() const {
|
||||
return frc::SendableRegistry::GetInstance().GetName(this);
|
||||
return wpi::SendableRegistry::GetInstance().GetName(this);
|
||||
}
|
||||
|
||||
std::string CommandBase::GetSubsystem() const {
|
||||
return frc::SendableRegistry::GetInstance().GetSubsystem(this);
|
||||
return wpi::SendableRegistry::GetInstance().GetSubsystem(this);
|
||||
}
|
||||
|
||||
void CommandBase::SetSubsystem(std::string_view subsystem) {
|
||||
frc::SendableRegistry::GetInstance().SetSubsystem(this, subsystem);
|
||||
wpi::SendableRegistry::GetInstance().SetSubsystem(this, subsystem);
|
||||
}
|
||||
|
||||
void CommandBase::InitSendable(frc::SendableBuilder& builder) {
|
||||
void CommandBase::InitSendable(wpi::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Command");
|
||||
builder.AddStringProperty(
|
||||
".name", [this] { return GetName(); }, nullptr);
|
||||
|
||||
@@ -10,13 +10,13 @@
|
||||
#include <frc/RobotState.h>
|
||||
#include <frc/TimedRobot.h>
|
||||
#include <frc/livewindow/LiveWindow.h>
|
||||
#include <frc/smartdashboard/SendableBuilder.h>
|
||||
#include <frc/smartdashboard/SendableRegistry.h>
|
||||
#include <hal/FRCUsageReporting.h>
|
||||
#include <hal/HALBase.h>
|
||||
#include <networktables/NTSendableBuilder.h>
|
||||
#include <networktables/NetworkTableEntry.h>
|
||||
#include <wpi/DenseMap.h>
|
||||
#include <wpi/SmallVector.h>
|
||||
#include <wpi/sendable/SendableRegistry.h>
|
||||
|
||||
#include "frc2/command/CommandGroupBase.h"
|
||||
#include "frc2/command/CommandState.h"
|
||||
@@ -70,7 +70,7 @@ CommandScheduler::CommandScheduler()
|
||||
}) {
|
||||
HAL_Report(HALUsageReporting::kResourceType_Command,
|
||||
HALUsageReporting::kCommand2_Scheduler);
|
||||
frc::SendableRegistry::GetInstance().AddLW(this, "Scheduler");
|
||||
wpi::SendableRegistry::GetInstance().AddLW(this, "Scheduler");
|
||||
auto scheduler = frc::LiveWindow::GetInstance();
|
||||
scheduler->enabled = [this] {
|
||||
this->Disable();
|
||||
@@ -80,7 +80,7 @@ CommandScheduler::CommandScheduler()
|
||||
}
|
||||
|
||||
CommandScheduler::~CommandScheduler() {
|
||||
frc::SendableRegistry::GetInstance().Remove(this);
|
||||
wpi::SendableRegistry::GetInstance().Remove(this);
|
||||
auto scheduler = frc::LiveWindow::GetInstance();
|
||||
scheduler->enabled = nullptr;
|
||||
scheduler->disabled = nullptr;
|
||||
@@ -428,7 +428,7 @@ void CommandScheduler::OnCommandFinish(Action action) {
|
||||
m_impl->finishActions.emplace_back(std::move(action));
|
||||
}
|
||||
|
||||
void CommandScheduler::InitSendable(frc::SendableBuilder& builder) {
|
||||
void CommandScheduler::InitSendable(nt::NTSendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Scheduler");
|
||||
auto namesEntry = builder.GetEntry("Names");
|
||||
auto idsEntry = builder.GetEntry("Ids");
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#include "frc2/command/SubsystemBase.h"
|
||||
|
||||
#include <frc/smartdashboard/SendableBuilder.h>
|
||||
#include <frc/smartdashboard/SendableRegistry.h>
|
||||
#include <wpi/sendable/SendableBuilder.h>
|
||||
#include <wpi/sendable/SendableRegistry.h>
|
||||
|
||||
#include "frc2/command/Command.h"
|
||||
#include "frc2/command/CommandScheduler.h"
|
||||
@@ -13,11 +13,11 @@
|
||||
using namespace frc2;
|
||||
|
||||
SubsystemBase::SubsystemBase() {
|
||||
frc::SendableRegistry::GetInstance().AddLW(this, GetTypeName(*this));
|
||||
wpi::SendableRegistry::GetInstance().AddLW(this, GetTypeName(*this));
|
||||
CommandScheduler::GetInstance().RegisterSubsystem({this});
|
||||
}
|
||||
|
||||
void SubsystemBase::InitSendable(frc::SendableBuilder& builder) {
|
||||
void SubsystemBase::InitSendable(wpi::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Subsystem");
|
||||
builder.AddBooleanProperty(
|
||||
".hasDefault", [this] { return GetDefaultCommand() != nullptr; },
|
||||
@@ -48,22 +48,22 @@ void SubsystemBase::InitSendable(frc::SendableBuilder& builder) {
|
||||
}
|
||||
|
||||
std::string SubsystemBase::GetName() const {
|
||||
return frc::SendableRegistry::GetInstance().GetName(this);
|
||||
return wpi::SendableRegistry::GetInstance().GetName(this);
|
||||
}
|
||||
|
||||
void SubsystemBase::SetName(std::string_view name) {
|
||||
frc::SendableRegistry::GetInstance().SetName(this, name);
|
||||
wpi::SendableRegistry::GetInstance().SetName(this, name);
|
||||
}
|
||||
|
||||
std::string SubsystemBase::GetSubsystem() const {
|
||||
return frc::SendableRegistry::GetInstance().GetSubsystem(this);
|
||||
return wpi::SendableRegistry::GetInstance().GetSubsystem(this);
|
||||
}
|
||||
|
||||
void SubsystemBase::SetSubsystem(std::string_view name) {
|
||||
frc::SendableRegistry::GetInstance().SetSubsystem(this, name);
|
||||
wpi::SendableRegistry::GetInstance().SetSubsystem(this, name);
|
||||
}
|
||||
|
||||
void SubsystemBase::AddChild(std::string name, frc::Sendable* child) {
|
||||
auto& registry = frc::SendableRegistry::GetInstance();
|
||||
void SubsystemBase::AddChild(std::string name, wpi::Sendable* child) {
|
||||
auto& registry = wpi::SendableRegistry::GetInstance();
|
||||
registry.AddLW(child, GetSubsystem(), name);
|
||||
}
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include <frc/smartdashboard/Sendable.h>
|
||||
#include <frc/smartdashboard/SendableHelper.h>
|
||||
#include <wpi/SmallSet.h>
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
#include <wpi/span.h>
|
||||
|
||||
#include "frc2/command/Command.h"
|
||||
@@ -20,8 +20,8 @@ namespace frc2 {
|
||||
* A Sendable base class for Commands.
|
||||
*/
|
||||
class CommandBase : public Command,
|
||||
public frc::Sendable,
|
||||
public frc::SendableHelper<CommandBase> {
|
||||
public wpi::Sendable,
|
||||
public wpi::SendableHelper<CommandBase> {
|
||||
public:
|
||||
/**
|
||||
* Adds the specified requirements to the command.
|
||||
@@ -69,7 +69,7 @@ class CommandBase : public Command,
|
||||
*/
|
||||
void SetSubsystem(std::string_view subsystem);
|
||||
|
||||
void InitSendable(frc::SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
|
||||
protected:
|
||||
CommandBase();
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
|
||||
#include <frc/Errors.h>
|
||||
#include <frc/Watchdog.h>
|
||||
#include <frc/smartdashboard/Sendable.h>
|
||||
#include <frc/smartdashboard/SendableHelper.h>
|
||||
#include <networktables/NTSendable.h>
|
||||
#include <units/time.h>
|
||||
#include <wpi/FunctionExtras.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
#include <wpi/span.h>
|
||||
|
||||
namespace frc2 {
|
||||
@@ -27,8 +27,8 @@ class Subsystem;
|
||||
* with the scheduler using RegisterSubsystem() in order for their Periodic()
|
||||
* methods to be called and for their default commands to be scheduled.
|
||||
*/
|
||||
class CommandScheduler final : public frc::Sendable,
|
||||
public frc::SendableHelper<CommandScheduler> {
|
||||
class CommandScheduler final : public nt::NTSendable,
|
||||
public wpi::SendableHelper<CommandScheduler> {
|
||||
public:
|
||||
/**
|
||||
* Returns the Scheduler instance.
|
||||
@@ -332,7 +332,7 @@ class CommandScheduler final : public frc::Sendable,
|
||||
*/
|
||||
void OnCommandFinish(Action action);
|
||||
|
||||
void InitSendable(frc::SendableBuilder& builder) override;
|
||||
void InitSendable(nt::NTSendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
// Constructor; private as this is a singleton
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include <frc/smartdashboard/Sendable.h>
|
||||
#include <frc/smartdashboard/SendableHelper.h>
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
#include "frc2/command/Subsystem.h"
|
||||
|
||||
@@ -18,10 +18,10 @@ namespace frc2 {
|
||||
* provides a more intuitive method for setting the default command.
|
||||
*/
|
||||
class SubsystemBase : public Subsystem,
|
||||
public frc::Sendable,
|
||||
public frc::SendableHelper<SubsystemBase> {
|
||||
public wpi::Sendable,
|
||||
public wpi::SendableHelper<SubsystemBase> {
|
||||
public:
|
||||
void InitSendable(frc::SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
|
||||
/**
|
||||
* Gets the name of this Subsystem.
|
||||
@@ -58,7 +58,7 @@ class SubsystemBase : public Subsystem,
|
||||
* @param name name to give child
|
||||
* @param child sendable
|
||||
*/
|
||||
void AddChild(std::string name, frc::Sendable* child);
|
||||
void AddChild(std::string name, wpi::Sendable* child);
|
||||
|
||||
protected:
|
||||
SubsystemBase();
|
||||
|
||||
Reference in New Issue
Block a user