mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
[commands] Remove deprecated classes and functions (#5409)
Removes:
- PerpetualCommand
- Command.perpetually()
- CommandGroupBase
- Command.IsGrouped() (C++ only)
- Command.SetGrouped() (C++ only)
- Command.withInterrupt()
- ProxyScheduleCommand
- Button
- InternalButton, JoystickButton, NetworkButton and POVButton now subclass Trigger
- Old style Trigger functions:
- Trigger.whenActive
- Trigger.whileActiveOnce
- Trigger.whileActiveContinuous
- Trigger.whenInactive
- Trigger.toggleWhenActive
- Trigger.cancelWhenActive
- CommandScheduler.clearButtons()
- CommandScheduler.addButtons() (Java only)
- Command supplier constructor of SelectCommand
This commit is contained in:
@@ -11,7 +11,6 @@
|
||||
#include "frc2/command/ParallelCommandGroup.h"
|
||||
#include "frc2/command/ParallelDeadlineGroup.h"
|
||||
#include "frc2/command/ParallelRaceGroup.h"
|
||||
#include "frc2/command/PerpetualCommand.h"
|
||||
#include "frc2/command/RepeatCommand.h"
|
||||
#include "frc2/command/SequentialCommandGroup.h"
|
||||
#include "frc2/command/WaitCommand.h"
|
||||
@@ -54,10 +53,6 @@ CommandPtr Command::WithInterruptBehavior(
|
||||
return std::move(*this).ToPtr().WithInterruptBehavior(interruptBehavior);
|
||||
}
|
||||
|
||||
CommandPtr Command::WithInterrupt(std::function<bool()> condition) && {
|
||||
return std::move(*this).ToPtr().Until(std::move(condition));
|
||||
}
|
||||
|
||||
CommandPtr Command::BeforeStarting(
|
||||
std::function<void()> toRun,
|
||||
std::initializer_list<Subsystem*> requirements) && {
|
||||
@@ -82,12 +77,6 @@ CommandPtr Command::AndThen(std::function<void()> toRun,
|
||||
return std::move(*this).ToPtr().AndThen(std::move(toRun), requirements);
|
||||
}
|
||||
|
||||
PerpetualCommand Command::Perpetually() && {
|
||||
WPI_IGNORE_DEPRECATED
|
||||
return PerpetualCommand(std::move(*this).TransferOwnership());
|
||||
WPI_UNIGNORE_DEPRECATED
|
||||
}
|
||||
|
||||
CommandPtr Command::Repeatedly() && {
|
||||
return std::move(*this).ToPtr().Repeatedly();
|
||||
}
|
||||
@@ -150,14 +139,6 @@ void Command::SetComposed(bool isComposed) {
|
||||
m_isComposed = isComposed;
|
||||
}
|
||||
|
||||
bool Command::IsGrouped() const {
|
||||
return IsComposed();
|
||||
}
|
||||
|
||||
void Command::SetGrouped(bool grouped) {
|
||||
SetComposed(grouped);
|
||||
}
|
||||
|
||||
namespace frc2 {
|
||||
bool RequirementsDisjoint(Command* first, Command* second) {
|
||||
bool disjoint = true;
|
||||
|
||||
@@ -1,7 +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 "frc2/command/CommandGroupBase.h"
|
||||
|
||||
using namespace frc2;
|
||||
@@ -107,10 +107,6 @@ frc::EventLoop* CommandScheduler::GetDefaultButtonLoop() const {
|
||||
return &(m_impl->defaultButtonLoop);
|
||||
}
|
||||
|
||||
void CommandScheduler::ClearButtons() {
|
||||
m_impl->activeButtonLoop->Clear();
|
||||
}
|
||||
|
||||
void CommandScheduler::Schedule(Command* command) {
|
||||
if (m_impl->inRunLoop) {
|
||||
m_impl->toSchedule.emplace_back(command);
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "frc2/command/PerpetualCommand.h"
|
||||
|
||||
using namespace frc2;
|
||||
|
||||
PerpetualCommand::PerpetualCommand(std::unique_ptr<Command>&& command) {
|
||||
CommandScheduler::GetInstance().RequireUngrouped(command.get());
|
||||
m_command = std::move(command);
|
||||
m_command->SetComposed(true);
|
||||
AddRequirements(m_command->GetRequirements());
|
||||
}
|
||||
|
||||
void PerpetualCommand::Initialize() {
|
||||
m_command->Initialize();
|
||||
}
|
||||
|
||||
void PerpetualCommand::Execute() {
|
||||
m_command->Execute();
|
||||
}
|
||||
|
||||
void PerpetualCommand::End(bool interrupted) {
|
||||
m_command->End(interrupted);
|
||||
}
|
||||
@@ -1,41 +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 "frc2/command/ProxyScheduleCommand.h"
|
||||
|
||||
using namespace frc2;
|
||||
|
||||
ProxyScheduleCommand::ProxyScheduleCommand(
|
||||
std::span<Command* const> toSchedule) {
|
||||
SetInsert(m_toSchedule, toSchedule);
|
||||
}
|
||||
|
||||
ProxyScheduleCommand::ProxyScheduleCommand(Command* toSchedule) {
|
||||
SetInsert(m_toSchedule, {&toSchedule, 1});
|
||||
}
|
||||
|
||||
void ProxyScheduleCommand::Initialize() {
|
||||
for (auto* command : m_toSchedule) {
|
||||
command->Schedule();
|
||||
}
|
||||
}
|
||||
|
||||
void ProxyScheduleCommand::End(bool interrupted) {
|
||||
if (interrupted) {
|
||||
for (auto* command : m_toSchedule) {
|
||||
command->Cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ProxyScheduleCommand::Execute() {
|
||||
m_finished = true;
|
||||
for (auto* command : m_toSchedule) {
|
||||
m_finished &= !command->IsScheduled();
|
||||
}
|
||||
}
|
||||
|
||||
bool ProxyScheduleCommand::IsFinished() {
|
||||
return m_finished;
|
||||
}
|
||||
@@ -1,101 +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 "frc2/command/button/Button.h"
|
||||
|
||||
#include <wpi/deprecated.h>
|
||||
|
||||
using namespace frc2;
|
||||
|
||||
Button::Button(std::function<bool()> isPressed) : Trigger(isPressed) {}
|
||||
|
||||
Button Button::WhenPressed(Command* command) {
|
||||
WPI_IGNORE_DEPRECATED
|
||||
WhenActive(command);
|
||||
WPI_UNIGNORE_DEPRECATED
|
||||
return *this;
|
||||
}
|
||||
|
||||
Button Button::WhenPressed(std::function<void()> toRun,
|
||||
std::initializer_list<Subsystem*> requirements) {
|
||||
WPI_IGNORE_DEPRECATED
|
||||
WhenActive(std::move(toRun), requirements);
|
||||
WPI_UNIGNORE_DEPRECATED
|
||||
return *this;
|
||||
}
|
||||
|
||||
Button Button::WhenPressed(std::function<void()> toRun,
|
||||
std::span<Subsystem* const> requirements) {
|
||||
WPI_IGNORE_DEPRECATED
|
||||
WhenActive(std::move(toRun), requirements);
|
||||
WPI_UNIGNORE_DEPRECATED
|
||||
return *this;
|
||||
}
|
||||
|
||||
Button Button::WhileHeld(Command* command) {
|
||||
WPI_IGNORE_DEPRECATED
|
||||
WhileActiveContinous(command);
|
||||
WPI_UNIGNORE_DEPRECATED
|
||||
return *this;
|
||||
}
|
||||
|
||||
Button Button::WhileHeld(std::function<void()> toRun,
|
||||
std::initializer_list<Subsystem*> requirements) {
|
||||
WPI_IGNORE_DEPRECATED
|
||||
WhileActiveContinous(std::move(toRun), requirements);
|
||||
WPI_UNIGNORE_DEPRECATED
|
||||
return *this;
|
||||
}
|
||||
|
||||
Button Button::WhileHeld(std::function<void()> toRun,
|
||||
std::span<Subsystem* const> requirements) {
|
||||
WPI_IGNORE_DEPRECATED
|
||||
WhileActiveContinous(std::move(toRun), requirements);
|
||||
WPI_UNIGNORE_DEPRECATED
|
||||
return *this;
|
||||
}
|
||||
|
||||
Button Button::WhenHeld(Command* command) {
|
||||
WPI_IGNORE_DEPRECATED
|
||||
WhileActiveOnce(command);
|
||||
WPI_UNIGNORE_DEPRECATED
|
||||
return *this;
|
||||
}
|
||||
|
||||
Button Button::WhenReleased(Command* command) {
|
||||
WPI_IGNORE_DEPRECATED
|
||||
WhenInactive(command);
|
||||
WPI_UNIGNORE_DEPRECATED
|
||||
return *this;
|
||||
}
|
||||
|
||||
Button Button::WhenReleased(std::function<void()> toRun,
|
||||
std::initializer_list<Subsystem*> requirements) {
|
||||
WPI_IGNORE_DEPRECATED
|
||||
WhenInactive(std::move(toRun), requirements);
|
||||
WPI_UNIGNORE_DEPRECATED
|
||||
return *this;
|
||||
}
|
||||
|
||||
Button Button::WhenReleased(std::function<void()> toRun,
|
||||
std::span<Subsystem* const> requirements) {
|
||||
WPI_IGNORE_DEPRECATED
|
||||
WhenInactive(std::move(toRun), requirements);
|
||||
WPI_UNIGNORE_DEPRECATED
|
||||
return *this;
|
||||
}
|
||||
|
||||
Button Button::ToggleWhenPressed(Command* command) {
|
||||
WPI_IGNORE_DEPRECATED
|
||||
ToggleWhenActive(command);
|
||||
WPI_UNIGNORE_DEPRECATED
|
||||
return *this;
|
||||
}
|
||||
|
||||
Button Button::CancelWhenPressed(Command* command) {
|
||||
WPI_IGNORE_DEPRECATED
|
||||
CancelWhenActive(command);
|
||||
WPI_UNIGNORE_DEPRECATED
|
||||
return *this;
|
||||
}
|
||||
@@ -4,19 +4,15 @@
|
||||
|
||||
#include "frc2/command/button/NetworkButton.h"
|
||||
|
||||
#include <wpi/deprecated.h>
|
||||
|
||||
using namespace frc2;
|
||||
|
||||
WPI_IGNORE_DEPRECATED
|
||||
NetworkButton::NetworkButton(nt::BooleanTopic topic)
|
||||
: NetworkButton(topic.Subscribe(false)) {}
|
||||
|
||||
NetworkButton::NetworkButton(nt::BooleanSubscriber sub)
|
||||
: Button([sub = std::make_shared<nt::BooleanSubscriber>(std::move(sub))] {
|
||||
: Trigger([sub = std::make_shared<nt::BooleanSubscriber>(std::move(sub))] {
|
||||
return sub->GetTopic().GetInstance().IsConnected() && sub->Get();
|
||||
}) {}
|
||||
WPI_UNIGNORE_DEPRECATED
|
||||
|
||||
NetworkButton::NetworkButton(std::shared_ptr<nt::NetworkTable> table,
|
||||
std::string_view field)
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "frc2/command/button/Trigger.h"
|
||||
|
||||
#include <frc/filter/Debouncer.h>
|
||||
#include <wpi/deprecated.h>
|
||||
|
||||
#include "frc2/command/InstantCommand.h"
|
||||
|
||||
@@ -206,124 +205,6 @@ Trigger Trigger::ToggleOnFalse(CommandPtr&& command) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
WPI_IGNORE_DEPRECATED
|
||||
Trigger Trigger::WhenActive(Command* command) {
|
||||
return OnTrue(command);
|
||||
}
|
||||
|
||||
Trigger Trigger::WhenActive(std::function<void()> toRun,
|
||||
std::initializer_list<Subsystem*> requirements) {
|
||||
return WhenActive(std::move(toRun),
|
||||
{requirements.begin(), requirements.end()});
|
||||
}
|
||||
|
||||
Trigger Trigger::WhenActive(std::function<void()> toRun,
|
||||
std::span<Subsystem* const> requirements) {
|
||||
return WhenActive(InstantCommand(std::move(toRun), requirements));
|
||||
}
|
||||
|
||||
Trigger Trigger::WhileActiveContinous(Command* command) {
|
||||
m_loop->Bind([condition = m_condition, previous = m_condition(),
|
||||
command = std::move(command)]() mutable {
|
||||
bool current = condition();
|
||||
|
||||
if (current) {
|
||||
command->Schedule();
|
||||
} else if (previous && !current) {
|
||||
command->Cancel();
|
||||
}
|
||||
|
||||
previous = current;
|
||||
});
|
||||
return *this;
|
||||
}
|
||||
|
||||
Trigger Trigger::WhileActiveContinous(
|
||||
std::function<void()> toRun,
|
||||
std::initializer_list<Subsystem*> requirements) {
|
||||
return WhileActiveContinous(std::move(toRun),
|
||||
{requirements.begin(), requirements.end()});
|
||||
}
|
||||
|
||||
Trigger Trigger::WhileActiveContinous(
|
||||
std::function<void()> toRun, std::span<Subsystem* const> requirements) {
|
||||
return WhileActiveContinous(InstantCommand(std::move(toRun), requirements));
|
||||
}
|
||||
|
||||
Trigger Trigger::WhileActiveOnce(Command* command) {
|
||||
m_loop->Bind(
|
||||
[condition = m_condition, previous = m_condition(), command]() mutable {
|
||||
bool current = condition();
|
||||
|
||||
if (!previous && current) {
|
||||
command->Schedule();
|
||||
} else if (previous && !current) {
|
||||
command->Cancel();
|
||||
}
|
||||
|
||||
previous = current;
|
||||
});
|
||||
return *this;
|
||||
}
|
||||
|
||||
Trigger Trigger::WhenInactive(Command* command) {
|
||||
m_loop->Bind(
|
||||
[condition = m_condition, previous = m_condition(), command]() mutable {
|
||||
bool current = condition();
|
||||
|
||||
if (previous && !current) {
|
||||
command->Schedule();
|
||||
}
|
||||
|
||||
previous = current;
|
||||
});
|
||||
return *this;
|
||||
}
|
||||
|
||||
Trigger Trigger::WhenInactive(std::function<void()> toRun,
|
||||
std::initializer_list<Subsystem*> requirements) {
|
||||
return WhenInactive(std::move(toRun),
|
||||
{requirements.begin(), requirements.end()});
|
||||
}
|
||||
|
||||
Trigger Trigger::WhenInactive(std::function<void()> toRun,
|
||||
std::span<Subsystem* const> requirements) {
|
||||
return WhenInactive(InstantCommand(std::move(toRun), requirements));
|
||||
}
|
||||
|
||||
Trigger Trigger::ToggleWhenActive(Command* command) {
|
||||
m_loop->Bind([condition = m_condition, previous = m_condition(),
|
||||
command = command]() mutable {
|
||||
bool current = condition();
|
||||
|
||||
if (!previous && current) {
|
||||
if (command->IsScheduled()) {
|
||||
command->Cancel();
|
||||
} else {
|
||||
command->Schedule();
|
||||
}
|
||||
}
|
||||
|
||||
previous = current;
|
||||
});
|
||||
return *this;
|
||||
}
|
||||
|
||||
Trigger Trigger::CancelWhenActive(Command* command) {
|
||||
m_loop->Bind([condition = m_condition, previous = m_condition(),
|
||||
command = std::move(command)]() mutable {
|
||||
bool current = condition();
|
||||
|
||||
if (!previous && current) {
|
||||
command->Cancel();
|
||||
}
|
||||
|
||||
previous = current;
|
||||
});
|
||||
return *this;
|
||||
}
|
||||
WPI_UNIGNORE_DEPRECATED
|
||||
|
||||
Trigger Trigger::Debounce(units::second_t debounceTime,
|
||||
frc::Debouncer::DebounceType type) {
|
||||
return Trigger(m_loop, [debouncer = frc::Debouncer(debounceTime, type),
|
||||
|
||||
Reference in New Issue
Block a user