diff --git a/commandsv2/src/main/native/cpp/frc2/command/Commands.cpp b/commandsv2/src/main/native/cpp/frc2/command/Commands.cpp index 687f6c2c6a..b5a333ca8f 100644 --- a/commandsv2/src/main/native/cpp/frc2/command/Commands.cpp +++ b/commandsv2/src/main/native/cpp/frc2/command/Commands.cpp @@ -22,29 +22,28 @@ #include "wpi/commands2/WaitUntilCommand.hpp" #include "wpi/util/FunctionExtras.hpp" -using namespace wpi::cmd; +namespace wpi::cmd { // Factories -CommandPtr cmd::None() { +CommandPtr None() { return InstantCommand().ToPtr(); } -CommandPtr cmd::Idle(Requirements requirements) { +CommandPtr Idle(Requirements requirements) { return Run([] {}, requirements); } -CommandPtr cmd::RunOnce(std::function action, - Requirements requirements) { +CommandPtr RunOnce(std::function action, Requirements requirements) { return InstantCommand(std::move(action), requirements).ToPtr(); } -CommandPtr cmd::Run(std::function action, Requirements requirements) { +CommandPtr Run(std::function action, Requirements requirements) { return RunCommand(std::move(action), requirements).ToPtr(); } -CommandPtr cmd::StartEnd(std::function start, std::function end, - Requirements requirements) { +CommandPtr StartEnd(std::function start, std::function end, + Requirements requirements) { return FunctionalCommand( std::move(start), [] {}, [end = std::move(end)](bool interrupted) { end(); }, @@ -52,27 +51,27 @@ CommandPtr cmd::StartEnd(std::function start, std::function end, .ToPtr(); } -CommandPtr cmd::RunEnd(std::function run, std::function end, - Requirements requirements) { +CommandPtr RunEnd(std::function run, std::function end, + Requirements requirements) { return FunctionalCommand([] {}, std::move(run), [end = std::move(end)](bool interrupted) { end(); }, [] { return false; }, requirements) .ToPtr(); } -CommandPtr cmd::StartRun(std::function start, std::function run, - Requirements requirements) { +CommandPtr StartRun(std::function start, std::function run, + Requirements requirements) { return FunctionalCommand( std::move(start), std::move(run), [](bool interrupted) {}, [] { return false; }, requirements) .ToPtr(); } -CommandPtr cmd::Print(std::string_view msg) { +CommandPtr Print(std::string_view msg) { return PrintCommand(msg).ToPtr(); } -CommandPtr cmd::DeferredProxy(wpi::util::unique_function supplier) { +CommandPtr DeferredProxy(wpi::util::unique_function supplier) { return Defer( [supplier = std::move(supplier)]() mutable { // There is no non-owning version of AsProxy(), so use the non-owning @@ -82,55 +81,55 @@ CommandPtr cmd::DeferredProxy(wpi::util::unique_function supplier) { {}); } -CommandPtr cmd::DeferredProxy( - wpi::util::unique_function supplier) { +CommandPtr DeferredProxy(wpi::util::unique_function supplier) { return Defer([supplier = std::move( supplier)]() mutable { return supplier().AsProxy(); }, {}); } -CommandPtr cmd::Wait(wpi::units::second_t duration) { +CommandPtr Wait(wpi::units::second_t duration) { return WaitCommand(duration).ToPtr(); } -CommandPtr cmd::WaitUntil(std::function condition) { +CommandPtr WaitUntil(std::function condition) { return WaitUntilCommand(condition).ToPtr(); } -CommandPtr cmd::Either(CommandPtr&& onTrue, CommandPtr&& onFalse, - std::function selector) { +CommandPtr Either(CommandPtr&& onTrue, CommandPtr&& onFalse, + std::function selector) { return ConditionalCommand(std::move(onTrue).Unwrap(), std::move(onFalse).Unwrap(), std::move(selector)) .ToPtr(); } -CommandPtr cmd::Defer(wpi::util::unique_function supplier, - Requirements requirements) { +CommandPtr Defer(wpi::util::unique_function supplier, + Requirements requirements) { return DeferredCommand(std::move(supplier), requirements).ToPtr(); } -CommandPtr cmd::Sequence(std::vector&& commands) { +CommandPtr Sequence(std::vector&& commands) { return SequentialCommandGroup(CommandPtr::UnwrapVector(std::move(commands))) .ToPtr(); } -CommandPtr cmd::RepeatingSequence(std::vector&& commands) { - return Sequence(std::move(commands)).Repeatedly(); +CommandPtr RepeatingSequence(std::vector&& commands) { + return wpi::cmd::Sequence(std::move(commands)).Repeatedly(); } -CommandPtr cmd::Parallel(std::vector&& commands) { +CommandPtr Parallel(std::vector&& commands) { return ParallelCommandGroup(CommandPtr::UnwrapVector(std::move(commands))) .ToPtr(); } -CommandPtr cmd::Race(std::vector&& commands) { +CommandPtr Race(std::vector&& commands) { return ParallelRaceGroup(CommandPtr::UnwrapVector(std::move(commands))) .ToPtr(); } -CommandPtr cmd::Deadline(CommandPtr&& deadline, - std::vector&& others) { +CommandPtr Deadline(CommandPtr&& deadline, std::vector&& others) { return ParallelDeadlineGroup(std::move(deadline).Unwrap(), CommandPtr::UnwrapVector(std::move(others))) .ToPtr(); } + +} // namespace wpi::cmd diff --git a/commandsv2/src/main/native/include/wpi/commands2/Commands.hpp b/commandsv2/src/main/native/include/wpi/commands2/Commands.hpp index cc9c491132..84e6f46ea5 100644 --- a/commandsv2/src/main/native/include/wpi/commands2/Commands.hpp +++ b/commandsv2/src/main/native/include/wpi/commands2/Commands.hpp @@ -19,11 +19,6 @@ namespace wpi::cmd { class Subsystem; -/** - * Namespace for command factories. - */ -namespace cmd { - /** * Constructs a command that does nothing, finishing immediately. */ @@ -260,6 +255,4 @@ CommandPtr Deadline(CommandPtr&& deadline, CommandPtrs&&... commands) { impl::MakeVector(std::forward(commands)...)); } -} // namespace cmd - } // namespace wpi::cmd diff --git a/commandsv2/src/test/native/cpp/wpi/command/CommandDecoratorTest.cpp b/commandsv2/src/test/native/cpp/wpi/command/CommandDecoratorTest.cpp index ab8acbcd1c..d5c1842c3c 100644 --- a/commandsv2/src/test/native/cpp/wpi/command/CommandDecoratorTest.cpp +++ b/commandsv2/src/test/native/cpp/wpi/command/CommandDecoratorTest.cpp @@ -21,7 +21,7 @@ TEST_F(CommandDecoratorTest, WithTimeout) { wpi::sim::PauseTiming(); - auto command = cmd::Idle().WithTimeout(100_ms); + auto command = Idle().WithTimeout(100_ms); scheduler.Schedule(command); scheduler.Run(); @@ -42,7 +42,7 @@ TEST_F(CommandDecoratorTest, Until) { bool finish = false; - auto command = cmd::Idle().Until([&finish] { return finish; }); + auto command = Idle().Until([&finish] { return finish; }); scheduler.Schedule(command); scheduler.Run(); @@ -85,7 +85,7 @@ TEST_F(CommandDecoratorTest, OnlyWhile) { bool run = true; - auto command = cmd::Idle().OnlyWhile([&run] { return run; }); + auto command = Idle().OnlyWhile([&run] { return run; }); scheduler.Schedule(command); scheduler.Run(); @@ -126,7 +126,7 @@ TEST_F(CommandDecoratorTest, OnlyWhileOrder) { TEST_F(CommandDecoratorTest, IgnoringDisable) { CommandScheduler scheduler = GetScheduler(); - auto command = cmd::Idle().IgnoringDisable(true); + auto command = Idle().IgnoringDisable(true); SetDSEnabled(false); @@ -141,7 +141,7 @@ TEST_F(CommandDecoratorTest, BeforeStarting) { bool finished = false; - auto command = cmd::None().BeforeStarting([&finished] { finished = true; }); + auto command = None().BeforeStarting([&finished] { finished = true; }); scheduler.Schedule(command); @@ -161,7 +161,7 @@ TEST_F(CommandDecoratorTest, AndThenLambda) { bool finished = false; - auto command = cmd::None().AndThen([&finished] { finished = true; }); + auto command = None().AndThen([&finished] { finished = true; }); scheduler.Schedule(command); @@ -181,8 +181,8 @@ TEST_F(CommandDecoratorTest, AndThen) { bool finished = false; - auto command1 = cmd::None(); - auto command2 = cmd::RunOnce([&finished] { finished = true; }); + auto command1 = None(); + auto command2 = RunOnce([&finished] { finished = true; }); auto group = std::move(command1).AndThen(std::move(command2)); scheduler.Schedule(group); @@ -203,8 +203,8 @@ TEST_F(CommandDecoratorTest, DeadlineFor) { bool finish = false; - auto dictator = cmd::WaitUntil([&finish] { return finish; }); - auto endsAfter = cmd::Idle(); + auto dictator = WaitUntil([&finish] { return finish; }); + auto endsAfter = Idle(); auto group = std::move(dictator).DeadlineFor(std::move(endsAfter)); @@ -245,8 +245,8 @@ TEST_F(CommandDecoratorTest, AlongWith) { bool finish = false; - auto command1 = cmd::WaitUntil([&finish] { return finish; }); - auto command2 = cmd::None(); + auto command1 = WaitUntil([&finish] { return finish; }); + auto command2 = None(); auto group = std::move(command1).AlongWith(std::move(command2)); @@ -264,8 +264,8 @@ TEST_F(CommandDecoratorTest, AlongWith) { TEST_F(CommandDecoratorTest, RaceWith) { CommandScheduler scheduler = GetScheduler(); - auto command1 = cmd::Idle(); - auto command2 = cmd::None(); + auto command1 = Idle(); + auto command2 = None(); auto group = std::move(command1).RaceWith(std::move(command2)); @@ -288,7 +288,7 @@ TEST_F(CommandDecoratorTest, DeadlineForOrder) { dictatorWasPolled = true; return true; }); - auto other = cmd::Run([&dictatorHasRun, &dictatorWasPolled] { + auto other = wpi::cmd::Run([&dictatorHasRun, &dictatorWasPolled] { EXPECT_TRUE(dictatorHasRun); EXPECT_TRUE(dictatorWasPolled); }); @@ -341,7 +341,7 @@ TEST_F(CommandDecoratorTest, AlongWithOrder) { firstWasPolled = true; return true; }); - auto command2 = cmd::Run([&firstHasRun, &firstWasPolled] { + auto command2 = wpi::cmd::Run([&firstHasRun, &firstWasPolled] { EXPECT_TRUE(firstHasRun); EXPECT_TRUE(firstWasPolled); }); @@ -367,7 +367,7 @@ TEST_F(CommandDecoratorTest, RaceWithOrder) { firstWasPolled = true; return true; }); - auto command2 = cmd::Run([&firstHasRun, &firstWasPolled] { + auto command2 = wpi::cmd::Run([&firstHasRun, &firstWasPolled] { EXPECT_TRUE(firstHasRun); EXPECT_TRUE(firstWasPolled); }); @@ -388,7 +388,7 @@ TEST_F(CommandDecoratorTest, Unless) { bool unlessCondition = true; auto command = - cmd::RunOnce([&hasRun] { hasRun = true; }, {}).Unless([&unlessCondition] { + RunOnce([&hasRun] { hasRun = true; }, {}).Unless([&unlessCondition] { return unlessCondition; }); @@ -409,7 +409,7 @@ TEST_F(CommandDecoratorTest, OnlyIf) { bool onlyIfCondition = false; auto command = - cmd::RunOnce([&hasRun] { hasRun = true; }, {}).OnlyIf([&onlyIfCondition] { + RunOnce([&hasRun] { hasRun = true; }, {}).OnlyIf([&onlyIfCondition] { return onlyIfCondition; }); @@ -483,7 +483,7 @@ TEST_F(CommandDecoratorTest, HandleInterrupt) { } TEST_F(CommandDecoratorTest, WithName) { - auto command = cmd::None(); + auto command = None(); std::string name{"Named"}; auto named = std::move(command).WithName(name); EXPECT_EQ(name, named.get()->GetName()); diff --git a/commandsv2/src/test/native/cpp/wpi/command/CommandPtrTest.cpp b/commandsv2/src/test/native/cpp/wpi/command/CommandPtrTest.cpp index b6e388dcae..90d6aea662 100644 --- a/commandsv2/src/test/native/cpp/wpi/command/CommandPtrTest.cpp +++ b/commandsv2/src/test/native/cpp/wpi/command/CommandPtrTest.cpp @@ -19,7 +19,7 @@ TEST_F(CommandPtrTest, MovedFrom) { int counter = 0; - CommandPtr movedFrom = cmd::Run([&counter] { counter++; }); + CommandPtr movedFrom = wpi::cmd::Run([&counter] { counter++; }); CommandPtr movedTo = std::move(movedFrom); EXPECT_NO_FATAL_FAILURE(scheduler.Schedule(movedTo)); diff --git a/commandsv2/src/test/native/cpp/wpi/command/CommandSendableButtonTest.cpp b/commandsv2/src/test/native/cpp/wpi/command/CommandSendableButtonTest.cpp index 1e84dd8d63..3cc95fb5d2 100644 --- a/commandsv2/src/test/native/cpp/wpi/command/CommandSendableButtonTest.cpp +++ b/commandsv2/src/test/native/cpp/wpi/command/CommandSendableButtonTest.cpp @@ -20,7 +20,7 @@ class CommandSendableButtonTest : public CommandTestBase { void SetUp() override { m_schedule = 0; m_cancel = 0; - m_command = cmd::StartEnd([this] { m_schedule++; }, [this] { m_cancel++; }); + m_command = StartEnd([this] { m_schedule++; }, [this] { m_cancel++; }); m_publish = wpi::nt::NetworkTableInstance::GetDefault() .GetBooleanTopic("/SmartDashboard/command/running") .Publish(); diff --git a/commandsv2/src/test/native/cpp/wpi/command/ConditionalCommandTest.cpp b/commandsv2/src/test/native/cpp/wpi/command/ConditionalCommandTest.cpp index 59eeaa462d..12c860c71c 100644 --- a/commandsv2/src/test/native/cpp/wpi/command/ConditionalCommandTest.cpp +++ b/commandsv2/src/test/native/cpp/wpi/command/ConditionalCommandTest.cpp @@ -57,72 +57,64 @@ TEST_F(ConditionalCommandTest, ConditionalCommandRequirement) { } TEST_F(ConditionalCommandTest, AllTrue) { - auto command = - cmd::Either(cmd::Idle().IgnoringDisable(true), - cmd::Idle().IgnoringDisable(true), [] { return true; }); + auto command = Either(Idle().IgnoringDisable(true), + Idle().IgnoringDisable(true), [] { return true; }); EXPECT_EQ(true, command.get()->RunsWhenDisabled()); } TEST_F(ConditionalCommandTest, AllFalse) { - auto command = - cmd::Either(cmd::Idle().IgnoringDisable(false), - cmd::Idle().IgnoringDisable(false), [] { return true; }); + auto command = Either(Idle().IgnoringDisable(false), + Idle().IgnoringDisable(false), [] { return true; }); EXPECT_EQ(false, command.get()->RunsWhenDisabled()); } TEST_F(ConditionalCommandTest, OneTrueOneFalse) { - auto command = - cmd::Either(cmd::Idle().IgnoringDisable(true), - cmd::Idle().IgnoringDisable(false), [] { return true; }); + auto command = Either(Idle().IgnoringDisable(true), + Idle().IgnoringDisable(false), [] { return true; }); EXPECT_EQ(false, command.get()->RunsWhenDisabled()); } TEST_F(ConditionalCommandTest, TwoFalseOneTrue) { - auto command = - cmd::Either(cmd::Idle().IgnoringDisable(false), - cmd::Idle().IgnoringDisable(true), [] { return true; }); + auto command = Either(Idle().IgnoringDisable(false), + Idle().IgnoringDisable(true), [] { return true; }); EXPECT_EQ(false, command.get()->RunsWhenDisabled()); } TEST_F(ConditionalCommandTest, AllCancelSelf) { - auto command = cmd::Either(cmd::Idle().WithInterruptBehavior( - Command::InterruptionBehavior::kCancelSelf), - cmd::Idle().WithInterruptBehavior( - Command::InterruptionBehavior::kCancelSelf), - [] { return true; }); + auto command = Either( + Idle().WithInterruptBehavior(Command::InterruptionBehavior::kCancelSelf), + Idle().WithInterruptBehavior(Command::InterruptionBehavior::kCancelSelf), + [] { return true; }); EXPECT_EQ(Command::InterruptionBehavior::kCancelSelf, command.get()->GetInterruptionBehavior()); } TEST_F(ConditionalCommandTest, AllCancelIncoming) { - auto command = - cmd::Either(cmd::Idle().WithInterruptBehavior( - Command::InterruptionBehavior::kCancelIncoming), - cmd::Idle().WithInterruptBehavior( - Command::InterruptionBehavior::kCancelIncoming), - [] { return false; }); + auto command = Either(Idle().WithInterruptBehavior( + Command::InterruptionBehavior::kCancelIncoming), + Idle().WithInterruptBehavior( + Command::InterruptionBehavior::kCancelIncoming), + [] { return false; }); EXPECT_EQ(Command::InterruptionBehavior::kCancelIncoming, command.get()->GetInterruptionBehavior()); } TEST_F(ConditionalCommandTest, OneCancelSelfOneIncoming) { - auto command = - cmd::Either(cmd::Idle().WithInterruptBehavior( - Command::InterruptionBehavior::kCancelSelf), - cmd::Idle().WithInterruptBehavior( - Command::InterruptionBehavior::kCancelIncoming), - [] { return false; }); + auto command = Either( + Idle().WithInterruptBehavior(Command::InterruptionBehavior::kCancelSelf), + Idle().WithInterruptBehavior( + Command::InterruptionBehavior::kCancelIncoming), + [] { return false; }); EXPECT_EQ(Command::InterruptionBehavior::kCancelSelf, command.get()->GetInterruptionBehavior()); } TEST_F(ConditionalCommandTest, OneCancelIncomingOneSelf) { - auto command = - cmd::Either(cmd::Idle().WithInterruptBehavior( - Command::InterruptionBehavior::kCancelIncoming), - cmd::Idle().WithInterruptBehavior( - Command::InterruptionBehavior::kCancelSelf), - [] { return false; }); + auto command = Either( + Idle().WithInterruptBehavior( + Command::InterruptionBehavior::kCancelIncoming), + Idle().WithInterruptBehavior(Command::InterruptionBehavior::kCancelSelf), + [] { return false; }); EXPECT_EQ(Command::InterruptionBehavior::kCancelSelf, command.get()->GetInterruptionBehavior()); } diff --git a/commandsv2/src/test/native/cpp/wpi/command/DefaultCommandTest.cpp b/commandsv2/src/test/native/cpp/wpi/command/DefaultCommandTest.cpp index e2df9f7a29..5b290de4a1 100644 --- a/commandsv2/src/test/native/cpp/wpi/command/DefaultCommandTest.cpp +++ b/commandsv2/src/test/native/cpp/wpi/command/DefaultCommandTest.cpp @@ -16,7 +16,7 @@ TEST_F(DefaultCommandTest, DefaultCommandSchedule) { TestSubsystem subsystem; - auto command = cmd::Idle({&subsystem}); + auto command = Idle({&subsystem}); scheduler.SetDefaultCommand(&subsystem, std::move(command)); auto handle = scheduler.GetDefaultCommand(&subsystem); @@ -30,8 +30,8 @@ TEST_F(DefaultCommandTest, DefaultCommandInterruptResume) { TestSubsystem subsystem; - auto command1 = cmd::Idle({&subsystem}); - auto command2 = cmd::Idle({&subsystem}); + auto command1 = Idle({&subsystem}); + auto command2 = Idle({&subsystem}); scheduler.SetDefaultCommand(&subsystem, std::move(command1)); auto handle = scheduler.GetDefaultCommand(&subsystem); diff --git a/commandsv2/src/test/native/cpp/wpi/command/DeferredCommandTest.cpp b/commandsv2/src/test/native/cpp/wpi/command/DeferredCommandTest.cpp index 65f48d477b..9dcee0fa57 100644 --- a/commandsv2/src/test/native/cpp/wpi/command/DeferredCommandTest.cpp +++ b/commandsv2/src/test/native/cpp/wpi/command/DeferredCommandTest.cpp @@ -55,7 +55,7 @@ TEST(DeferredCommandTest, DeferredSupplierOnlyCalledDuringInit) { int count = 0; DeferredCommand command{[&count] { count++; - return cmd::None(); + return None(); }, {}}; @@ -70,7 +70,7 @@ TEST(DeferredCommandTest, DeferredSupplierOnlyCalledDuringInit) { TEST(DeferredCommandTest, DeferredRequirements) { TestSubsystem subsystem; - DeferredCommand command{cmd::None, {&subsystem}}; + DeferredCommand command{None, {&subsystem}}; EXPECT_TRUE(command.GetRequirements().contains(&subsystem)); } diff --git a/commandsv2/src/test/native/cpp/wpi/command/InstantCommandTest.cpp b/commandsv2/src/test/native/cpp/wpi/command/InstantCommandTest.cpp index ac80f69ffa..bd4ec87d55 100644 --- a/commandsv2/src/test/native/cpp/wpi/command/InstantCommandTest.cpp +++ b/commandsv2/src/test/native/cpp/wpi/command/InstantCommandTest.cpp @@ -15,7 +15,7 @@ TEST_F(InstantCommandTest, InstantCommandSchedule) { int counter = 0; - auto command = cmd::RunOnce([&counter] { counter++; }); + auto command = RunOnce([&counter] { counter++; }); scheduler.Schedule(command); scheduler.Run(); diff --git a/commandsv2/src/test/native/cpp/wpi/command/ParallelCommandGroupTest.cpp b/commandsv2/src/test/native/cpp/wpi/command/ParallelCommandGroupTest.cpp index eb52bf45ad..da3a5e64ab 100644 --- a/commandsv2/src/test/native/cpp/wpi/command/ParallelCommandGroupTest.cpp +++ b/commandsv2/src/test/native/cpp/wpi/command/ParallelCommandGroupTest.cpp @@ -79,7 +79,7 @@ TEST_F(ParallelCommandGroupTest, ParallelGroupInterrupt) { TEST_F(ParallelCommandGroupTest, ParallelGroupNotScheduledCancel) { CommandScheduler scheduler = GetScheduler(); - auto group = cmd::Parallel(cmd::None(), cmd::None()); + auto group = Parallel(None(), None()); EXPECT_NO_FATAL_FAILURE(scheduler.Cancel(group)); } @@ -89,9 +89,9 @@ TEST_F(ParallelCommandGroupTest, ParallelGroupCopy) { bool finished = false; - auto command = cmd::WaitUntil([&finished] { return finished; }); + auto command = WaitUntil([&finished] { return finished; }); - auto group = cmd::Parallel(std::move(command)); + auto group = Parallel(std::move(command)); scheduler.Schedule(group); scheduler.Run(); EXPECT_TRUE(scheduler.IsScheduled(group)); @@ -108,11 +108,11 @@ TEST_F(ParallelCommandGroupTest, ParallelGroupRequirement) { TestSubsystem requirement3; TestSubsystem requirement4; - auto command1 = cmd::RunOnce([] {}, {&requirement1, &requirement2}); - auto command2 = cmd::RunOnce([] {}, {&requirement3}); - auto command3 = cmd::RunOnce([] {}, {&requirement3, &requirement4}); + auto command1 = RunOnce([] {}, {&requirement1, &requirement2}); + auto command2 = RunOnce([] {}, {&requirement3}); + auto command3 = RunOnce([] {}, {&requirement3, &requirement4}); - auto group = cmd::Parallel(std::move(command1), std::move(command2)); + auto group = Parallel(std::move(command1), std::move(command2)); scheduler.Schedule(group); scheduler.Schedule(command3); diff --git a/commandsv2/src/test/native/cpp/wpi/command/ParallelDeadlineGroupTest.cpp b/commandsv2/src/test/native/cpp/wpi/command/ParallelDeadlineGroupTest.cpp index 4edbaef6a5..3dd7988616 100644 --- a/commandsv2/src/test/native/cpp/wpi/command/ParallelDeadlineGroupTest.cpp +++ b/commandsv2/src/test/native/cpp/wpi/command/ParallelDeadlineGroupTest.cpp @@ -96,7 +96,7 @@ TEST_F(ParallelDeadlineGroupTest, SequentialGroupInterrupt) { TEST_F(ParallelDeadlineGroupTest, DeadlineGroupNotScheduledCancel) { CommandScheduler scheduler = GetScheduler(); - auto group = cmd::Deadline(cmd::None(), cmd::None()); + auto group = Deadline(None(), None()); EXPECT_NO_FATAL_FAILURE(scheduler.Cancel(group)); } @@ -106,9 +106,9 @@ TEST_F(ParallelDeadlineGroupTest, ParallelDeadlineCopy) { bool finished = false; - auto command = cmd::WaitUntil([&finished] { return finished; }); + auto command = WaitUntil([&finished] { return finished; }); - auto group = cmd::Deadline(std::move(command)); + auto group = Deadline(std::move(command)); scheduler.Schedule(group); scheduler.Run(); EXPECT_TRUE(scheduler.IsScheduled(group)); @@ -125,11 +125,11 @@ TEST_F(ParallelDeadlineGroupTest, ParallelDeadlineRequirement) { TestSubsystem requirement3; TestSubsystem requirement4; - auto command1 = cmd::RunOnce([] {}, {&requirement1, &requirement2}); - auto command2 = cmd::RunOnce([] {}, {&requirement3}); - auto command3 = cmd::RunOnce([] {}, {&requirement3, &requirement4}); + auto command1 = RunOnce([] {}, {&requirement1, &requirement2}); + auto command2 = RunOnce([] {}, {&requirement3}); + auto command3 = RunOnce([] {}, {&requirement3, &requirement4}); - auto group = cmd::Deadline(std::move(command1), std::move(command2)); + auto group = Deadline(std::move(command1), std::move(command2)); scheduler.Schedule(group); scheduler.Schedule(command3); diff --git a/commandsv2/src/test/native/cpp/wpi/command/ParallelRaceGroupTest.cpp b/commandsv2/src/test/native/cpp/wpi/command/ParallelRaceGroupTest.cpp index bcf12bbb73..3d71ad60ec 100644 --- a/commandsv2/src/test/native/cpp/wpi/command/ParallelRaceGroupTest.cpp +++ b/commandsv2/src/test/native/cpp/wpi/command/ParallelRaceGroupTest.cpp @@ -91,7 +91,7 @@ TEST_F(ParallelRaceGroupTest, ParallelRaceInterrupt) { TEST_F(ParallelRaceGroupTest, ParallelRaceNotScheduledCancel) { CommandScheduler scheduler = GetScheduler(); - auto group = cmd::Race(cmd::None(), cmd::None()); + auto group = Race(None(), None()); EXPECT_NO_FATAL_FAILURE(scheduler.Cancel(group)); } @@ -101,9 +101,9 @@ TEST_F(ParallelRaceGroupTest, ParallelRaceCopy) { bool finished = false; - auto command = cmd::WaitUntil([&finished] { return finished; }); + auto command = WaitUntil([&finished] { return finished; }); - auto group = cmd::Race(std::move(command)); + auto group = Race(std::move(command)); scheduler.Schedule(group); scheduler.Run(); EXPECT_TRUE(scheduler.IsScheduled(group)); @@ -120,11 +120,11 @@ TEST_F(ParallelRaceGroupTest, RaceGroupRequirement) { TestSubsystem requirement3; TestSubsystem requirement4; - auto command1 = cmd::RunOnce([] {}, {&requirement1, &requirement2}); - auto command2 = cmd::RunOnce([] {}, {&requirement3}); - auto command3 = cmd::RunOnce([] {}, {&requirement3, &requirement4}); + auto command1 = RunOnce([] {}, {&requirement1, &requirement2}); + auto command2 = RunOnce([] {}, {&requirement3}); + auto command3 = RunOnce([] {}, {&requirement3, &requirement4}); - auto group = cmd::Race(std::move(command1), std::move(command2)); + auto group = Race(std::move(command1), std::move(command2)); scheduler.Schedule(group); scheduler.Schedule(command3); @@ -140,12 +140,12 @@ TEST_F(ParallelRaceGroupTest, ParallelRaceOnlyCallsEndOnce) { bool finished2 = false; bool finished3 = false; - auto command1 = cmd::WaitUntil([&finished1] { return finished1; }); - auto command2 = cmd::WaitUntil([&finished2] { return finished2; }); - auto command3 = cmd::WaitUntil([&finished3] { return finished3; }); + auto command1 = WaitUntil([&finished1] { return finished1; }); + auto command2 = WaitUntil([&finished2] { return finished2; }); + auto command3 = WaitUntil([&finished3] { return finished3; }); - auto group1 = cmd::Sequence(std::move(command1), std::move(command2)); - auto group2 = cmd::Race(std::move(group1), std::move(command3)); + auto group1 = Sequence(std::move(command1), std::move(command2)); + auto group2 = Race(std::move(group1), std::move(command3)); scheduler.Schedule(group2); scheduler.Run(); diff --git a/commandsv2/src/test/native/cpp/wpi/command/PrintCommandTest.cpp b/commandsv2/src/test/native/cpp/wpi/command/PrintCommandTest.cpp index 1773db64df..faae85d1b9 100644 --- a/commandsv2/src/test/native/cpp/wpi/command/PrintCommandTest.cpp +++ b/commandsv2/src/test/native/cpp/wpi/command/PrintCommandTest.cpp @@ -15,7 +15,7 @@ class PrintCommandTest : public CommandTestBase {}; TEST_F(PrintCommandTest, PrintCommandSchedule) { CommandScheduler scheduler = GetScheduler(); - auto command = cmd::Print("Test!"); + auto command = Print("Test!"); testing::internal::CaptureStdout(); diff --git a/commandsv2/src/test/native/cpp/wpi/command/ProxyCommandTest.cpp b/commandsv2/src/test/native/cpp/wpi/command/ProxyCommandTest.cpp index 4efa04f5a2..efe7f3b3e0 100644 --- a/commandsv2/src/test/native/cpp/wpi/command/ProxyCommandTest.cpp +++ b/commandsv2/src/test/native/cpp/wpi/command/ProxyCommandTest.cpp @@ -54,7 +54,7 @@ TEST_F(ProxyCommandTest, OwningCommandSchedule) { bool scheduled = false; - auto command = cmd::RunOnce([&scheduled] { scheduled = true; }).AsProxy(); + auto command = RunOnce([&scheduled] { scheduled = true; }).AsProxy(); scheduler.Schedule(command); scheduler.Run(); @@ -67,7 +67,7 @@ TEST_F(ProxyCommandTest, OwningCommandEnd) { bool finished = false; - auto command = cmd::WaitUntil([&finished] { return finished; }).AsProxy(); + auto command = WaitUntil([&finished] { return finished; }).AsProxy(); scheduler.Schedule(command); scheduler.Run(); diff --git a/commandsv2/src/test/native/cpp/wpi/command/RunCommandTest.cpp b/commandsv2/src/test/native/cpp/wpi/command/RunCommandTest.cpp index ef7fa767e1..f3ba35f4e0 100644 --- a/commandsv2/src/test/native/cpp/wpi/command/RunCommandTest.cpp +++ b/commandsv2/src/test/native/cpp/wpi/command/RunCommandTest.cpp @@ -15,7 +15,7 @@ TEST_F(RunCommandTest, RunCommandSchedule) { int counter = 0; - auto command = cmd::Run([&counter] { counter++; }); + auto command = wpi::cmd::Run([&counter] { counter++; }); scheduler.Schedule(command); scheduler.Run(); diff --git a/commandsv2/src/test/native/cpp/wpi/command/SchedulerTest.cpp b/commandsv2/src/test/native/cpp/wpi/command/SchedulerTest.cpp index cfdf03b828..9c510bafaa 100644 --- a/commandsv2/src/test/native/cpp/wpi/command/SchedulerTest.cpp +++ b/commandsv2/src/test/native/cpp/wpi/command/SchedulerTest.cpp @@ -16,7 +16,7 @@ class SchedulerTest : public CommandTestBase {}; TEST_F(SchedulerTest, SchedulerLambdaTestNoInterrupt) { CommandScheduler scheduler = GetScheduler(); - auto command = cmd::None(); + auto command = None(); int counter = 0; @@ -33,7 +33,7 @@ TEST_F(SchedulerTest, SchedulerLambdaTestNoInterrupt) { TEST_F(SchedulerTest, SchedulerLambdaInterrupt) { CommandScheduler scheduler = GetScheduler(); - auto command = cmd::Idle(); + auto command = Idle(); int counter = 0; @@ -57,7 +57,7 @@ TEST_F(SchedulerTest, SchedulerLambdaInterruptNoCause) { counter++; }); - auto command = cmd::Idle(); + auto command = Idle(); scheduler.Schedule(command); scheduler.Cancel(command); @@ -71,7 +71,7 @@ TEST_F(SchedulerTest, SchedulerLambdaInterruptCause) { int counter = 0; TestSubsystem subsystem{}; - auto command = cmd::Idle({&subsystem}); + auto command = Idle({&subsystem}); InstantCommand interruptor([] {}, {&subsystem}); scheduler.OnCommandInterrupt( @@ -93,11 +93,11 @@ TEST_F(SchedulerTest, SchedulerLambdaInterruptCauseInRunLoop) { int counter = 0; TestSubsystem subsystem{}; - auto command = cmd::Idle({&subsystem}); + auto command = Idle({&subsystem}); InstantCommand interruptor([] {}, {&subsystem}); // This command will schedule interruptor in execute() inside the run loop auto interruptorScheduler = - cmd::RunOnce([&] { scheduler.Schedule(&interruptor); }); + RunOnce([&] { scheduler.Schedule(&interruptor); }); scheduler.OnCommandInterrupt( [&](const Command&, const std::optional& cause) { @@ -143,8 +143,8 @@ TEST_F(SchedulerTest, UnregisterSubsystem) { TEST_F(SchedulerTest, SchedulerCancelAll) { CommandScheduler scheduler = GetScheduler(); - auto command1 = cmd::Idle(); - auto command2 = cmd::Idle(); + auto command1 = Idle(); + auto command2 = Idle(); int counter = 0; @@ -167,7 +167,7 @@ TEST_F(SchedulerTest, ScheduleScheduledNoOp) { int counter = 0; - auto command = cmd::StartEnd([&counter] { counter++; }, [] {}); + auto command = StartEnd([&counter] { counter++; }, [] {}); scheduler.Schedule(command); scheduler.Schedule(command); @@ -202,9 +202,7 @@ TEST_F(SchedulerTest, ScheduleCommandPtr) { { auto commandPtr = TrackDestroyCommand([&destructionCounter] { destructionCounter++; }) - .AlongWith(wpi::cmd::InstantCommand([&runCounter] { - runCounter++; - }).ToPtr()) + .AlongWith(InstantCommand([&runCounter] { runCounter++; }).ToPtr()) .Until([&finish] { return finish; }); EXPECT_EQ(destructionCounter, 0) << "Composition should not delete command"; diff --git a/commandsv2/src/test/native/cpp/wpi/command/SchedulingRecursionTest.cpp b/commandsv2/src/test/native/cpp/wpi/command/SchedulingRecursionTest.cpp index 2f15e4e11b..d27d569b2d 100644 --- a/commandsv2/src/test/native/cpp/wpi/command/SchedulingRecursionTest.cpp +++ b/commandsv2/src/test/native/cpp/wpi/command/SchedulingRecursionTest.cpp @@ -56,7 +56,8 @@ TEST_P(SchedulingRecursionTest, CancelFromInitialize) { TestSubsystem requirement; SelfCancellingCommand selfCancels{&scheduler, counter, &requirement, GetParam()}; - auto other = cmd::Run([&hasOtherRun] { hasOtherRun = true; }, {&requirement}); + auto other = + wpi::cmd::Run([&hasOtherRun] { hasOtherRun = true; }, {&requirement}); scheduler.Schedule(&selfCancels); scheduler.Run(); @@ -79,7 +80,8 @@ TEST_F(SchedulingRecursionTest, CancelFromInitializeAction) { [&counter](bool) { counter++; }, [] { return false; }, {&requirement}}; - auto other = cmd::Run([&hasOtherRun] { hasOtherRun = true; }, {&requirement}); + auto other = + wpi::cmd::Run([&hasOtherRun] { hasOtherRun = true; }, {&requirement}); scheduler.OnCommandInitialize([&scheduler, &selfCancels](const Command&) { scheduler.Cancel(&selfCancels); }); @@ -102,7 +104,8 @@ TEST_P(SchedulingRecursionTest, TestSubsystem requirement; SelfCancellingCommand selfCancels{&scheduler, counter, &requirement, GetParam()}; - auto other = cmd::Run([&hasOtherRun] { hasOtherRun = true; }, {&requirement}); + auto other = + wpi::cmd::Run([&hasOtherRun] { hasOtherRun = true; }, {&requirement}); scheduler.SetDefaultCommand(&requirement, std::move(other)); scheduler.Schedule(&selfCancels); @@ -285,7 +288,7 @@ TEST_P(SchedulingRecursionTest, ScheduleFromEndInterrupt) { TestSubsystem requirement; SelfCancellingCommand selfCancels{&scheduler, counter, &requirement, GetParam()}; - auto other = cmd::Idle({&requirement}); + auto other = Idle({&requirement}); scheduler.Schedule(&selfCancels); EXPECT_NO_THROW({ scheduler.Schedule(other); }); @@ -298,8 +301,8 @@ TEST_F(SchedulingRecursionTest, ScheduleFromEndInterruptAction) { CommandScheduler scheduler = GetScheduler(); int counter = 0; TestSubsystem requirement; - auto selfCancels = cmd::Idle({&requirement}); - auto other = cmd::Idle({&requirement}); + auto selfCancels = Idle({&requirement}); + auto other = Idle({&requirement}); scheduler.OnCommandInterrupt([&](const Command&) { counter++; scheduler.Schedule(other); @@ -320,7 +323,7 @@ TEST_F(SchedulingRecursionTest, CancelDefaultCommandFromEnd) { [&counter](bool) { counter++; }, [] { return false; }, {&requirement}}; - auto other = cmd::Idle({&requirement}); + auto other = Idle({&requirement}); FunctionalCommand cancelDefaultCommand{[] {}, [] {}, [&](bool) { counter++; @@ -343,15 +346,15 @@ TEST_F(SchedulingRecursionTest, CancelDefaultCommandFromEnd) { TEST_F(SchedulingRecursionTest, CancelNextCommandFromCommand) { CommandScheduler scheduler = GetScheduler(); - wpi::cmd::RunCommand* command1Ptr = nullptr; - wpi::cmd::RunCommand* command2Ptr = nullptr; + RunCommand* command1Ptr = nullptr; + RunCommand* command2Ptr = nullptr; int counter = 0; - auto command1 = wpi::cmd::RunCommand([&counter, &command2Ptr, &scheduler] { + auto command1 = RunCommand([&counter, &command2Ptr, &scheduler] { scheduler.Cancel(command2Ptr); counter++; }); - auto command2 = wpi::cmd::RunCommand([&counter, &command1Ptr, &scheduler] { + auto command2 = RunCommand([&counter, &command1Ptr, &scheduler] { scheduler.Cancel(command1Ptr); counter++; }); diff --git a/commandsv2/src/test/native/cpp/wpi/command/SelectCommandTest.cpp b/commandsv2/src/test/native/cpp/wpi/command/SelectCommandTest.cpp index 8e9f1c41f4..cb0702f995 100644 --- a/commandsv2/src/test/native/cpp/wpi/command/SelectCommandTest.cpp +++ b/commandsv2/src/test/native/cpp/wpi/command/SelectCommandTest.cpp @@ -49,13 +49,12 @@ TEST_F(SelectCommandTest, SelectCommandRequirement) { TestSubsystem requirement3; TestSubsystem requirement4; - auto command1 = cmd::RunOnce([] {}, {&requirement1, &requirement2}); - auto command2 = cmd::RunOnce([] {}, {&requirement3}); - auto command3 = cmd::RunOnce([] {}, {&requirement3, &requirement4}); + auto command1 = RunOnce([] {}, {&requirement1, &requirement2}); + auto command2 = RunOnce([] {}, {&requirement3}); + auto command3 = RunOnce([] {}, {&requirement3, &requirement4}); - auto select = - cmd::Select([] { return 1; }, std::pair(1, std::move(command1)), - std::pair(2, std::move(command2))); + auto select = Select([] { return 1; }, std::pair(1, std::move(command1)), + std::pair(2, std::move(command2))); scheduler.Schedule(select); scheduler.Schedule(command3); diff --git a/commandsv2/src/test/native/cpp/wpi/command/SequentialCommandGroupTest.cpp b/commandsv2/src/test/native/cpp/wpi/command/SequentialCommandGroupTest.cpp index 691bc44ba4..596cec1c6e 100644 --- a/commandsv2/src/test/native/cpp/wpi/command/SequentialCommandGroupTest.cpp +++ b/commandsv2/src/test/native/cpp/wpi/command/SequentialCommandGroupTest.cpp @@ -106,9 +106,9 @@ TEST_F(SequentialCommandGroupTest, SequentialGroupCopy) { bool finished = false; - auto command = cmd::WaitUntil([&finished] { return finished; }); + auto command = WaitUntil([&finished] { return finished; }); - auto group = cmd::Sequence(std::move(command)); + auto group = Sequence(std::move(command)); scheduler.Schedule(group); scheduler.Run(); EXPECT_TRUE(scheduler.IsScheduled(group)); @@ -125,11 +125,11 @@ TEST_F(SequentialCommandGroupTest, SequentialGroupRequirement) { TestSubsystem requirement3; TestSubsystem requirement4; - auto command1 = cmd::RunOnce([] {}, {&requirement1, &requirement2}); - auto command2 = cmd::RunOnce([] {}, {&requirement3}); - auto command3 = cmd::RunOnce([] {}, {&requirement3, &requirement4}); + auto command1 = RunOnce([] {}, {&requirement1, &requirement2}); + auto command2 = RunOnce([] {}, {&requirement3}); + auto command3 = RunOnce([] {}, {&requirement3, &requirement4}); - auto group = cmd::Sequence(std::move(command1), std::move(command2)); + auto group = Sequence(std::move(command1), std::move(command2)); scheduler.Schedule(group); scheduler.Schedule(command3); diff --git a/commandsv2/src/test/native/cpp/wpi/command/StartEndCommandTest.cpp b/commandsv2/src/test/native/cpp/wpi/command/StartEndCommandTest.cpp index 11d291e4b7..a60908f070 100644 --- a/commandsv2/src/test/native/cpp/wpi/command/StartEndCommandTest.cpp +++ b/commandsv2/src/test/native/cpp/wpi/command/StartEndCommandTest.cpp @@ -15,8 +15,7 @@ TEST_F(StartEndCommandTest, StartEndCommandSchedule) { int counter = 0; - auto command = - cmd::StartEnd([&counter] { counter++; }, [&counter] { counter++; }); + auto command = StartEnd([&counter] { counter++; }, [&counter] { counter++; }); scheduler.Schedule(command); scheduler.Run(); diff --git a/commandsv2/src/test/native/cpp/wpi/command/WaitCommandTest.cpp b/commandsv2/src/test/native/cpp/wpi/command/WaitCommandTest.cpp index ced6ba08ff..680bd54945 100644 --- a/commandsv2/src/test/native/cpp/wpi/command/WaitCommandTest.cpp +++ b/commandsv2/src/test/native/cpp/wpi/command/WaitCommandTest.cpp @@ -17,7 +17,7 @@ TEST_F(WaitCommandTest, WaitCommandSchedule) { CommandScheduler scheduler = GetScheduler(); - auto command = cmd::Wait(100_ms); + auto command = wpi::cmd::Wait(100_ms); scheduler.Schedule(command); scheduler.Run(); diff --git a/commandsv2/src/test/native/cpp/wpi/command/WaitUntilCommandTest.cpp b/commandsv2/src/test/native/cpp/wpi/command/WaitUntilCommandTest.cpp index 4f9a18a0ca..3e55423a06 100644 --- a/commandsv2/src/test/native/cpp/wpi/command/WaitUntilCommandTest.cpp +++ b/commandsv2/src/test/native/cpp/wpi/command/WaitUntilCommandTest.cpp @@ -15,7 +15,7 @@ TEST_F(WaitUntilCommandTest, WaitUntilCommandSchedule) { bool finished = false; - auto command = cmd::WaitUntil([&finished] { return finished; }); + auto command = WaitUntil([&finished] { return finished; }); scheduler.Schedule(command); scheduler.Run(); diff --git a/commandsv2/src/test/native/cpp/wpi/command/button/TriggerTest.cpp b/commandsv2/src/test/native/cpp/wpi/command/button/TriggerTest.cpp index 3cb74c224a..b1665debc0 100644 --- a/commandsv2/src/test/native/cpp/wpi/command/button/TriggerTest.cpp +++ b/commandsv2/src/test/native/cpp/wpi/command/button/TriggerTest.cpp @@ -109,7 +109,7 @@ TEST_F(TriggerTest, WhileTrueLambdaRun) { auto& scheduler = CommandScheduler::GetInstance(); int counter = 0; bool pressed = false; - CommandPtr command = cmd::Run([&counter] { counter++; }); + CommandPtr command = wpi::cmd::Run([&counter] { counter++; }); pressed = false; Trigger([&pressed] { return pressed; }).WhileTrue(std::move(command)); @@ -130,8 +130,8 @@ TEST_F(TriggerTest, WhenTrueOnce) { int endCounter = 0; bool pressed = false; - CommandPtr command = cmd::StartEnd([&startCounter] { startCounter++; }, - [&endCounter] { endCounter++; }); + CommandPtr command = StartEnd([&startCounter] { startCounter++; }, + [&endCounter] { endCounter++; }); pressed = false; Trigger([&pressed] { return pressed; }).WhileTrue(std::move(command)); @@ -154,8 +154,8 @@ TEST_F(TriggerTest, ToggleOnTrue) { bool pressed = false; int startCounter = 0; int endCounter = 0; - CommandPtr command = cmd::StartEnd([&startCounter] { startCounter++; }, - [&endCounter] { endCounter++; }); + CommandPtr command = StartEnd([&startCounter] { startCounter++; }, + [&endCounter] { endCounter++; }); Trigger([&pressed] { return pressed; }).ToggleOnTrue(std::move(command)); scheduler.Run(); diff --git a/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/cpp/RobotContainer.cpp b/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/cpp/RobotContainer.cpp index 4680a5ff15..6d39814f00 100644 --- a/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/cpp/RobotContainer.cpp +++ b/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/cpp/RobotContainer.cpp @@ -13,7 +13,7 @@ RobotContainer::RobotContainer() { ConfigureButtonBindings(); // Set up default drive command - m_drive.SetDefaultCommand(wpi::cmd::cmd::Run( + m_drive.SetDefaultCommand(wpi::cmd::Run( [this] { m_drive.ArcadeDrive(-m_driverController.GetLeftY(), -m_driverController.GetRightX()); @@ -42,5 +42,5 @@ void RobotContainer::ConfigureButtonBindings() { wpi::cmd::CommandPtr RobotContainer::GetAutonomousCommand() { // Runs the chosen command in autonomous - return wpi::cmd::cmd::None(); + return wpi::cmd::None(); } diff --git a/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/include/RobotContainer.hpp b/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/include/RobotContainer.hpp index 3225288342..98daed3f92 100644 --- a/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/include/RobotContainer.hpp +++ b/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/include/RobotContainer.hpp @@ -36,9 +36,9 @@ class RobotContainer { // RobotContainer-owned commands wpi::cmd::CommandPtr m_driveHalfVelocity = - wpi::cmd::cmd::RunOnce([this] { m_drive.SetMaxOutput(0.5); }, {}); + wpi::cmd::RunOnce([this] { m_drive.SetMaxOutput(0.5); }, {}); wpi::cmd::CommandPtr m_driveFullVelocity = - wpi::cmd::cmd::RunOnce([this] { m_drive.SetMaxOutput(1); }, {}); + wpi::cmd::RunOnce([this] { m_drive.SetMaxOutput(1); }, {}); void ConfigureButtonBindings(); }; diff --git a/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/cpp/RobotContainer.cpp b/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/cpp/RobotContainer.cpp index 8396437f5d..052f1a5cc5 100644 --- a/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/cpp/RobotContainer.cpp +++ b/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/cpp/RobotContainer.cpp @@ -24,7 +24,7 @@ RobotContainer::RobotContainer() { ConfigureButtonBindings(); // Set up default drive command - m_drive.SetDefaultCommand(wpi::cmd::cmd::Run( + m_drive.SetDefaultCommand(wpi::cmd::Run( [this] { m_drive.ArcadeDrive(-m_driverController.GetLeftY(), -m_driverController.GetRightX()); @@ -41,9 +41,8 @@ void RobotContainer::ConfigureButtonBindings() { m_driverController.WestFace().OnTrue(m_hatch.ReleaseHatchCommand()); // While holding Right Bumper, drive at half velocity m_driverController.RightBumper() - .OnTrue(wpi::cmd::cmd::RunOnce([this] { m_drive.SetMaxOutput(0.5); }, {})) - .OnFalse( - wpi::cmd::cmd::RunOnce([this] { m_drive.SetMaxOutput(1.0); }, {})); + .OnTrue(wpi::cmd::RunOnce([this] { m_drive.SetMaxOutput(0.5); }, {})) + .OnFalse(wpi::cmd::RunOnce([this] { m_drive.SetMaxOutput(1.0); }, {})); } wpi::cmd::Command* RobotContainer::GetAutonomousCommand() { diff --git a/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/cpp/commands/Autos.cpp b/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/cpp/commands/Autos.cpp index 3df1162017..00a65b86c2 100644 --- a/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/cpp/commands/Autos.cpp +++ b/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/cpp/commands/Autos.cpp @@ -33,7 +33,7 @@ wpi::cmd::CommandPtr autos::SimpleAuto(DriveSubsystem* drive) { wpi::cmd::CommandPtr autos::ComplexAuto(DriveSubsystem* drive, HatchSubsystem* hatch) { - return wpi::cmd::cmd::Sequence( + return wpi::cmd::Sequence( // Drive forward the specified distance wpi::cmd::FunctionalCommand( // Reset encoders on command start diff --git a/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/RapidReactCommandBot.cpp b/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/RapidReactCommandBot.cpp index 6a83770f10..371179f7fd 100644 --- a/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/RapidReactCommandBot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/RapidReactCommandBot.cpp @@ -31,7 +31,7 @@ void RapidReactCommandBot::ConfigureBindings() { // Fire the shooter with the South Face button m_driverController.SouthFace().OnTrue( - wpi::cmd::cmd::Parallel( + wpi::cmd::Parallel( m_shooter.ShootCommand(ShooterConstants::kShooterTarget), m_storage.RunCommand()) // Since we composed this inline we should give it a name diff --git a/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/subsystems/Shooter.cpp b/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/subsystems/Shooter.cpp index 69f4d7e7f9..0373c6b59d 100644 --- a/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/subsystems/Shooter.cpp +++ b/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/subsystems/Shooter.cpp @@ -21,7 +21,7 @@ Shooter::Shooter() { wpi::cmd::CommandPtr Shooter::ShootCommand( wpi::units::turns_per_second_t setpoint) { - return wpi::cmd::cmd::Parallel( + return wpi::cmd::Parallel( // Run the shooter flywheel at the desired setpoint using // feedforward and feedback Run([this, setpoint] { @@ -32,7 +32,7 @@ wpi::cmd::CommandPtr Shooter::ShootCommand( }), // Wait until the shooter has reached the setpoint, and then // run the feeder - wpi::cmd::cmd::WaitUntil([this] { + wpi::cmd::WaitUntil([this] { return m_shooterFeedback.AtSetpoint(); }).AndThen([this] { m_feederMotor.SetThrottle(1.0); })) .WithName("Shoot"); diff --git a/wpilibcExamples/src/main/cpp/examples/RomiReference/cpp/RobotContainer.cpp b/wpilibcExamples/src/main/cpp/examples/RomiReference/cpp/RobotContainer.cpp index 07f1cd0a47..793af12753 100644 --- a/wpilibcExamples/src/main/cpp/examples/RomiReference/cpp/RobotContainer.cpp +++ b/wpilibcExamples/src/main/cpp/examples/RomiReference/cpp/RobotContainer.cpp @@ -20,8 +20,8 @@ void RobotContainer::ConfigureButtonBindings() { [this] { return -m_controller.GetRawAxis(2); })); // Example of how to use the onboard IO - m_onboardButtonA.OnTrue(wpi::cmd::cmd::Print("Button A Pressed")) - .OnFalse(wpi::cmd::cmd::Print("Button A Released")); + m_onboardButtonA.OnTrue(wpi::cmd::Print("Button A Pressed")) + .OnFalse(wpi::cmd::Print("Button A Released")); // Setup SmartDashboard options. m_chooser.SetDefaultOption("Auto Routine Distance", &m_autoDistance); diff --git a/wpilibcExamples/src/main/cpp/examples/SysIdRoutine/cpp/subsystems/Drive.cpp b/wpilibcExamples/src/main/cpp/examples/SysIdRoutine/cpp/subsystems/Drive.cpp index af710fce2f..5c1d2c34e4 100644 --- a/wpilibcExamples/src/main/cpp/examples/SysIdRoutine/cpp/subsystems/Drive.cpp +++ b/wpilibcExamples/src/main/cpp/examples/SysIdRoutine/cpp/subsystems/Drive.cpp @@ -23,8 +23,8 @@ Drive::Drive() { wpi::cmd::CommandPtr Drive::ArcadeDriveCommand(std::function fwd, std::function rot) { - return wpi::cmd::cmd::Run( - [this, fwd, rot] { m_drive.ArcadeDrive(fwd(), rot()); }, {this}) + return wpi::cmd::Run([this, fwd, rot] { m_drive.ArcadeDrive(fwd(), rot()); }, + {this}) .WithName("Arcade Drive"); } diff --git a/wpilibcExamples/src/main/cpp/examples/SysIdRoutine/cpp/subsystems/Shooter.cpp b/wpilibcExamples/src/main/cpp/examples/SysIdRoutine/cpp/subsystems/Shooter.cpp index 512ef2be72..06548fe3d8 100644 --- a/wpilibcExamples/src/main/cpp/examples/SysIdRoutine/cpp/subsystems/Shooter.cpp +++ b/wpilibcExamples/src/main/cpp/examples/SysIdRoutine/cpp/subsystems/Shooter.cpp @@ -15,7 +15,7 @@ Shooter::Shooter() { wpi::cmd::CommandPtr Shooter::RunShooterCommand( std::function shooterVelocity) { - return wpi::cmd::cmd::Run( + return wpi::cmd::Run( [this, shooterVelocity] { m_shooterMotor.SetVoltage( wpi::units::volt_t{m_shooterFeedback.Calculate( diff --git a/wpilibcExamples/src/main/cpp/examples/XRPReference/cpp/RobotContainer.cpp b/wpilibcExamples/src/main/cpp/examples/XRPReference/cpp/RobotContainer.cpp index 5d4d20743b..bc68d85967 100644 --- a/wpilibcExamples/src/main/cpp/examples/XRPReference/cpp/RobotContainer.cpp +++ b/wpilibcExamples/src/main/cpp/examples/XRPReference/cpp/RobotContainer.cpp @@ -21,16 +21,16 @@ void RobotContainer::ConfigureButtonBindings() { [this] { return -m_controller.GetRawAxis(2); })); // Example of how to use the onboard IO - m_userButton.OnTrue(wpi::cmd::cmd::Print("USER Button Pressed")) - .OnFalse(wpi::cmd::cmd::Print("USER Button Released")); + m_userButton.OnTrue(wpi::cmd::Print("USER Button Pressed")) + .OnFalse(wpi::cmd::Print("USER Button Released")); wpi::cmd::JoystickButton(&m_controller, 1) - .OnTrue(wpi::cmd::cmd::RunOnce([this] { m_arm.SetAngle(45_deg); }, {})) - .OnFalse(wpi::cmd::cmd::RunOnce([this] { m_arm.SetAngle(0_deg); }, {})); + .OnTrue(wpi::cmd::RunOnce([this] { m_arm.SetAngle(45_deg); }, {})) + .OnFalse(wpi::cmd::RunOnce([this] { m_arm.SetAngle(0_deg); }, {})); wpi::cmd::JoystickButton(&m_controller, 2) - .OnTrue(wpi::cmd::cmd::RunOnce([this] { m_arm.SetAngle(90_deg); }, {})) - .OnFalse(wpi::cmd::cmd::RunOnce([this] { m_arm.SetAngle(0_deg); }, {})); + .OnTrue(wpi::cmd::RunOnce([this] { m_arm.SetAngle(90_deg); }, {})) + .OnFalse(wpi::cmd::RunOnce([this] { m_arm.SetAngle(0_deg); }, {})); // Setup SmartDashboard options. m_chooser.SetDefaultOption("Auto Routine Distance", &m_autoDistance); diff --git a/wpilibcExamples/src/main/cpp/snippets/SelectCommand/include/RobotContainer.hpp b/wpilibcExamples/src/main/cpp/snippets/SelectCommand/include/RobotContainer.hpp index e23769e994..417f164989 100644 --- a/wpilibcExamples/src/main/cpp/snippets/SelectCommand/include/RobotContainer.hpp +++ b/wpilibcExamples/src/main/cpp/snippets/SelectCommand/include/RobotContainer.hpp @@ -36,13 +36,12 @@ class RobotContainer { // takes a generic type, so the selector does not have to be an enum; it could // be any desired type (string, integer, boolean, double...) wpi::cmd::CommandPtr m_exampleSelectCommand = - wpi::cmd::cmd::Select( + wpi::cmd::Select( [this] { return m_chooser.GetSelected(); }, // Maps selector values to commands - std::pair{ONE, wpi::cmd::cmd::Print("Command one was selected!")}, - std::pair{TWO, wpi::cmd::cmd::Print("Command two was selected!")}, - std::pair{THREE, - wpi::cmd::cmd::Print("Command three was selected!")}); + std::pair{ONE, wpi::cmd::Print("Command one was selected!")}, + std::pair{TWO, wpi::cmd::Print("Command two was selected!")}, + std::pair{THREE, wpi::cmd::Print("Command three was selected!")}); void ConfigureButtonBindings(); }; diff --git a/wpilibcExamples/src/main/cpp/templates/commandv2/cpp/commands/Autos.cpp b/wpilibcExamples/src/main/cpp/templates/commandv2/cpp/commands/Autos.cpp index a3c32215c3..192d75ab74 100644 --- a/wpilibcExamples/src/main/cpp/templates/commandv2/cpp/commands/Autos.cpp +++ b/wpilibcExamples/src/main/cpp/templates/commandv2/cpp/commands/Autos.cpp @@ -8,6 +8,6 @@ #include "wpi/commands2/Commands.hpp" wpi::cmd::CommandPtr autos::ExampleAuto(ExampleSubsystem* subsystem) { - return wpi::cmd::cmd::Sequence(subsystem->ExampleMethodCommand(), - ExampleCommand(subsystem).ToPtr()); + return wpi::cmd::Sequence(subsystem->ExampleMethodCommand(), + ExampleCommand(subsystem).ToPtr()); } diff --git a/wpilibcExamples/src/main/cpp/templates/commandv2skeleton/cpp/RobotContainer.cpp b/wpilibcExamples/src/main/cpp/templates/commandv2skeleton/cpp/RobotContainer.cpp index f880768f3e..25edad49f2 100644 --- a/wpilibcExamples/src/main/cpp/templates/commandv2skeleton/cpp/RobotContainer.cpp +++ b/wpilibcExamples/src/main/cpp/templates/commandv2skeleton/cpp/RobotContainer.cpp @@ -13,5 +13,5 @@ RobotContainer::RobotContainer() { void RobotContainer::ConfigureBindings() {} wpi::cmd::CommandPtr RobotContainer::GetAutonomousCommand() { - return wpi::cmd::cmd::Print("No autonomous command configured"); + return wpi::cmd::Print("No autonomous command configured"); }