mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Remove most 2022 deprecations (#4205)
Excludes "old" commands and SimDevice functions.
This commit is contained in:
@@ -34,14 +34,6 @@ Compressor::~Compressor() {
|
||||
}
|
||||
}
|
||||
|
||||
void Compressor::Start() {
|
||||
EnableDigital();
|
||||
}
|
||||
|
||||
void Compressor::Stop() {
|
||||
Disable();
|
||||
}
|
||||
|
||||
bool Compressor::Enabled() const {
|
||||
return IsEnabled();
|
||||
}
|
||||
|
||||
@@ -233,12 +233,6 @@ Instance::~Instance() {
|
||||
}
|
||||
}
|
||||
|
||||
DriverStation& DriverStation::GetInstance() {
|
||||
::GetInstance();
|
||||
static DriverStation instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
bool DriverStation::GetStickButton(int stick, int button) {
|
||||
if (stick < 0 || stick >= kJoystickPorts) {
|
||||
FRC_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick);
|
||||
@@ -504,20 +498,12 @@ bool DriverStation::IsAutonomousEnabled() {
|
||||
return controlWord.autonomous && controlWord.enabled;
|
||||
}
|
||||
|
||||
bool DriverStation::IsOperatorControl() {
|
||||
return IsTeleop();
|
||||
}
|
||||
|
||||
bool DriverStation::IsTeleop() {
|
||||
HAL_ControlWord controlWord;
|
||||
HAL_GetControlWord(&controlWord);
|
||||
return !(controlWord.autonomous || controlWord.test);
|
||||
}
|
||||
|
||||
bool DriverStation::IsOperatorControlEnabled() {
|
||||
return IsTeleopEnabled();
|
||||
}
|
||||
|
||||
bool DriverStation::IsTeleopEnabled() {
|
||||
HAL_ControlWord controlWord;
|
||||
HAL_GetControlWord(&controlWord);
|
||||
@@ -671,10 +657,6 @@ void DriverStation::InAutonomous(bool entering) {
|
||||
::GetInstance().userInAutonomous = entering;
|
||||
}
|
||||
|
||||
void DriverStation::InOperatorControl(bool entering) {
|
||||
InTeleop(entering);
|
||||
}
|
||||
|
||||
void DriverStation::InTeleop(bool entering) {
|
||||
::GetInstance().userInTeleop = entering;
|
||||
}
|
||||
|
||||
@@ -16,9 +16,6 @@
|
||||
|
||||
using namespace frc;
|
||||
|
||||
IterativeRobotBase::IterativeRobotBase(double period)
|
||||
: IterativeRobotBase(units::second_t(period)) {}
|
||||
|
||||
IterativeRobotBase::IterativeRobotBase(units::second_t period)
|
||||
: m_period(period),
|
||||
m_watchdog(period, [this] { PrintLoopOverrunMessage(); }) {}
|
||||
|
||||
@@ -38,12 +38,6 @@ void ResetPreferencesInstance() {
|
||||
} // namespace frc::impl
|
||||
#endif
|
||||
|
||||
Preferences* Preferences::GetInstance() {
|
||||
::GetInstance();
|
||||
static Preferences instance;
|
||||
return &instance;
|
||||
}
|
||||
|
||||
std::vector<std::string> Preferences::GetKeys() {
|
||||
return ::GetInstance().table->GetKeys();
|
||||
}
|
||||
@@ -80,10 +74,6 @@ void Preferences::SetString(std::string_view key, std::string_view value) {
|
||||
entry.SetPersistent();
|
||||
}
|
||||
|
||||
void Preferences::PutString(std::string_view key, std::string_view value) {
|
||||
SetString(key, value);
|
||||
}
|
||||
|
||||
void Preferences::InitString(std::string_view key, std::string_view value) {
|
||||
auto entry = ::GetInstance().table->GetEntry(key);
|
||||
entry.SetDefaultString(value);
|
||||
@@ -96,10 +86,6 @@ void Preferences::SetInt(std::string_view key, int value) {
|
||||
entry.SetPersistent();
|
||||
}
|
||||
|
||||
void Preferences::PutInt(std::string_view key, int value) {
|
||||
SetInt(key, value);
|
||||
}
|
||||
|
||||
void Preferences::InitInt(std::string_view key, int value) {
|
||||
auto entry = ::GetInstance().table->GetEntry(key);
|
||||
entry.SetDefaultDouble(value);
|
||||
@@ -112,10 +98,6 @@ void Preferences::SetDouble(std::string_view key, double value) {
|
||||
entry.SetPersistent();
|
||||
}
|
||||
|
||||
void Preferences::PutDouble(std::string_view key, double value) {
|
||||
SetDouble(key, value);
|
||||
}
|
||||
|
||||
void Preferences::InitDouble(std::string_view key, double value) {
|
||||
auto entry = ::GetInstance().table->GetEntry(key);
|
||||
entry.SetDefaultDouble(value);
|
||||
@@ -128,10 +110,6 @@ void Preferences::SetFloat(std::string_view key, float value) {
|
||||
entry.SetPersistent();
|
||||
}
|
||||
|
||||
void Preferences::PutFloat(std::string_view key, float value) {
|
||||
SetFloat(key, value);
|
||||
}
|
||||
|
||||
void Preferences::InitFloat(std::string_view key, float value) {
|
||||
auto entry = ::GetInstance().table->GetEntry(key);
|
||||
entry.SetDefaultDouble(value);
|
||||
@@ -144,10 +122,6 @@ void Preferences::SetBoolean(std::string_view key, bool value) {
|
||||
entry.SetPersistent();
|
||||
}
|
||||
|
||||
void Preferences::PutBoolean(std::string_view key, bool value) {
|
||||
SetBoolean(key, value);
|
||||
}
|
||||
|
||||
void Preferences::InitBoolean(std::string_view key, bool value) {
|
||||
auto entry = ::GetInstance().table->GetEntry(key);
|
||||
entry.SetDefaultBoolean(value);
|
||||
@@ -160,10 +134,6 @@ void Preferences::SetLong(std::string_view key, int64_t value) {
|
||||
entry.SetPersistent();
|
||||
}
|
||||
|
||||
void Preferences::PutLong(std::string_view key, int64_t value) {
|
||||
SetLong(key, value);
|
||||
}
|
||||
|
||||
void Preferences::InitLong(std::string_view key, int64_t value) {
|
||||
auto entry = ::GetInstance().table->GetEntry(key);
|
||||
entry.SetDefaultDouble(value);
|
||||
|
||||
@@ -20,10 +20,6 @@ bool RobotState::IsEStopped() {
|
||||
return DriverStation::IsEStopped();
|
||||
}
|
||||
|
||||
bool RobotState::IsOperatorControl() {
|
||||
return IsTeleop();
|
||||
}
|
||||
|
||||
bool RobotState::IsTeleop() {
|
||||
return DriverStation::IsTeleop();
|
||||
}
|
||||
|
||||
@@ -196,16 +196,6 @@ void SPI::SetSampleDataOnTrailingEdge() {
|
||||
HAL_SetSPIOpts(m_port, m_msbFirst, m_sampleOnTrailing, m_clockIdleHigh);
|
||||
}
|
||||
|
||||
void SPI::SetSampleDataOnFalling() {
|
||||
m_sampleOnTrailing = true;
|
||||
HAL_SetSPIOpts(m_port, m_msbFirst, m_sampleOnTrailing, m_clockIdleHigh);
|
||||
}
|
||||
|
||||
void SPI::SetSampleDataOnRising() {
|
||||
m_sampleOnTrailing = false;
|
||||
HAL_SetSPIOpts(m_port, m_msbFirst, m_sampleOnTrailing, m_clockIdleHigh);
|
||||
}
|
||||
|
||||
void SPI::SetClockActiveLow() {
|
||||
m_clockIdleHigh = true;
|
||||
HAL_SetSPIOpts(m_port, m_msbFirst, m_sampleOnTrailing, m_clockIdleHigh);
|
||||
@@ -278,10 +268,6 @@ void SPI::StartAutoRate(units::second_t period) {
|
||||
FRC_CheckErrorStatus(status, "Port {}", m_port);
|
||||
}
|
||||
|
||||
void SPI::StartAutoRate(double period) {
|
||||
StartAutoRate(units::second_t(period));
|
||||
}
|
||||
|
||||
void SPI::StartAutoTrigger(DigitalSource& source, bool rising, bool falling) {
|
||||
int32_t status = 0;
|
||||
HAL_StartSPIAutoTrigger(m_port, source.GetPortHandleForRouting(),
|
||||
@@ -355,13 +341,6 @@ void SPI::InitAccumulator(units::second_t period, int cmd, int xferSize,
|
||||
m_accum->m_notifier.StartPeriodic(period * kAccumulateDepth / 2);
|
||||
}
|
||||
|
||||
void SPI::InitAccumulator(double period, int cmd, int xferSize, int validMask,
|
||||
int validValue, int dataShift, int dataSize,
|
||||
bool isSigned, bool bigEndian) {
|
||||
InitAccumulator(units::second_t(period), cmd, xferSize, validMask, validValue,
|
||||
dataShift, dataSize, isSigned, bigEndian);
|
||||
}
|
||||
|
||||
void SPI::FreeAccumulator() {
|
||||
m_accum.reset(nullptr);
|
||||
FreeAuto();
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "frc/SpeedControllerGroup.h"
|
||||
|
||||
#include <wpi/sendable/SendableBuilder.h>
|
||||
#include <wpi/sendable/SendableRegistry.h>
|
||||
|
||||
using namespace frc;
|
||||
|
||||
// Can't use a delegated constructor here because of an MSVC bug.
|
||||
// https://developercommunity.visualstudio.com/content/problem/583/compiler-bug-with-delegating-a-constructor.html
|
||||
|
||||
SpeedControllerGroup::SpeedControllerGroup(
|
||||
std::vector<std::reference_wrapper<SpeedController>>&& speedControllers)
|
||||
: m_speedControllers(std::move(speedControllers)) {
|
||||
Initialize();
|
||||
}
|
||||
|
||||
void SpeedControllerGroup::Initialize() {
|
||||
for (auto& speedController : m_speedControllers) {
|
||||
wpi::SendableRegistry::AddChild(this, &speedController.get());
|
||||
}
|
||||
static int instances = 0;
|
||||
++instances;
|
||||
wpi::SendableRegistry::Add(this, "SpeedControllerGroup", instances);
|
||||
}
|
||||
|
||||
void SpeedControllerGroup::Set(double speed) {
|
||||
for (auto speedController : m_speedControllers) {
|
||||
speedController.get().Set(m_isInverted ? -speed : speed);
|
||||
}
|
||||
}
|
||||
|
||||
double SpeedControllerGroup::Get() const {
|
||||
if (!m_speedControllers.empty()) {
|
||||
return m_speedControllers.front().get().Get() * (m_isInverted ? -1 : 1);
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
void SpeedControllerGroup::SetInverted(bool isInverted) {
|
||||
m_isInverted = isInverted;
|
||||
}
|
||||
|
||||
bool SpeedControllerGroup::GetInverted() const {
|
||||
return m_isInverted;
|
||||
}
|
||||
|
||||
void SpeedControllerGroup::Disable() {
|
||||
for (auto speedController : m_speedControllers) {
|
||||
speedController.get().Disable();
|
||||
}
|
||||
}
|
||||
|
||||
void SpeedControllerGroup::StopMotor() {
|
||||
for (auto speedController : m_speedControllers) {
|
||||
speedController.get().StopMotor();
|
||||
}
|
||||
}
|
||||
|
||||
void SpeedControllerGroup::InitSendable(wpi::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Speed Controller");
|
||||
builder.SetActuator(true);
|
||||
builder.SetSafeState([=] { StopMotor(); });
|
||||
builder.AddDoubleProperty(
|
||||
"Value", [=] { return Get(); }, [=](double value) { Set(value); });
|
||||
}
|
||||
@@ -70,8 +70,6 @@ void TimedRobot::EndCompetition() {
|
||||
HAL_StopNotifier(m_notifier, &status);
|
||||
}
|
||||
|
||||
TimedRobot::TimedRobot(double period) : TimedRobot(units::second_t(period)) {}
|
||||
|
||||
TimedRobot::TimedRobot(units::second_t period) : IterativeRobotBase(period) {
|
||||
m_startTime = Timer::GetFPGATimestamp();
|
||||
AddPeriodic([=] { LoopFunc(); }, period);
|
||||
|
||||
@@ -65,10 +65,6 @@ bool Timer::HasElapsed(units::second_t period) const {
|
||||
return Get() >= period;
|
||||
}
|
||||
|
||||
bool Timer::HasPeriodPassed(units::second_t period) {
|
||||
return AdvanceIfElapsed(period);
|
||||
}
|
||||
|
||||
bool Timer::AdvanceIfElapsed(units::second_t period) {
|
||||
if (Get() >= period) {
|
||||
// Advance the start time by the period.
|
||||
|
||||
@@ -12,20 +12,12 @@
|
||||
#include <wpi/sendable/SendableRegistry.h>
|
||||
|
||||
#include "frc/MathUtil.h"
|
||||
#include "frc/SpeedController.h"
|
||||
#include "frc/motorcontrol/MotorController.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(disable : 4996) // was declared deprecated
|
||||
#elif defined(__clang__)
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
#elif defined(__GNUC__)
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
DifferentialDrive::DifferentialDrive(SpeedController& leftMotor,
|
||||
SpeedController& rightMotor)
|
||||
DifferentialDrive::DifferentialDrive(MotorController& leftMotor,
|
||||
MotorController& rightMotor)
|
||||
: m_leftMotor(&leftMotor), m_rightMotor(&rightMotor) {
|
||||
wpi::SendableRegistry::AddChild(this, m_leftMotor);
|
||||
wpi::SendableRegistry::AddChild(this, m_rightMotor);
|
||||
|
||||
@@ -13,27 +13,19 @@
|
||||
#include <wpi/sendable/SendableRegistry.h>
|
||||
|
||||
#include "frc/MathUtil.h"
|
||||
#include "frc/SpeedController.h"
|
||||
#include "frc/motorcontrol/MotorController.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(disable : 4996) // was declared deprecated
|
||||
#elif defined(__clang__)
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
#elif defined(__GNUC__)
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
KilloughDrive::KilloughDrive(SpeedController& leftMotor,
|
||||
SpeedController& rightMotor,
|
||||
SpeedController& backMotor)
|
||||
KilloughDrive::KilloughDrive(MotorController& leftMotor,
|
||||
MotorController& rightMotor,
|
||||
MotorController& backMotor)
|
||||
: KilloughDrive(leftMotor, rightMotor, backMotor, kDefaultLeftMotorAngle,
|
||||
kDefaultRightMotorAngle, kDefaultBackMotorAngle) {}
|
||||
|
||||
KilloughDrive::KilloughDrive(SpeedController& leftMotor,
|
||||
SpeedController& rightMotor,
|
||||
SpeedController& backMotor, double leftMotorAngle,
|
||||
KilloughDrive::KilloughDrive(MotorController& leftMotor,
|
||||
MotorController& rightMotor,
|
||||
MotorController& backMotor, double leftMotorAngle,
|
||||
double rightMotorAngle, double backMotorAngle)
|
||||
: m_leftMotor(&leftMotor),
|
||||
m_rightMotor(&rightMotor),
|
||||
|
||||
@@ -13,23 +13,15 @@
|
||||
#include <wpi/sendable/SendableRegistry.h>
|
||||
|
||||
#include "frc/MathUtil.h"
|
||||
#include "frc/SpeedController.h"
|
||||
#include "frc/drive/Vector2d.h"
|
||||
#include "frc/motorcontrol/MotorController.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(disable : 4996) // was declared deprecated
|
||||
#elif defined(__clang__)
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
#elif defined(__GNUC__)
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
MecanumDrive::MecanumDrive(SpeedController& frontLeftMotor,
|
||||
SpeedController& rearLeftMotor,
|
||||
SpeedController& frontRightMotor,
|
||||
SpeedController& rearRightMotor)
|
||||
MecanumDrive::MecanumDrive(MotorController& frontLeftMotor,
|
||||
MotorController& rearLeftMotor,
|
||||
MotorController& frontRightMotor,
|
||||
MotorController& rearRightMotor)
|
||||
: m_frontLeftMotor(&frontLeftMotor),
|
||||
m_rearLeftMotor(&rearLeftMotor),
|
||||
m_frontRightMotor(&frontRightMotor),
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
|
||||
#include <hal/FRCUsageReporting.h>
|
||||
|
||||
#include "frc/MathUtil.h"
|
||||
#include "frc/motorcontrol/MotorController.h"
|
||||
|
||||
using namespace frc;
|
||||
@@ -31,10 +30,6 @@ void RobotDriveBase::FeedWatchdog() {
|
||||
Feed();
|
||||
}
|
||||
|
||||
double RobotDriveBase::ApplyDeadband(double value, double deadband) {
|
||||
return frc::ApplyDeadband(value, deadband);
|
||||
}
|
||||
|
||||
void RobotDriveBase::Desaturate(wpi::span<double> wheelSpeeds) {
|
||||
double maxMagnitude = std::abs(wheelSpeeds[0]);
|
||||
for (size_t i = 1; i < wheelSpeeds.size(); i++) {
|
||||
|
||||
@@ -75,12 +75,6 @@ std::shared_ptr<Component> Instance::GetOrAdd(wpi::Sendable* sendable) {
|
||||
return data;
|
||||
}
|
||||
|
||||
LiveWindow* LiveWindow::GetInstance() {
|
||||
::GetInstance();
|
||||
static LiveWindow instance;
|
||||
return &instance;
|
||||
}
|
||||
|
||||
void LiveWindow::SetEnabledCallback(std::function<void()> func) {
|
||||
::GetInstance().enabled = func;
|
||||
}
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "frc/SpeedController.h"
|
||||
#include "frc/motorcontrol/MotorController.h"
|
||||
|
||||
#include <frc/RobotController.h>
|
||||
|
||||
using namespace frc;
|
||||
|
||||
void SpeedController::SetVoltage(units::volt_t output) {
|
||||
void MotorController::SetVoltage(units::volt_t output) {
|
||||
Set(output / units::volt_t(RobotController::GetInputVoltage()));
|
||||
}
|
||||
Reference in New Issue
Block a user