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
#include < src/helpers.h>
19
23
@@ -33,34 +37,42 @@ void Command::Execute() {}
33
37
void Command::End (bool interrupted) {}
34
38
35
39
/*
36
- ParallelRaceGroup Command::WithTimeout(units::second_t duration) && {
37
- std::vector<std::unique_ptr<Command>> temp;
38
- temp.emplace_back(std::make_unique<WaitCommand>(duration));
39
- temp.emplace_back(std::move(*this).TransferOwnership());
40
- return ParallelRaceGroup(std::move(temp));
40
+ CommandPtr Command::WithTimeout(units::second_t duration) && {
41
+ return CommandPtr(std::move(*this).TransferOwnership()).WithTimeout(duration);
41
42
}
42
43
*/
43
44
44
45
/*
45
- ParallelRaceGroup Command::Until(std::function<bool()> condition) && {
46
- std::vector<std::unique_ptr<Command>> temp;
47
- temp.emplace_back(std::make_unique<WaitUntilCommand>(std::move(condition)));
48
- temp.emplace_back(std::move(*this).TransferOwnership());
49
- return ParallelRaceGroup(std::move(temp));
46
+ CommandPtr Command::Until(std::function<bool()> condition) && {
47
+ return CommandPtr(std::move(*this).TransferOwnership())
48
+ .Until(std::move(condition));
50
49
}
51
50
*/
52
51
53
52
/*
54
- ParallelRaceGroup Command::WithInterrupt(std::function<bool()> condition) && {
55
- std::vector<std::unique_ptr<Command>> temp;
56
- temp.emplace_back(std::make_unique<WaitUntilCommand>(std::move(condition)));
57
- temp.emplace_back(std::move(*this).TransferOwnership());
58
- return ParallelRaceGroup(std::move(temp));
53
+ CommandPtr Command::IgnoringDisable(bool doesRunWhenDisabled) && {
54
+ return CommandPtr(std::move(*this).TransferOwnership())
55
+ .IgnoringDisable(doesRunWhenDisabled);
59
56
}
60
57
*/
61
58
62
59
/*
63
- SequentialCommandGroup Command::BeforeStarting(
60
+ CommandPtr Command::WithInterruptBehavior(
61
+ InterruptionBehavior interruptBehavior) && {
62
+ return CommandPtr(std::move(*this).TransferOwnership())
63
+ .WithInterruptBehavior(interruptBehavior);
64
+ }
65
+ */
66
+
67
+ /*
68
+ CommandPtr Command::WithInterrupt(std::function<bool()> condition) && {
69
+ return CommandPtr(std::move(*this).TransferOwnership())
70
+ .Until(std::move(condition));
71
+ }
72
+ */
73
+
74
+ /*
75
+ CommandPtr Command::BeforeStarting(
64
76
std::function<void()> toRun,
65
77
std::initializer_list<Subsystem*> requirements) && {
66
78
return std::move(*this).BeforeStarting(
@@ -69,54 +81,72 @@ SequentialCommandGroup Command::BeforeStarting(
69
81
*/
70
82
71
83
/*
72
- SequentialCommandGroup Command::BeforeStarting(
73
- std::function<void()> toRun, wpi::span<Subsystem* const> requirements) && {
74
- std::vector<std::unique_ptr<Command>> temp;
75
- temp.emplace_back(
76
- std::make_unique<InstantCommand>(std::move(toRun), requirements));
77
- temp.emplace_back(std::move(*this).TransferOwnership());
78
- return SequentialCommandGroup(std::move(temp));
84
+ CommandPtr Command::BeforeStarting(
85
+ std::function<void()> toRun, std::span<Subsystem* const> requirements) && {
86
+ return CommandPtr(std::move(*this).TransferOwnership())
87
+ .BeforeStarting(std::move(toRun), requirements);
79
88
}
80
89
*/
81
90
82
91
/*
83
- SequentialCommandGroup Command::AndThen(
84
- std::function<void()> toRun,
85
- std::initializer_list<Subsystem*> requirements) && {
92
+ CommandPtr Command::AndThen(std::function<void()> toRun,
93
+ std::initializer_list<Subsystem*> requirements) && {
86
94
return std::move(*this).AndThen(std::move(toRun),
87
95
{requirements.begin(), requirements.end()});
88
96
}
89
97
*/
90
98
91
99
/*
92
- SequentialCommandGroup Command::AndThen(
93
- std::function<void()> toRun, wpi::span<Subsystem* const> requirements) && {
94
- std::vector<std::unique_ptr<Command>> temp;
95
- temp.emplace_back(std::move(*this).TransferOwnership());
96
- temp.emplace_back(
97
- std::make_unique<InstantCommand>(std::move(toRun), requirements));
98
- return SequentialCommandGroup(std::move(temp));
100
+ CommandPtr Command::AndThen(std::function<void()> toRun,
101
+ std::span<Subsystem* const> requirements) && {
102
+ return CommandPtr(std::move(*this).TransferOwnership())
103
+ .AndThen(std::move(toRun), requirements);
99
104
}
100
105
*/
101
106
102
107
/*
103
108
PerpetualCommand Command::Perpetually() && {
109
+ WPI_IGNORE_DEPRECATED
104
110
return PerpetualCommand(std::move(*this).TransferOwnership());
111
+ WPI_UNIGNORE_DEPRECATED
112
+ }
113
+ */
114
+
115
+ /*
116
+ CommandPtr Command::Repeatedly() && {
117
+ return CommandPtr(std::move(*this).TransferOwnership()).Repeatedly();
118
+ }
119
+ */
120
+
121
+ /*
122
+ CommandPtr Command::AsProxy() && {
123
+ return CommandPtr(std::move(*this).TransferOwnership()).AsProxy();
105
124
}
106
125
*/
107
126
108
127
/*
109
- ProxyScheduleCommand Command::AsProxy() {
110
- return ProxyScheduleCommand(this);
128
+ CommandPtr Command::Unless(std::function<bool()> condition) && {
129
+ return CommandPtr(std::move(*this).TransferOwnership())
130
+ .Unless(std::move(condition));
111
131
}
112
132
*/
113
133
114
- void frc2::Command_Schedule (std::shared_ptr<Command> self, bool interruptible) {
115
- CommandScheduler::GetInstance ().Schedule (interruptible, self);
134
+ /*
135
+ CommandPtr Command::FinallyDo(std::function<void(bool)> end) && {
136
+ return CommandPtr(std::move(*this).TransferOwnership())
137
+ .FinallyDo(std::move(end));
138
+ }
139
+ */
140
+
141
+ /*
142
+ CommandPtr Command::HandleInterrupt(std::function<void(void)> handler) && {
143
+ return CommandPtr(std::move(*this).TransferOwnership())
144
+ .HandleInterrupt(std::move(handler));
116
145
}
146
+ */
117
147
118
148
void frc2::Command_Schedule (std::shared_ptr<Command> self) {
119
- CommandScheduler::GetInstance ().Schedule (true , self);
149
+ CommandScheduler::GetInstance ().Schedule (self);
120
150
}
121
151
122
152
void Command::Cancel () {
@@ -127,10 +157,10 @@ bool Command::IsScheduled() {
127
157
return CommandScheduler::GetInstance ().IsScheduled (this );
128
158
}
129
159
130
- bool Command::HasRequirement (std::shared_ptr< Subsystem> requirement) const {
160
+ bool Command::HasRequirement (Subsystem* requirement) const {
131
161
bool hasRequirement = false ;
132
162
for (auto && subsystem : GetRequirements ()) {
133
- hasRequirement |= requirement == subsystem;
163
+ hasRequirement |= requirement == subsystem. get () ;
134
164
}
135
165
return hasRequirement;
136
166
}
0 commit comments