Skip to content

Commit 0ed7551

Browse files
authored
Merge pull request #13 from robotpy/2023-beta
2023 beta
2 parents 5fc9143 + ec366dc commit 0ed7551

File tree

118 files changed

+3484
-1086
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+3484
-1086
lines changed

.github/workflows/dist.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ name: dist
44
on:
55
pull_request:
66
push:
7+
branches:
8+
- main
79
tags:
810
- '*'
911

1012
jobs:
1113
ci:
12-
uses: robotpy/build-actions/.github/workflows/package-ci.yml@v2022
14+
uses: robotpy/build-actions/.github/workflows/package-ci.yml@v2023
1315
with:
1416
enable_sphinx_check: false
1517
secrets:

commands2/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
CommandBase,
99
CommandGroupBase,
1010
CommandScheduler,
11-
CommandState,
1211
ConditionalCommand,
1312
FunctionalCommand,
1413
InstantCommand,
@@ -25,6 +24,7 @@
2524
ProfiledPIDSubsystem,
2625
ProxyScheduleCommand,
2726
RamseteCommand,
27+
RepeatCommand,
2828
RunCommand,
2929
ScheduleCommand,
3030
SequentialCommandGroup,
@@ -44,6 +44,7 @@
4444
WaitCommand,
4545
WaitUntilCommand,
4646
# button,
47+
# cmd,
4748
requirementsDisjoint,
4849
)
4950

@@ -52,7 +53,6 @@
5253
"CommandBase",
5354
"CommandGroupBase",
5455
"CommandScheduler",
55-
"CommandState",
5656
"ConditionalCommand",
5757
"FunctionalCommand",
5858
"InstantCommand",
@@ -69,6 +69,7 @@
6969
"ProfiledPIDSubsystem",
7070
"ProxyScheduleCommand",
7171
"RamseteCommand",
72+
"RepeatCommand",
7273
"RunCommand",
7374
"ScheduleCommand",
7475
"SequentialCommandGroup",
@@ -88,5 +89,6 @@
8889
"WaitCommand",
8990
"WaitUntilCommand",
9091
# "button",
92+
# "cmd",
9193
"requirementsDisjoint",
9294
]

commands2/button/__init__.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
11
# autogenerated by 'robotpy-build create-imports commands2.button commands2._impl.button'
2-
from .._impl.button import Button, JoystickButton, NetworkButton, POVButton
2+
from .._impl.button import (
3+
Button,
4+
CommandGenericHID,
5+
CommandJoystick,
6+
CommandPS4Controller,
7+
CommandXboxController,
8+
JoystickButton,
9+
NetworkButton,
10+
POVButton,
11+
)
312

4-
__all__ = ["Button", "JoystickButton", "NetworkButton", "POVButton"]
13+
__all__ = [
14+
"Button",
15+
"CommandGenericHID",
16+
"CommandJoystick",
17+
"CommandPS4Controller",
18+
"CommandXboxController",
19+
"JoystickButton",
20+
"NetworkButton",
21+
"POVButton",
22+
]

commands2/cmd/__init__.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# autogenerated by 'robotpy-build create-imports commands2.cmd commands2._impl.cmd'
2+
from .._impl.cmd import (
3+
deadline,
4+
either,
5+
nothing,
6+
parallel,
7+
print,
8+
race,
9+
repeatingSequence,
10+
run,
11+
runEnd,
12+
runOnce,
13+
sequence,
14+
startEnd,
15+
wait,
16+
waitUntil,
17+
)
18+
19+
__all__ = [
20+
"deadline",
21+
"either",
22+
"nothing",
23+
"parallel",
24+
"print",
25+
"race",
26+
"repeatingSequence",
27+
"run",
28+
"runEnd",
29+
"runOnce",
30+
"sequence",
31+
"startEnd",
32+
"wait",
33+
"waitUntil",
34+
]

commands2/src/Command.cpp.inl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111

1212
cls_Command
1313
.def("andThen",
14-
[](std::shared_ptr<Command> self, std::function<void()> toRun, wpi::span<std::shared_ptr<Subsystem>> requirements) {
14+
[](std::shared_ptr<Command> self, std::function<void()> toRun, std::span<std::shared_ptr<Subsystem>> requirements) {
1515
std::vector<std::shared_ptr<Command>> temp;
1616
temp.emplace_back(self);
1717
temp.emplace_back(
1818
std::make_shared<InstantCommand>(std::move(toRun), requirements));
1919
return SequentialCommandGroup(std::move(temp));
2020
},
21-
py::arg("toRun"), py::arg("requirements") = wpi::span<std::shared_ptr<Subsystem>>{},
21+
py::arg("toRun"), py::arg("requirements") = std::span<std::shared_ptr<Subsystem>>{},
2222
"Decorates this command with a runnable to run after the command finishes.\n"
2323
DECORATOR_NOTE)
2424
.def("andThen",
@@ -62,13 +62,13 @@ cls_Command
6262
DECORATOR_NOTE
6363
)
6464
.def("beforeStarting",
65-
[](std::shared_ptr<Command> self, std::function<void()> toRun, wpi::span<std::shared_ptr<Subsystem>> requirements) {
65+
[](std::shared_ptr<Command> self, std::function<void()> toRun, std::span<std::shared_ptr<Subsystem>> requirements) {
6666
std::vector<std::shared_ptr<Command>> temp;
6767
temp.emplace_back(std::make_shared<InstantCommand>(std::move(toRun), requirements));
6868
temp.emplace_back(self);
6969
return std::make_shared<SequentialCommandGroup>(std::move(temp));
7070
},
71-
py::arg("toRun"), py::arg("requirements")=wpi::span<std::shared_ptr<Subsystem> >{},
71+
py::arg("toRun"), py::arg("requirements")=std::span<std::shared_ptr<Subsystem> >{},
7272
"Decorates this command with a runnable to run before this command starts.\n"
7373
"\n"
7474
":param toRun: the Runnable to run\n"

commands2/src/Subsystem.cpp.inl

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

commands2/src/Trigger.cpp.inl

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

commands2/src/cpp/frc2/command/Command.cpp

Lines changed: 70 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,20 @@
44

55
#include "frc2/command/Command.h"
66

7+
#include "frc2/command/CommandHelper.h"
78
#include "frc2/command/CommandScheduler.h"
9+
#include "frc2/command/ConditionalCommand.h"
810
#include "frc2/command/InstantCommand.h"
911
#include "frc2/command/ParallelCommandGroup.h"
1012
#include "frc2/command/ParallelDeadlineGroup.h"
1113
#include "frc2/command/ParallelRaceGroup.h"
1214
#include "frc2/command/PerpetualCommand.h"
1315
#include "frc2/command/ProxyScheduleCommand.h"
16+
#include "frc2/command/RepeatCommand.h"
1417
#include "frc2/command/SequentialCommandGroup.h"
1518
#include "frc2/command/WaitCommand.h"
1619
#include "frc2/command/WaitUntilCommand.h"
20+
#include "frc2/command/WrapperCommand.h"
1721

1822
#include <src/helpers.h>
1923

@@ -33,34 +37,42 @@ void Command::Execute() {}
3337
void Command::End(bool interrupted) {}
3438

3539
/*
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);
4142
}
4243
*/
4344

4445
/*
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));
5049
}
5150
*/
5251

5352
/*
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);
5956
}
6057
*/
6158

6259
/*
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(
6476
std::function<void()> toRun,
6577
std::initializer_list<Subsystem*> requirements) && {
6678
return std::move(*this).BeforeStarting(
@@ -69,54 +81,72 @@ SequentialCommandGroup Command::BeforeStarting(
6981
*/
7082

7183
/*
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);
7988
}
8089
*/
8190

8291
/*
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) && {
8694
return std::move(*this).AndThen(std::move(toRun),
8795
{requirements.begin(), requirements.end()});
8896
}
8997
*/
9098

9199
/*
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);
99104
}
100105
*/
101106

102107
/*
103108
PerpetualCommand Command::Perpetually() && {
109+
WPI_IGNORE_DEPRECATED
104110
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();
105124
}
106125
*/
107126

108127
/*
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));
111131
}
112132
*/
113133

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));
116145
}
146+
*/
117147

118148
void frc2::Command_Schedule(std::shared_ptr<Command> self) {
119-
CommandScheduler::GetInstance().Schedule(true, self);
149+
CommandScheduler::GetInstance().Schedule(self);
120150
}
121151

122152
void Command::Cancel() {
@@ -127,10 +157,10 @@ bool Command::IsScheduled() {
127157
return CommandScheduler::GetInstance().IsScheduled(this);
128158
}
129159

130-
bool Command::HasRequirement(std::shared_ptr<Subsystem> requirement) const {
160+
bool Command::HasRequirement(Subsystem* requirement) const {
131161
bool hasRequirement = false;
132162
for (auto&& subsystem : GetRequirements()) {
133-
hasRequirement |= requirement == subsystem;
163+
hasRequirement |= requirement == subsystem.get();
134164
}
135165
return hasRequirement;
136166
}

commands2/src/cpp/frc2/command/CommandBase.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void CommandBase::AddRequirements(
2020
m_requirements.insert(requirements.begin(), requirements.end());
2121
}
2222

23-
void CommandBase::AddRequirements(wpi::span<std::shared_ptr<Subsystem>> requirements) {
23+
void CommandBase::AddRequirements(std::span<std::shared_ptr<Subsystem>> requirements) {
2424
m_requirements.insert(requirements.begin(), requirements.end());
2525
}
2626

0 commit comments

Comments
 (0)