Skip to content

Commit

Permalink
[wpilib] Remove LiveWindow (#7733)
Browse files Browse the repository at this point in the history
This will be replaced by a different mechanism, but removing it eases
the initial implementation burden of a new Telemetry/Sendable framework.
  • Loading branch information
PeterJohnson authored Jan 25, 2025
1 parent adbe95e commit eee30c4
Show file tree
Hide file tree
Showing 88 changed files with 85 additions and 1,356 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@ public void setActuator(boolean value) {
// ignore
}

@Override
public void setSafeState(Runnable func) {
// ignore
}

@Override
public void addBooleanProperty(String key, BooleanSupplier getter, BooleanConsumer setter) {
m_updates.add(() -> m_backend.log(key, getter.getAsBoolean()));
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
org.gradle.jvmargs=-Xmx2g
org.gradle.jvmargs=-Xmx4g
org.ysb33r.gradle.doxygen.download.url=https://frcmaven.wpi.edu/artifactory/generic-release-mirror/doxygen
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import edu.wpi.first.wpilibj.TimedRobot;
import edu.wpi.first.wpilibj.Watchdog;
import edu.wpi.first.wpilibj.event.EventLoop;
import edu.wpi.first.wpilibj.livewindow.LiveWindow;
import edu.wpi.first.wpilibj2.command.Command.InterruptionBehavior;
import java.io.PrintWriter;
import java.io.StringWriter;
Expand Down Expand Up @@ -101,13 +100,7 @@ public static synchronized CommandScheduler getInstance() {

CommandScheduler() {
HAL.report(tResourceType.kResourceType_Command, tInstances.kCommand2_Scheduler);
SendableRegistry.addLW(this, "Scheduler");
LiveWindow.setEnabledListener(
() -> {
disable();
cancelAll();
});
LiveWindow.setDisabledListener(this::enable);
SendableRegistry.add(this, "Scheduler");
}

/**
Expand All @@ -123,8 +116,6 @@ public void setPeriod(double period) {
@Override
public void close() {
SendableRegistry.remove(this);
LiveWindow.setEnabledListener(null);
LiveWindow.setDisabledListener(null);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public abstract class SubsystemBase implements Subsystem, Sendable {
public SubsystemBase() {
String name = this.getClass().getSimpleName();
name = name.substring(name.lastIndexOf('.') + 1);
SendableRegistry.addLW(this, name, name);
SendableRegistry.add(this, name, name);
CommandScheduler.getInstance().registerSubsystem(this);
}

Expand All @@ -31,7 +31,7 @@ public SubsystemBase() {
*/
@SuppressWarnings("this-escape")
public SubsystemBase(String name) {
SendableRegistry.addLW(this, name, name);
SendableRegistry.add(this, name, name);
CommandScheduler.getInstance().registerSubsystem(this);
}

Expand Down Expand Up @@ -79,7 +79,7 @@ public void setSubsystem(String subsystem) {
* @param child sendable
*/
public void addChild(String name, Sendable child) {
SendableRegistry.addLW(child, getSubsystem(), name);
SendableRegistry.add(child, getSubsystem(), name);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include <frc/RobotBase.h>
#include <frc/RobotState.h>
#include <frc/TimedRobot.h>
#include <frc/livewindow/LiveWindow.h>
#include <hal/FRCUsageReporting.h>
#include <hal/HALBase.h>
#include <networktables/IntegerArrayTopic.h>
Expand Down Expand Up @@ -72,19 +71,11 @@ CommandScheduler::CommandScheduler()
}) {
HAL_Report(HALUsageReporting::kResourceType_Command,
HALUsageReporting::kCommand2_Scheduler);
wpi::SendableRegistry::AddLW(this, "Scheduler");
frc::LiveWindow::SetEnabledCallback([this] {
this->Disable();
this->CancelAll();
});
frc::LiveWindow::SetDisabledCallback([this] { this->Enable(); });
wpi::SendableRegistry::Add(this, "Scheduler");
}

CommandScheduler::~CommandScheduler() {
wpi::SendableRegistry::Remove(this);
frc::LiveWindow::SetEnabledCallback(nullptr);
frc::LiveWindow::SetDisabledCallback(nullptr);

std::unique_ptr<Impl>().swap(m_impl);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
using namespace frc2;

SubsystemBase::SubsystemBase() {
wpi::SendableRegistry::AddLW(this, GetTypeName(*this));
wpi::SendableRegistry::Add(this, GetTypeName(*this));
CommandScheduler::GetInstance().RegisterSubsystem({this});
}

SubsystemBase::SubsystemBase(std::string_view name) {
wpi::SendableRegistry::AddLW(this, name);
wpi::SendableRegistry::Add(this, name);
CommandScheduler::GetInstance().RegisterSubsystem({this});
}

Expand Down Expand Up @@ -71,5 +71,5 @@ void SubsystemBase::SetSubsystem(std::string_view name) {
}

void SubsystemBase::AddChild(std::string name, wpi::Sendable* child) {
wpi::SendableRegistry::AddLW(child, GetSubsystem(), name);
wpi::SendableRegistry::Add(child, GetSubsystem(), name);
}
2 changes: 1 addition & 1 deletion wpilibc/src/main/native/cpp/ADXL345_I2C.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ ADXL345_I2C::ADXL345_I2C(I2C::Port port, Range range, int deviceAddress)
HAL_Report(HALUsageReporting::kResourceType_ADXL345,
HALUsageReporting::kADXL345_I2C, 0);

wpi::SendableRegistry::AddLW(this, "ADXL345_I2C", port);
wpi::SendableRegistry::Add(this, "ADXL345_I2C", port);
}

I2C::Port ADXL345_I2C::GetI2CPort() const {
Expand Down
4 changes: 2 additions & 2 deletions wpilibc/src/main/native/cpp/AnalogAccelerometer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ void AnalogAccelerometer::InitAccelerometer() {
HAL_Report(HALUsageReporting::kResourceType_Accelerometer,
m_analogInput->GetChannel() + 1);

wpi::SendableRegistry::AddLW(this, "Accelerometer",
m_analogInput->GetChannel());
wpi::SendableRegistry::Add(this, "Accelerometer",
m_analogInput->GetChannel());
}
4 changes: 2 additions & 2 deletions wpilibc/src/main/native/cpp/AnalogEncoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ void AnalogEncoder::Init(double fullRange, double expectedZero) {
m_fullRange = fullRange;
m_expectedZero = expectedZero;

wpi::SendableRegistry::AddLW(this, "Analog Encoder",
m_analogInput->GetChannel());
wpi::SendableRegistry::Add(this, "Analog Encoder",
m_analogInput->GetChannel());
}

double AnalogEncoder::Get() const {
Expand Down
2 changes: 1 addition & 1 deletion wpilibc/src/main/native/cpp/AnalogInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ AnalogInput::AnalogInput(int channel) {

HAL_Report(HALUsageReporting::kResourceType_AnalogChannel, channel + 1);

wpi::SendableRegistry::AddLW(this, "AnalogInput", channel);
wpi::SendableRegistry::Add(this, "AnalogInput", channel);
}

int AnalogInput::GetValue() const {
Expand Down
4 changes: 2 additions & 2 deletions wpilibc/src/main/native/cpp/AnalogPotentiometer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ AnalogPotentiometer::AnalogPotentiometer(std::shared_ptr<AnalogInput> input,
: m_analog_input(std::move(input)),
m_fullRange(fullRange),
m_offset(offset) {
wpi::SendableRegistry::AddLW(this, "AnalogPotentiometer",
m_analog_input->GetChannel());
wpi::SendableRegistry::Add(this, "AnalogPotentiometer",
m_analog_input->GetChannel());
}

double AnalogPotentiometer::Get() const {
Expand Down
4 changes: 2 additions & 2 deletions wpilibc/src/main/native/cpp/AnalogTrigger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ AnalogTrigger::AnalogTrigger(std::shared_ptr<AnalogInput> input)
int index = GetIndex();

HAL_Report(HALUsageReporting::kResourceType_AnalogTrigger, index + 1);
wpi::SendableRegistry::AddLW(this, "AnalogTrigger", index);
wpi::SendableRegistry::Add(this, "AnalogTrigger", index);
}

AnalogTrigger::AnalogTrigger(DutyCycle& input)
Expand All @@ -55,7 +55,7 @@ AnalogTrigger::AnalogTrigger(std::shared_ptr<DutyCycle> input)
int index = GetIndex();

HAL_Report(HALUsageReporting::kResourceType_AnalogTrigger, index + 1);
wpi::SendableRegistry::AddLW(this, "AnalogTrigger", index);
wpi::SendableRegistry::Add(this, "AnalogTrigger", index);
}

void AnalogTrigger::SetLimitsVoltage(double lower, double upper) {
Expand Down
2 changes: 1 addition & 1 deletion wpilibc/src/main/native/cpp/Compressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Compressor::Compressor(int module, PneumaticsModuleType moduleType)
m_module->EnableCompressorDigital();

HAL_Report(HALUsageReporting::kResourceType_Compressor, module + 1);
wpi::SendableRegistry::AddLW(this, "Compressor", module);
wpi::SendableRegistry::Add(this, "Compressor", module);
}

Compressor::Compressor(PneumaticsModuleType moduleType)
Expand Down
2 changes: 1 addition & 1 deletion wpilibc/src/main/native/cpp/Counter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Counter::Counter(Mode mode) {
SetMaxPeriod(0.5_s);

HAL_Report(HALUsageReporting::kResourceType_Counter, m_index + 1, mode + 1);
wpi::SendableRegistry::AddLW(this, "Counter", m_index);
wpi::SendableRegistry::Add(this, "Counter", m_index);
}

Counter::Counter(int channel) : Counter(kTwoPulse) {
Expand Down
2 changes: 1 addition & 1 deletion wpilibc/src/main/native/cpp/DigitalInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ DigitalInput::DigitalInput(int channel) {
FRC_CheckErrorStatus(status, "Channel {}", channel);

HAL_Report(HALUsageReporting::kResourceType_DigitalInput, channel + 1);
wpi::SendableRegistry::AddLW(this, "DigitalInput", channel);
wpi::SendableRegistry::Add(this, "DigitalInput", channel);
}

bool DigitalInput::Get() const {
Expand Down
2 changes: 1 addition & 1 deletion wpilibc/src/main/native/cpp/DigitalOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ DigitalOutput::DigitalOutput(int channel) {
FRC_CheckErrorStatus(status, "Channel {}", channel);

HAL_Report(HALUsageReporting::kResourceType_DigitalOutput, channel + 1);
wpi::SendableRegistry::AddLW(this, "DigitalOutput", channel);
wpi::SendableRegistry::Add(this, "DigitalOutput", channel);
}

DigitalOutput::~DigitalOutput() {
Expand Down
5 changes: 2 additions & 3 deletions wpilibc/src/main/native/cpp/DoubleSolenoid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ DoubleSolenoid::DoubleSolenoid(int module, PneumaticsModuleType moduleType,
HAL_Report(HALUsageReporting::kResourceType_Solenoid, m_reverseChannel + 1,
m_module->GetModuleNumber() + 1);

wpi::SendableRegistry::AddLW(this, "DoubleSolenoid",
m_module->GetModuleNumber(), m_forwardChannel);
wpi::SendableRegistry::Add(this, "DoubleSolenoid",
m_module->GetModuleNumber(), m_forwardChannel);
}

DoubleSolenoid::DoubleSolenoid(PneumaticsModuleType moduleType,
Expand Down Expand Up @@ -129,7 +129,6 @@ bool DoubleSolenoid::IsRevSolenoidDisabled() const {
void DoubleSolenoid::InitSendable(wpi::SendableBuilder& builder) {
builder.SetSmartDashboardType("Double Solenoid");
builder.SetActuator(true);
builder.SetSafeState([=, this] { Set(kOff); });
builder.AddSmallStringProperty(
"Value",
[=, this](wpi::SmallVectorImpl<char>& buf) -> std::string_view {
Expand Down
2 changes: 1 addition & 1 deletion wpilibc/src/main/native/cpp/DutyCycle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void DutyCycle::InitDutyCycle() {
&status);
FRC_CheckErrorStatus(status, "Channel {}", GetSourceChannel());
HAL_Report(HALUsageReporting::kResourceType_DutyCycle, m_channel + 1);
wpi::SendableRegistry::AddLW(this, "Duty Cycle", m_channel);
wpi::SendableRegistry::Add(this, "Duty Cycle", m_channel);
}

int DutyCycle::GetFPGAIndex() const {
Expand Down
4 changes: 2 additions & 2 deletions wpilibc/src/main/native/cpp/DutyCycleEncoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ void DutyCycleEncoder::Init(double fullRange, double expectedZero) {
m_fullRange = fullRange;
m_expectedZero = expectedZero;

wpi::SendableRegistry::AddLW(this, "DutyCycle Encoder",
m_dutyCycle->GetSourceChannel());
wpi::SendableRegistry::Add(this, "DutyCycle Encoder",
m_dutyCycle->GetSourceChannel());
}

double DutyCycleEncoder::Get() const {
Expand Down
2 changes: 1 addition & 1 deletion wpilibc/src/main/native/cpp/Encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ void Encoder::InitEncoder(bool reverseDirection, EncodingType encodingType) {

HAL_Report(HALUsageReporting::kResourceType_Encoder, GetFPGAIndex() + 1,
encodingType);
wpi::SendableRegistry::AddLW(this, "Encoder", m_aSource->GetChannel());
wpi::SendableRegistry::Add(this, "Encoder", m_aSource->GetChannel());
}

double Encoder::DecodingScaleFactor() const {
Expand Down
27 changes: 0 additions & 27 deletions wpilibc/src/main/native/cpp/IterativeRobotBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

#include "frc/DSControlWord.h"
#include "frc/Errors.h"
#include "frc/livewindow/LiveWindow.h"
#include "frc/smartdashboard/SmartDashboard.h"

using namespace frc;
Expand Down Expand Up @@ -96,24 +95,6 @@ void IterativeRobotBase::SetNetworkTablesFlushEnabled(bool enabled) {
m_ntFlushEnabled = enabled;
}

void IterativeRobotBase::EnableLiveWindowInTest(bool testLW) {
static bool hasReported;
if (IsTestEnabled()) {
throw FRC_MakeError(err::IncompatibleMode,
"Can't configure test mode while in test mode!");
}
if (!hasReported && testLW) {
HAL_Report(HALUsageReporting::kResourceType_SmartDashboard,
HALUsageReporting::kSmartDashboard_LiveWindow);
hasReported = true;
}
m_lwEnabledInTest = testLW;
}

bool IterativeRobotBase::IsLiveWindowEnabledInTest() {
return m_lwEnabledInTest;
}

units::second_t IterativeRobotBase::GetPeriod() const {
return m_period;
}
Expand Down Expand Up @@ -150,9 +131,6 @@ void IterativeRobotBase::LoopFunc() {
} else if (m_lastMode == Mode::kTeleop) {
TeleopExit();
} else if (m_lastMode == Mode::kTest) {
if (m_lwEnabledInTest) {
LiveWindow::SetEnabled(false);
}
TestExit();
}

Expand All @@ -167,9 +145,6 @@ void IterativeRobotBase::LoopFunc() {
TeleopInit();
m_watchdog.AddEpoch("TeleopInit()");
} else if (mode == Mode::kTest) {
if (m_lwEnabledInTest) {
LiveWindow::SetEnabled(true);
}
TestInit();
m_watchdog.AddEpoch("TestInit()");
}
Expand Down Expand Up @@ -201,8 +176,6 @@ void IterativeRobotBase::LoopFunc() {

SmartDashboard::UpdateValues();
m_watchdog.AddEpoch("SmartDashboard::UpdateValues()");
LiveWindow::UpdateValues();
m_watchdog.AddEpoch("LiveWindow::UpdateValues()");

if constexpr (IsSimulation()) {
HAL_SimPeriodicBefore();
Expand Down
3 changes: 1 addition & 2 deletions wpilibc/src/main/native/cpp/PWM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ PWM::PWM(int channel, bool registerSendable) {

HAL_Report(HALUsageReporting::kResourceType_PWM, channel + 1);
if (registerSendable) {
wpi::SendableRegistry::AddLW(this, "PWM", channel);
wpi::SendableRegistry::Add(this, "PWM", channel);
}
}

Expand Down Expand Up @@ -174,7 +174,6 @@ int PWM::GetChannel() const {
void PWM::InitSendable(wpi::SendableBuilder& builder) {
builder.SetSmartDashboardType("PWM");
builder.SetActuator(true);
builder.SetSafeState([=, this] { SetDisabled(); });
builder.AddDoubleProperty(
"Value", [=, this] { return GetPulseTime().value(); },
[=, this](double value) { SetPulseTime(units::millisecond_t{value}); });
Expand Down
4 changes: 2 additions & 2 deletions wpilibc/src/main/native/cpp/PowerDistribution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ PowerDistribution::PowerDistribution() {
HAL_Report(HALUsageReporting::kResourceType_PDP,
HALUsageReporting::kPDP_REV);
}
wpi::SendableRegistry::AddLW(this, "PowerDistribution", m_module);
wpi::SendableRegistry::Add(this, "PowerDistribution", m_module);
}

PowerDistribution::PowerDistribution(int module, ModuleType moduleType) {
Expand All @@ -68,7 +68,7 @@ PowerDistribution::PowerDistribution(int module, ModuleType moduleType) {
HAL_Report(HALUsageReporting::kResourceType_PDP,
HALUsageReporting::kPDP_REV);
}
wpi::SendableRegistry::AddLW(this, "PowerDistribution", m_module);
wpi::SendableRegistry::Add(this, "PowerDistribution", m_module);
}

int PowerDistribution::GetNumChannels() const {
Expand Down
2 changes: 1 addition & 1 deletion wpilibc/src/main/native/cpp/SharpIR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ SharpIR SharpIR::GP2Y0A51SK0F(int channel) {

SharpIR::SharpIR(int channel, double a, double b, double minCM, double maxCM)
: m_sensor(channel), m_A(a), m_B(b), m_minCM(minCM), m_maxCM(maxCM) {
wpi::SendableRegistry::AddLW(this, "SharpIR", channel);
wpi::SendableRegistry::Add(this, "SharpIR", channel);

m_simDevice = hal::SimDevice("SharpIR", m_sensor.GetChannel());
if (m_simDevice) {
Expand Down
Loading

0 comments on commit eee30c4

Please sign in to comment.