4
4
5
5
#include " frc2/command/Command.h"
6
6
7
+ #include " frc2/command/CommandHelper.h"
7
8
#include " frc2/command/CommandScheduler.h"
9
+ #include " frc2/command/ConditionalCommand.h"
8
10
#include " frc2/command/InstantCommand.h"
9
11
#include " frc2/command/ParallelCommandGroup.h"
10
12
#include " frc2/command/ParallelDeadlineGroup.h"
11
13
#include " frc2/command/ParallelRaceGroup.h"
12
14
#include " frc2/command/PerpetualCommand.h"
13
15
#include " frc2/command/ProxyScheduleCommand.h"
16
+ #include " frc2/command/RepeatCommand.h"
14
17
#include " frc2/command/SequentialCommandGroup.h"
15
18
#include " frc2/command/WaitCommand.h"
16
19
#include " frc2/command/WaitUntilCommand.h"
20
+ #include " frc2/command/WrapperCommand.h"
17
21
18
22
using namespace frc2 ;
19
23
@@ -30,69 +34,87 @@ void Command::Initialize() {}
30
34
void Command::Execute () {}
31
35
void Command::End (bool interrupted) {}
32
36
33
- ParallelRaceGroup Command::WithTimeout (units::second_t duration) && {
34
- std::vector<std::unique_ptr<Command>> temp;
35
- temp.emplace_back (std::make_unique<WaitCommand>(duration));
36
- temp.emplace_back (std::move (*this ).TransferOwnership ());
37
- return ParallelRaceGroup (std::move (temp));
37
+ CommandPtr Command::WithTimeout (units::second_t duration) && {
38
+ return CommandPtr (std::move (*this ).TransferOwnership ()).WithTimeout (duration);
38
39
}
39
40
40
- ParallelRaceGroup Command::Until (std::function<bool ()> condition) && {
41
- std::vector<std::unique_ptr<Command>> temp;
42
- temp.emplace_back (std::make_unique<WaitUntilCommand>(std::move (condition)));
43
- temp.emplace_back (std::move (*this ).TransferOwnership ());
44
- return ParallelRaceGroup (std::move (temp));
41
+ CommandPtr Command::Until (std::function<bool ()> condition) && {
42
+ return CommandPtr (std::move (*this ).TransferOwnership ())
43
+ .Until (std::move (condition));
45
44
}
46
45
47
- ParallelRaceGroup Command::WithInterrupt (std::function<bool ()> condition) && {
48
- std::vector<std::unique_ptr<Command>> temp;
49
- temp.emplace_back (std::make_unique<WaitUntilCommand>(std::move (condition)));
50
- temp.emplace_back (std::move (*this ).TransferOwnership ());
51
- return ParallelRaceGroup (std::move (temp));
46
+ CommandPtr Command::IgnoringDisable (bool doesRunWhenDisabled) && {
47
+ return CommandPtr (std::move (*this ).TransferOwnership ())
48
+ .IgnoringDisable (doesRunWhenDisabled);
52
49
}
53
50
54
- SequentialCommandGroup Command::BeforeStarting (
51
+ CommandPtr Command::WithInterruptBehavior (
52
+ InterruptionBehavior interruptBehavior) && {
53
+ return CommandPtr (std::move (*this ).TransferOwnership ())
54
+ .WithInterruptBehavior (interruptBehavior);
55
+ }
56
+
57
+ CommandPtr Command::WithInterrupt (std::function<bool ()> condition) && {
58
+ return CommandPtr (std::move (*this ).TransferOwnership ())
59
+ .Until (std::move (condition));
60
+ }
61
+
62
+ CommandPtr Command::BeforeStarting (
55
63
std::function<void ()> toRun,
56
64
std::initializer_list<Subsystem*> requirements) && {
57
65
return std::move (*this ).BeforeStarting (
58
66
std::move (toRun), {requirements.begin (), requirements.end ()});
59
67
}
60
68
61
- SequentialCommandGroup Command::BeforeStarting (
62
- std::function<void ()> toRun, wpi::span<Subsystem* const > requirements) && {
63
- std::vector<std::unique_ptr<Command>> temp;
64
- temp.emplace_back (
65
- std::make_unique<InstantCommand>(std::move (toRun), requirements));
66
- temp.emplace_back (std::move (*this ).TransferOwnership ());
67
- return SequentialCommandGroup (std::move (temp));
69
+ CommandPtr Command::BeforeStarting (
70
+ std::function<void ()> toRun, std::span<Subsystem* const > requirements) && {
71
+ return CommandPtr (std::move (*this ).TransferOwnership ())
72
+ .BeforeStarting (std::move (toRun), requirements);
68
73
}
69
74
70
- SequentialCommandGroup Command::AndThen (
71
- std::function<void ()> toRun,
72
- std::initializer_list<Subsystem*> requirements) && {
75
+ CommandPtr Command::AndThen (std::function<void ()> toRun,
76
+ std::initializer_list<Subsystem*> requirements) && {
73
77
return std::move (*this ).AndThen (std::move (toRun),
74
78
{requirements.begin (), requirements.end ()});
75
79
}
76
80
77
- SequentialCommandGroup Command::AndThen (
78
- std::function<void ()> toRun, wpi::span<Subsystem* const > requirements) && {
79
- std::vector<std::unique_ptr<Command>> temp;
80
- temp.emplace_back (std::move (*this ).TransferOwnership ());
81
- temp.emplace_back (
82
- std::make_unique<InstantCommand>(std::move (toRun), requirements));
83
- return SequentialCommandGroup (std::move (temp));
81
+ CommandPtr Command::AndThen (std::function<void ()> toRun,
82
+ std::span<Subsystem* const > requirements) && {
83
+ return CommandPtr (std::move (*this ).TransferOwnership ())
84
+ .AndThen (std::move (toRun), requirements);
84
85
}
85
86
86
87
PerpetualCommand Command::Perpetually () && {
88
+ WPI_IGNORE_DEPRECATED
87
89
return PerpetualCommand (std::move (*this ).TransferOwnership ());
90
+ WPI_UNIGNORE_DEPRECATED
91
+ }
92
+
93
+ CommandPtr Command::Repeatedly () && {
94
+ return CommandPtr (std::move (*this ).TransferOwnership ()).Repeatedly ();
95
+ }
96
+
97
+ CommandPtr Command::AsProxy () && {
98
+ return CommandPtr (std::move (*this ).TransferOwnership ()).AsProxy ();
99
+ }
100
+
101
+ CommandPtr Command::Unless (std::function<bool ()> condition) && {
102
+ return CommandPtr (std::move (*this ).TransferOwnership ())
103
+ .Unless (std::move (condition));
104
+ }
105
+
106
+ CommandPtr Command::FinallyDo (std::function<void (bool )> end) && {
107
+ return CommandPtr (std::move (*this ).TransferOwnership ())
108
+ .FinallyDo (std::move (end));
88
109
}
89
110
90
- ProxyScheduleCommand Command::AsProxy () {
91
- return ProxyScheduleCommand (this );
111
+ CommandPtr Command::HandleInterrupt (std::function<void (void )> handler) && {
112
+ return CommandPtr (std::move (*this ).TransferOwnership ())
113
+ .HandleInterrupt (std::move (handler));
92
114
}
93
115
94
- void Command::Schedule (bool interruptible ) {
95
- CommandScheduler::GetInstance ().Schedule (interruptible, this );
116
+ void Command::Schedule () {
117
+ CommandScheduler::GetInstance ().Schedule (this );
96
118
}
97
119
98
120
void Command::Cancel () {
0 commit comments