Skip to content

Commit bab2af0

Browse files
authored
[commands] Remove EndlessCommand (#4483)
1 parent 6931760 commit bab2af0

File tree

7 files changed

+32
-138
lines changed

7 files changed

+32
-138
lines changed

cpp/frc2/command/Command.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include "frc2/command/CommandHelper.h"
88
#include "frc2/command/CommandScheduler.h"
99
#include "frc2/command/ConditionalCommand.h"
10-
#include "frc2/command/EndlessCommand.h"
1110
#include "frc2/command/InstantCommand.h"
1211
#include "frc2/command/ParallelCommandGroup.h"
1312
#include "frc2/command/ParallelDeadlineGroup.h"
@@ -91,10 +90,6 @@ PerpetualCommand Command::Perpetually() && {
9190
WPI_UNIGNORE_DEPRECATED
9291
}
9392

94-
CommandPtr Command::Endlessly() && {
95-
return CommandPtr(std::move(*this).TransferOwnership()).Endlessly();
96-
}
97-
9893
CommandPtr Command::Repeatedly() && {
9994
return CommandPtr(std::move(*this).TransferOwnership()).Repeatedly();
10095
}

cpp/frc2/command/CommandPtr.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
#include "frc2/command/CommandScheduler.h"
88
#include "frc2/command/ConditionalCommand.h"
9-
#include "frc2/command/EndlessCommand.h"
109
#include "frc2/command/InstantCommand.h"
1110
#include "frc2/command/ParallelCommandGroup.h"
1211
#include "frc2/command/ParallelDeadlineGroup.h"
@@ -26,11 +25,6 @@ CommandPtr CommandPtr::Repeatedly() && {
2625
return std::move(*this);
2726
}
2827

29-
CommandPtr CommandPtr::Endlessly() && {
30-
m_ptr = std::make_unique<EndlessCommand>(std::move(m_ptr));
31-
return std::move(*this);
32-
}
33-
3428
CommandPtr CommandPtr::AsProxy() && {
3529
m_ptr = std::make_unique<ProxyScheduleCommand>(std::move(m_ptr));
3630
return std::move(*this);

cpp/frc2/command/EndlessCommand.cpp

Lines changed: 0 additions & 28 deletions
This file was deleted.

include/frc2/command/Command.h

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -200,19 +200,21 @@ class Command {
200200
* conditions. The decorated command can still be interrupted or canceled.
201201
*
202202
* @return the decorated command
203-
* @deprecated replace with EndlessCommand
203+
* @deprecated PerpetualCommand violates the assumption that execute() doesn't
204+
get called after isFinished() returns true -- an assumption that should be
205+
valid. This was unsafe/undefined behavior from the start, and RepeatCommand
206+
provides an easy way to achieve similar end results with slightly different (and
207+
safe) semantics.
204208
*/
205-
WPI_DEPRECATED("Replace with Endlessly()")
209+
WPI_DEPRECATED(
210+
"PerpetualCommand violates the assumption that execute() doesn't get "
211+
"called after isFinished() returns true -- an assumption that should be "
212+
"valid."
213+
"This was unsafe/undefined behavior from the start, and RepeatCommand "
214+
"provides an easy way to achieve similar end results with slightly "
215+
"different (and safe) semantics.")
206216
PerpetualCommand Perpetually() &&;
207217

208-
/**
209-
* Decorates this command to run endlessly, ignoring its ordinary end
210-
* conditions. The decorated command can still be interrupted or canceled.
211-
*
212-
* @return the decorated command
213-
*/
214-
[[nodiscard]] CommandPtr Endlessly() &&;
215-
216218
/**
217219
* Decorates this command to run repeatedly, restarting it when it ends, until
218220
* this command is interrupted. The decorated command can still be canceled.

include/frc2/command/CommandPtr.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,6 @@ class CommandPtr final {
4646
*/
4747
[[nodiscard]] CommandPtr Repeatedly() &&;
4848

49-
/**
50-
* Decorates this command to run endlessly, ignoring its ordinary end
51-
* conditions. The decorated command can still be interrupted or canceled.
52-
*
53-
* @return the decorated command
54-
*/
55-
[[nodiscard]] CommandPtr Endlessly() &&;
56-
5749
/**
5850
* Decorates this command to run "by proxy" by wrapping it in a
5951
* ProxyScheduleCommand. This is useful for "forking off" from command groups

include/frc2/command/EndlessCommand.h

Lines changed: 0 additions & 77 deletions
This file was deleted.

include/frc2/command/PerpetualCommand.h

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ namespace frc2 {
2929
*
3030
* This class is provided by the NewCommands VendorDep
3131
*
32-
* @deprecated replace with EndlessCommand
32+
* @deprecated PerpetualCommand violates the assumption that execute() doesn't
33+
get called after isFinished() returns true -- an assumption that should be
34+
valid. This was unsafe/undefined behavior from the start, and RepeatCommand
35+
provides an easy way to achieve similar end results with slightly different (and
36+
safe) semantics.
3337
*/
3438
class PerpetualCommand : public CommandHelper<CommandBase, PerpetualCommand> {
3539
public:
@@ -40,10 +44,16 @@ class PerpetualCommand : public CommandHelper<CommandBase, PerpetualCommand> {
4044
*
4145
* @param command the command to run perpetually
4246
*/
43-
WPI_DEPRECATED("Replace with EndlessCommand")
47+
WPI_DEPRECATED(
48+
"PerpetualCommand violates the assumption that execute() doesn't get "
49+
"called after isFinished() returns true -- an assumption that should be "
50+
"valid."
51+
"This was unsafe/undefined behavior from the start, and RepeatCommand "
52+
"provides an easy way to achieve similar end results with slightly "
53+
"different (and safe) semantics.")
4454
explicit PerpetualCommand(std::unique_ptr<Command>&& command);
45-
4655
WPI_IGNORE_DEPRECATED
56+
4757
/**
4858
* Creates a new PerpetualCommand. Will run another command in perpetuity,
4959
* ignoring that command's end conditions, unless this command itself is
@@ -53,7 +63,13 @@ class PerpetualCommand : public CommandHelper<CommandBase, PerpetualCommand> {
5363
*/
5464
template <class T, typename = std::enable_if_t<std::is_base_of_v<
5565
Command, std::remove_reference_t<T>>>>
56-
WPI_DEPRECATED("Replace with EndlessCommand")
66+
WPI_DEPRECATED(
67+
"PerpetualCommand violates the assumption that execute() doesn't get "
68+
"called after isFinished() returns true -- an assumption that should be "
69+
"valid."
70+
"This was unsafe/undefined behavior from the start, and RepeatCommand "
71+
"provides an easy way to achieve similar end results with slightly "
72+
"different (and safe) semantics.")
5773
explicit PerpetualCommand(T&& command)
5874
: PerpetualCommand(std::make_unique<std::remove_reference_t<T>>(
5975
std::forward<T>(command))) {}

0 commit comments

Comments
 (0)