SCRIPT namespace replacements

This commit is contained in:
PJ Reiniger
2025-11-07 20:00:05 -05:00
committed by Peter Johnson
parent ae6c043632
commit 9aca8e0fd6
2622 changed files with 22275 additions and 22275 deletions

View File

@@ -7,7 +7,7 @@
#include "wpi/commands2/RunCommand.hpp"
#include "wpi/util/array.hpp"
using namespace frc2;
using namespace wpi::cmd;
// Class to verify the overload resolution of Command::AddRequirements. This
// does not derive from Command because AddRequirements is non-virtual,
@@ -15,7 +15,7 @@ using namespace frc2;
class MockAddRequirements {
public:
MOCK_METHOD(void, AddRequirements, (Requirements), ());
MOCK_METHOD(void, AddRequirements, ((wpi::SmallSet<Subsystem*, 4>)), ());
MOCK_METHOD(void, AddRequirements, ((wpi::util::SmallSet<Subsystem*, 4>)), ());
MOCK_METHOD(void, AddRequirements, (Subsystem*), ());
};
@@ -40,12 +40,12 @@ TEST(AddRequirementsTest, SpanOverloadResolution) {
}
TEST(AddRequirementsTest, SmallSetOverloadResolution) {
wpi::SmallSet<Subsystem*, 4> requirementsSet;
wpi::util::SmallSet<Subsystem*, 4> requirementsSet;
MockAddRequirements overloadResolver;
EXPECT_CALL(overloadResolver,
AddRequirements(testing::An<wpi::SmallSet<Subsystem*, 4>>()));
AddRequirements(testing::An<wpi::util::SmallSet<Subsystem*, 4>>()));
overloadResolver.AddRequirements(requirementsSet);
}
@@ -84,7 +84,7 @@ TEST(AddRequirementsTest, SpanSemantics) {
TestSubsystem requirement1;
TestSubsystem requirement2;
wpi::array<Subsystem* const, 2> requirementsArray(&requirement1,
wpi::util::array<Subsystem* const, 2> requirementsArray(&requirement1,
&requirement2);
RunCommand command([] {});
@@ -97,7 +97,7 @@ TEST(AddRequirementsTest, SpanSemantics) {
TEST(AddRequirementsTest, SpanDuplicatesSemantics) {
TestSubsystem requirement;
wpi::array<Subsystem* const, 2> requirementsArray(&requirement, &requirement);
wpi::util::array<Subsystem* const, 2> requirementsArray(&requirement, &requirement);
RunCommand command([] {});
command.AddRequirements(std::span{requirementsArray});
@@ -109,7 +109,7 @@ TEST(AddRequirementsTest, SmallSetSemantics) {
TestSubsystem requirement1;
TestSubsystem requirement2;
wpi::SmallSet<Subsystem*, 4> requirementsSet;
wpi::util::SmallSet<Subsystem*, 4> requirementsSet;
requirementsSet.insert(&requirement1);
requirementsSet.insert(&requirement2);

View File

@@ -13,13 +13,13 @@
#include "wpi/commands2/WaitUntilCommand.hpp"
#include "wpi/simulation/SimHooks.hpp"
using namespace frc2;
using namespace wpi::cmd;
class CommandDecoratorTest : public CommandTestBase {};
TEST_F(CommandDecoratorTest, WithTimeout) {
CommandScheduler scheduler = GetScheduler();
frc::sim::PauseTiming();
wpi::sim::PauseTiming();
auto command = cmd::Idle().WithTimeout(100_ms);
@@ -28,13 +28,13 @@ TEST_F(CommandDecoratorTest, WithTimeout) {
EXPECT_TRUE(scheduler.IsScheduled(command));
frc::sim::StepTiming(150_ms);
wpi::sim::StepTiming(150_ms);
scheduler.Run();
EXPECT_FALSE(scheduler.IsScheduled(command));
frc::sim::ResumeTiming();
wpi::sim::ResumeTiming();
}
TEST_F(CommandDecoratorTest, Until) {

View File

@@ -10,7 +10,7 @@
#include "wpi/commands2/Commands.hpp"
#include "wpi/system/Errors.hpp"
using namespace frc2;
using namespace wpi::cmd;
class CommandPtrTest : public CommandTestBase {};
TEST_F(CommandPtrTest, MovedFrom) {
@@ -27,16 +27,16 @@ TEST_F(CommandPtrTest, MovedFrom) {
EXPECT_EQ(1, counter);
EXPECT_NO_FATAL_FAILURE(scheduler.Cancel(movedTo));
EXPECT_THROW(scheduler.Schedule(movedFrom), frc::RuntimeError);
EXPECT_THROW(scheduler.Schedule(movedFrom), wpi::RuntimeError);
// NOLINTNEXTLINE(clang-analyzer-cplusplus.Move)
EXPECT_THROW(movedFrom.IsScheduled(), frc::RuntimeError);
EXPECT_THROW(movedFrom.IsScheduled(), wpi::RuntimeError);
EXPECT_THROW(static_cast<void>(std::move(movedFrom).Repeatedly()),
frc::RuntimeError);
wpi::RuntimeError);
EXPECT_EQ(1, counter);
}
TEST_F(CommandPtrTest, NullInitialization) {
EXPECT_THROW(auto cmd = CommandPtr{std::unique_ptr<Command>{}},
frc::RuntimeError);
wpi::RuntimeError);
}

View File

@@ -9,7 +9,7 @@
#include "wpi/commands2/FunctionalCommand.hpp"
#include "wpi/system/Errors.hpp"
using namespace frc2;
using namespace wpi::cmd;
class CommandRequirementsTest : public CommandTestBase {};
TEST_F(CommandRequirementsTest, RequirementInterrupt) {
@@ -81,5 +81,5 @@ TEST_F(CommandRequirementsTest, DefaultCommandRequirementError) {
MockCommand command1;
ASSERT_THROW(requirement1.SetDefaultCommand(std::move(command1)),
frc::RuntimeError);
wpi::RuntimeError);
}

View File

@@ -9,7 +9,7 @@
#include "wpi/nt/NetworkTableInstance.hpp"
#include "wpi/smartdashboard/SmartDashboard.hpp"
using namespace frc2;
using namespace wpi::cmd;
class CommandScheduleTest : public CommandTestBase {};
TEST_F(CommandScheduleTest, InstantSchedule) {
@@ -100,8 +100,8 @@ TEST_F(CommandScheduleTest, SchedulerCancel) {
TEST_F(CommandScheduleTest, CommandKnowsWhenItEnded) {
CommandScheduler scheduler = GetScheduler();
frc2::FunctionalCommand* commandPtr = nullptr;
auto command = frc2::FunctionalCommand(
wpi::cmd::FunctionalCommand* commandPtr = nullptr;
auto command = wpi::cmd::FunctionalCommand(
[] {}, [] {},
[&](auto isForced) {
EXPECT_FALSE(scheduler.IsScheduled(commandPtr))
@@ -120,10 +120,10 @@ TEST_F(CommandScheduleTest, CommandKnowsWhenItEnded) {
TEST_F(CommandScheduleTest, ScheduleCommandInCommand) {
CommandScheduler scheduler = GetScheduler();
int counter = 0;
frc2::InstantCommand commandToGetScheduled{[&counter] { counter++; }};
wpi::cmd::InstantCommand commandToGetScheduled{[&counter] { counter++; }};
auto command =
frc2::RunCommand([&counter, &scheduler, &commandToGetScheduled] {
wpi::cmd::RunCommand([&counter, &scheduler, &commandToGetScheduled] {
scheduler.Schedule(&commandToGetScheduled);
EXPECT_EQ(counter, 1)
<< "Scheduled command's init was not run immediately "
@@ -151,21 +151,21 @@ TEST_F(CommandScheduleTest, NotScheduledCancel) {
TEST_F(CommandScheduleTest, SmartDashboardCancel) {
CommandScheduler scheduler = GetScheduler();
frc::SmartDashboard::PutData("Scheduler", &scheduler);
frc::SmartDashboard::UpdateValues();
wpi::SmartDashboard::PutData("Scheduler", &scheduler);
wpi::SmartDashboard::UpdateValues();
MockCommand command;
scheduler.Schedule(&command);
scheduler.Run();
frc::SmartDashboard::UpdateValues();
wpi::SmartDashboard::UpdateValues();
EXPECT_TRUE(scheduler.IsScheduled(&command));
uintptr_t ptrTmp = reinterpret_cast<uintptr_t>(&command);
nt::NetworkTableInstance::GetDefault()
wpi::nt::NetworkTableInstance::GetDefault()
.GetEntry("/SmartDashboard/Scheduler/Cancel")
.SetIntegerArray(
std::span<const int64_t>{{static_cast<int64_t>(ptrTmp)}});
frc::SmartDashboard::UpdateValues();
wpi::SmartDashboard::UpdateValues();
scheduler.Run();
EXPECT_FALSE(scheduler.IsScheduled(&command));
}

View File

@@ -8,37 +8,37 @@
#include "wpi/nt/NetworkTableInstance.hpp"
#include "wpi/smartdashboard/SmartDashboard.hpp"
using namespace frc2;
using namespace wpi::cmd;
class CommandSendableButtonTest : public CommandTestBase {
protected:
int m_schedule;
int m_cancel;
nt::BooleanPublisher m_publish;
wpi::nt::BooleanPublisher m_publish;
std::optional<CommandPtr> m_command;
void SetUp() override {
m_schedule = 0;
m_cancel = 0;
m_command = cmd::StartEnd([this] { m_schedule++; }, [this] { m_cancel++; });
m_publish = nt::NetworkTableInstance::GetDefault()
m_publish = wpi::nt::NetworkTableInstance::GetDefault()
.GetBooleanTopic("/SmartDashboard/command/running")
.Publish();
frc::SmartDashboard::PutData("command", m_command->get());
frc::SmartDashboard::UpdateValues();
wpi::SmartDashboard::PutData("command", m_command->get());
wpi::SmartDashboard::UpdateValues();
}
};
TEST_F(CommandSendableButtonTest, trueAndNotScheduledSchedules) {
// Not scheduled and true -> scheduled
GetScheduler().Run();
frc::SmartDashboard::UpdateValues();
wpi::SmartDashboard::UpdateValues();
EXPECT_FALSE(m_command->IsScheduled());
EXPECT_EQ(0, m_schedule);
EXPECT_EQ(0, m_cancel);
m_publish.Set(true);
frc::SmartDashboard::UpdateValues();
wpi::SmartDashboard::UpdateValues();
GetScheduler().Run();
EXPECT_TRUE(m_command->IsScheduled());
EXPECT_EQ(1, m_schedule);
@@ -47,15 +47,15 @@ TEST_F(CommandSendableButtonTest, trueAndNotScheduledSchedules) {
TEST_F(CommandSendableButtonTest, trueAndScheduledNoOp) {
// Scheduled and true -> no-op
frc2::CommandScheduler::GetInstance().Schedule(m_command.value());
wpi::cmd::CommandScheduler::GetInstance().Schedule(m_command.value());
GetScheduler().Run();
frc::SmartDashboard::UpdateValues();
wpi::SmartDashboard::UpdateValues();
EXPECT_TRUE(m_command->IsScheduled());
EXPECT_EQ(1, m_schedule);
EXPECT_EQ(0, m_cancel);
m_publish.Set(true);
frc::SmartDashboard::UpdateValues();
wpi::SmartDashboard::UpdateValues();
GetScheduler().Run();
EXPECT_TRUE(m_command->IsScheduled());
EXPECT_EQ(1, m_schedule);
@@ -65,13 +65,13 @@ TEST_F(CommandSendableButtonTest, trueAndScheduledNoOp) {
TEST_F(CommandSendableButtonTest, falseAndNotScheduledNoOp) {
// Not scheduled and false -> no-op
GetScheduler().Run();
frc::SmartDashboard::UpdateValues();
wpi::SmartDashboard::UpdateValues();
EXPECT_FALSE(m_command->IsScheduled());
EXPECT_EQ(0, m_schedule);
EXPECT_EQ(0, m_cancel);
m_publish.Set(false);
frc::SmartDashboard::UpdateValues();
wpi::SmartDashboard::UpdateValues();
GetScheduler().Run();
EXPECT_FALSE(m_command->IsScheduled());
EXPECT_EQ(0, m_schedule);
@@ -80,15 +80,15 @@ TEST_F(CommandSendableButtonTest, falseAndNotScheduledNoOp) {
TEST_F(CommandSendableButtonTest, falseAndScheduledCancel) {
// Scheduled and false -> cancel
frc2::CommandScheduler::GetInstance().Schedule(m_command.value());
wpi::cmd::CommandScheduler::GetInstance().Schedule(m_command.value());
GetScheduler().Run();
frc::SmartDashboard::UpdateValues();
wpi::SmartDashboard::UpdateValues();
EXPECT_TRUE(m_command->IsScheduled());
EXPECT_EQ(1, m_schedule);
EXPECT_EQ(0, m_cancel);
m_publish.Set(false);
frc::SmartDashboard::UpdateValues();
wpi::SmartDashboard::UpdateValues();
GetScheduler().Run();
EXPECT_FALSE(m_command->IsScheduled());
EXPECT_EQ(1, m_schedule);

View File

@@ -4,7 +4,7 @@
#include "CommandTestBase.hpp"
using namespace frc2;
using namespace wpi::cmd;
CommandTestBase::CommandTestBase() {
auto& scheduler = CommandScheduler::GetInstance();
@@ -26,7 +26,7 @@ CommandScheduler CommandTestBase::GetScheduler() {
}
void CommandTestBase::SetDSEnabled(bool enabled) {
frc::sim::DriverStationSim::SetDsAttached(true);
frc::sim::DriverStationSim::SetEnabled(enabled);
frc::sim::DriverStationSim::NotifyNewData();
wpi::sim::DriverStationSim::SetDsAttached(true);
wpi::sim::DriverStationSim::SetEnabled(enabled);
wpi::sim::DriverStationSim::NotifyNewData();
}

View File

@@ -16,7 +16,7 @@
#include "wpi/commands2/SubsystemBase.hpp"
#include "wpi/simulation/DriverStationSim.hpp"
namespace frc2 {
namespace wpi::cmd {
class TestSubsystem : public SubsystemBase {
public:
@@ -33,7 +33,7 @@ class TestSubsystem : public SubsystemBase {
*/
class MockCommand : public CommandHelper<Command, MockCommand> {
public:
MOCK_CONST_METHOD0(GetRequirements, wpi::SmallSet<Subsystem*, 4>());
MOCK_CONST_METHOD0(GetRequirements, wpi::util::SmallSet<Subsystem*, 4>());
MOCK_METHOD0(IsFinished, bool());
MOCK_CONST_METHOD0(RunsWhenDisabled, bool());
MOCK_METHOD0(Initialize, void());
@@ -83,7 +83,7 @@ class MockCommand : public CommandHelper<Command, MockCommand> {
}
private:
wpi::SmallSet<Subsystem*, 4> m_requirements;
wpi::util::SmallSet<Subsystem*, 4> m_requirements;
};
class CommandTestBase : public ::testing::Test {
@@ -120,10 +120,10 @@ class CommandTestBaseWithParam : public ::testing::TestWithParam<T> {
CommandScheduler GetScheduler() { return CommandScheduler(); }
void SetDSEnabled(bool enabled) {
frc::sim::DriverStationSim::SetDsAttached(true);
frc::sim::DriverStationSim::SetEnabled(enabled);
frc::sim::DriverStationSim::NotifyNewData();
wpi::sim::DriverStationSim::SetDsAttached(true);
wpi::sim::DriverStationSim::SetEnabled(enabled);
wpi::sim::DriverStationSim::NotifyNewData();
}
};
} // namespace frc2
} // namespace wpi::cmd

View File

@@ -13,7 +13,7 @@
#include "make_vector.hpp"
#include "wpi/commands2/Commands.hpp"
namespace frc2 {
namespace wpi::cmd {
inline namespace single {
template <typename T>
@@ -182,4 +182,4 @@ REGISTER_TYPED_TEST_SUITE_P(MultiCompositionInterruptibilityTest, AllCancelSelf,
INSTANTIATE_TYPED_TEST_SUITE_P(Suite, MultiCompositionRunsWhenDisabledTest, \
CompositionType)
} // namespace multi
} // namespace frc2
} // namespace wpi::cmd

View File

@@ -10,7 +10,7 @@
#include "wpi/commands2/ConditionalCommand.hpp"
#include "wpi/commands2/InstantCommand.hpp"
using namespace frc2;
using namespace wpi::cmd;
class ConditionalCommandTest : public CommandTestBase {};
TEST_F(ConditionalCommandTest, ConditionalCommandSchedule) {

View File

@@ -8,7 +8,7 @@
#include "wpi/commands2/Commands.hpp"
#include "wpi/commands2/RunCommand.hpp"
using namespace frc2;
using namespace wpi::cmd;
class DefaultCommandTest : public CommandTestBase {};
TEST_F(DefaultCommandTest, DefaultCommandSchedule) {

View File

@@ -7,7 +7,7 @@
#include "wpi/commands2/DeferredCommand.hpp"
#include "wpi/commands2/FunctionalCommand.hpp"
using namespace frc2;
using namespace wpi::cmd;
class DeferredFunctionsTest : public CommandTestBaseWithParam<bool> {};

View File

@@ -5,7 +5,7 @@
#include "CommandTestBase.hpp"
#include "wpi/commands2/FunctionalCommand.hpp"
using namespace frc2;
using namespace wpi::cmd;
class FunctionalCommandTest : public CommandTestBase {};
TEST_F(FunctionalCommandTest, FunctionalCommandSchedule) {

View File

@@ -6,7 +6,7 @@
#include "wpi/commands2/Commands.hpp"
#include "wpi/commands2/InstantCommand.hpp"
using namespace frc2;
using namespace wpi::cmd;
class InstantCommandTest : public CommandTestBase {};
TEST_F(InstantCommandTest, InstantCommandSchedule) {

View File

@@ -6,7 +6,7 @@
#include "wpi/commands2/NotifierCommand.hpp"
#include "wpi/simulation/SimHooks.hpp"
using namespace frc2;
using namespace wpi::cmd;
using namespace std::chrono_literals;
class NotifierCommandTest : public CommandTestBase {};
@@ -14,18 +14,18 @@ class NotifierCommandTest : public CommandTestBase {};
TEST_F(NotifierCommandTest, NotifierCommandSchedule) {
CommandScheduler scheduler = GetScheduler();
frc::sim::PauseTiming();
wpi::sim::PauseTiming();
int counter = 0;
NotifierCommand command([&] { counter++; }, 10_ms, {});
scheduler.Schedule(&command);
for (int i = 0; i < 5; ++i) {
frc::sim::StepTiming(5_ms);
wpi::sim::StepTiming(5_ms);
}
scheduler.Cancel(&command);
frc::sim::ResumeTiming();
wpi::sim::ResumeTiming();
EXPECT_EQ(counter, 2);
}

View File

@@ -13,12 +13,12 @@
#include "wpi/driverstation/Joystick.hpp"
#include "wpi/simulation/JoystickSim.hpp"
using namespace frc2;
using namespace wpi::cmd;
class POVButtonTest : public CommandTestBase {};
TEST_F(POVButtonTest, SetPOV) {
frc::sim::JoystickSim joysim(1);
joysim.SetPOV(frc::DriverStation::kUp);
wpi::sim::JoystickSim joysim(1);
joysim.SetPOV(wpi::DriverStation::kUp);
joysim.NotifyNewData();
auto& scheduler = CommandScheduler::GetInstance();
@@ -26,12 +26,12 @@ TEST_F(POVButtonTest, SetPOV) {
WaitUntilCommand command([&finished] { return finished; });
frc::Joystick joy(1);
POVButton(&joy, frc::DriverStation::kRight).OnTrue(&command);
wpi::Joystick joy(1);
POVButton(&joy, wpi::DriverStation::kRight).OnTrue(&command);
scheduler.Run();
EXPECT_FALSE(scheduler.IsScheduled(&command));
joysim.SetPOV(frc::DriverStation::kRight);
joysim.SetPOV(wpi::DriverStation::kRight);
joysim.NotifyNewData();
scheduler.Run();

View File

@@ -11,7 +11,7 @@
#include "wpi/commands2/ParallelCommandGroup.hpp"
#include "wpi/commands2/WaitUntilCommand.hpp"
using namespace frc2;
using namespace wpi::cmd;
class ParallelCommandGroupTest : public CommandTestBase {};
TEST_F(ParallelCommandGroupTest, ParallelGroupSchedule) {

View File

@@ -12,7 +12,7 @@
#include "wpi/commands2/ParallelDeadlineGroup.hpp"
#include "wpi/commands2/WaitUntilCommand.hpp"
using namespace frc2;
using namespace wpi::cmd;
class ParallelDeadlineGroupTest : public CommandTestBase {};
TEST_F(ParallelDeadlineGroupTest, DeadlineGroupSchedule) {

View File

@@ -12,7 +12,7 @@
#include "wpi/commands2/SequentialCommandGroup.hpp"
#include "wpi/commands2/WaitUntilCommand.hpp"
using namespace frc2;
using namespace wpi::cmd;
class ParallelRaceGroupTest : public CommandTestBase {};
TEST_F(ParallelRaceGroupTest, ParallelRaceSchedule) {

View File

@@ -8,7 +8,7 @@
#include "wpi/commands2/Commands.hpp"
#include "wpi/commands2/PrintCommand.hpp"
using namespace frc2;
using namespace wpi::cmd;
class PrintCommandTest : public CommandTestBase {};
TEST_F(PrintCommandTest, PrintCommandSchedule) {

View File

@@ -11,7 +11,7 @@
#include "wpi/commands2/ProxyCommand.hpp"
#include "wpi/commands2/WaitUntilCommand.hpp"
using namespace frc2;
using namespace wpi::cmd;
class ProxyCommandTest : public CommandTestBase {};
TEST_F(ProxyCommandTest, NonOwningCommandSchedule) {

View File

@@ -7,7 +7,7 @@
#include "wpi/commands2/FunctionalCommand.hpp"
#include "wpi/commands2/RepeatCommand.hpp"
using namespace frc2;
using namespace wpi::cmd;
class RepeatCommandTest : public CommandTestBase {};
TEST_F(RepeatCommandTest, CallsMethodsCorrectly) {

View File

@@ -10,7 +10,7 @@
#include "wpi/commands2/SelectCommand.hpp"
#include "wpi/commands2/SequentialCommandGroup.hpp"
using namespace frc2;
using namespace wpi::cmd;
class RobotDisabledCommandTest : public CommandTestBase {};
TEST_F(RobotDisabledCommandTest, RobotDisabledCommandCancel) {

View File

@@ -6,7 +6,7 @@
#include "wpi/commands2/Commands.hpp"
#include "wpi/commands2/RunCommand.hpp"
using namespace frc2;
using namespace wpi::cmd;
class RunCommandTest : public CommandTestBase {};
TEST_F(RunCommandTest, RunCommandSchedule) {

View File

@@ -9,7 +9,7 @@
#include "wpi/commands2/ScheduleCommand.hpp"
#include "wpi/commands2/SequentialCommandGroup.hpp"
using namespace frc2;
using namespace wpi::cmd;
class ScheduleCommandTest : public CommandTestBase {};
TEST_F(ScheduleCommandTest, ScheduleCommandSchedule) {

View File

@@ -10,7 +10,7 @@
#include "wpi/commands2/RunCommand.hpp"
#include "wpi/commands2/StartEndCommand.hpp"
using namespace frc2;
using namespace wpi::cmd;
class SchedulerTest : public CommandTestBase {};
TEST_F(SchedulerTest, SchedulerLambdaTestNoInterrupt) {
@@ -176,9 +176,9 @@ TEST_F(SchedulerTest, ScheduleScheduledNoOp) {
}
class TrackDestroyCommand
: public frc2::CommandHelper<Command, TrackDestroyCommand> {
: public wpi::cmd::CommandHelper<Command, TrackDestroyCommand> {
public:
explicit TrackDestroyCommand(wpi::unique_function<void()> deleteFunc)
explicit TrackDestroyCommand(wpi::util::unique_function<void()> deleteFunc)
: m_deleteFunc{std::move(deleteFunc)} {}
TrackDestroyCommand(TrackDestroyCommand&& other)
: m_deleteFunc{std::exchange(other.m_deleteFunc, [] {})} {}
@@ -189,7 +189,7 @@ class TrackDestroyCommand
~TrackDestroyCommand() override { m_deleteFunc(); }
private:
wpi::unique_function<void()> m_deleteFunc;
wpi::util::unique_function<void()> m_deleteFunc;
};
TEST_F(SchedulerTest, ScheduleCommandPtr) {
@@ -203,7 +203,7 @@ TEST_F(SchedulerTest, ScheduleCommandPtr) {
auto commandPtr =
TrackDestroyCommand([&destructionCounter] { destructionCounter++; })
.AlongWith(
frc2::InstantCommand([&runCounter] { runCounter++; }).ToPtr())
wpi::cmd::InstantCommand([&runCounter] { runCounter++; }).ToPtr())
.Until([&finish] { return finish; });
EXPECT_EQ(destructionCounter, 0) << "Composition should not delete command";

View File

@@ -13,7 +13,7 @@
#include "wpi/commands2/FunctionalCommand.hpp"
#include "wpi/commands2/RunCommand.hpp"
using namespace frc2;
using namespace wpi::cmd;
class SchedulingRecursionTest
: public CommandTestBaseWithParam<Command::InterruptionBehavior> {};
@@ -343,15 +343,15 @@ TEST_F(SchedulingRecursionTest, CancelDefaultCommandFromEnd) {
TEST_F(SchedulingRecursionTest, CancelNextCommandFromCommand) {
CommandScheduler scheduler = GetScheduler();
frc2::RunCommand* command1Ptr = nullptr;
frc2::RunCommand* command2Ptr = nullptr;
wpi::cmd::RunCommand* command1Ptr = nullptr;
wpi::cmd::RunCommand* command2Ptr = nullptr;
int counter = 0;
auto command1 = frc2::RunCommand([&counter, &command2Ptr, &scheduler] {
auto command1 = wpi::cmd::RunCommand([&counter, &command2Ptr, &scheduler] {
scheduler.Cancel(command2Ptr);
counter++;
});
auto command2 = frc2::RunCommand([&counter, &command1Ptr, &scheduler] {
auto command2 = wpi::cmd::RunCommand([&counter, &command1Ptr, &scheduler] {
scheduler.Cancel(command1Ptr);
counter++;
});

View File

@@ -11,7 +11,7 @@
#include "wpi/commands2/InstantCommand.hpp"
#include "wpi/commands2/SelectCommand.hpp"
using namespace frc2;
using namespace wpi::cmd;
class SelectCommandTest : public CommandTestBase {};
TEST_F(SelectCommandTest, SelectCommand) {

View File

@@ -11,7 +11,7 @@
#include "wpi/commands2/SequentialCommandGroup.hpp"
#include "wpi/commands2/WaitUntilCommand.hpp"
using namespace frc2;
using namespace wpi::cmd;
class SequentialCommandGroupTest : public CommandTestBase {};
TEST_F(SequentialCommandGroupTest, SequentialGroupSchedule) {

View File

@@ -6,7 +6,7 @@
#include "wpi/commands2/Commands.hpp"
#include "wpi/commands2/StartEndCommand.hpp"
using namespace frc2;
using namespace wpi::cmd;
class StartEndCommandTest : public CommandTestBase {};
TEST_F(StartEndCommandTest, StartEndCommandSchedule) {

View File

@@ -8,11 +8,11 @@
#include "wpi/commands2/WaitUntilCommand.hpp"
#include "wpi/simulation/SimHooks.hpp"
using namespace frc2;
using namespace wpi::cmd;
class WaitCommandTest : public CommandTestBase {};
TEST_F(WaitCommandTest, WaitCommandSchedule) {
frc::sim::PauseTiming();
wpi::sim::PauseTiming();
CommandScheduler scheduler = GetScheduler();
@@ -21,9 +21,9 @@ TEST_F(WaitCommandTest, WaitCommandSchedule) {
scheduler.Schedule(command);
scheduler.Run();
EXPECT_TRUE(scheduler.IsScheduled(command));
frc::sim::StepTiming(110_ms);
wpi::sim::StepTiming(110_ms);
scheduler.Run();
EXPECT_FALSE(scheduler.IsScheduled(command));
frc::sim::ResumeTiming();
wpi::sim::ResumeTiming();
}

View File

@@ -6,7 +6,7 @@
#include "wpi/commands2/Commands.hpp"
#include "wpi/commands2/WaitUntilCommand.hpp"
using namespace frc2;
using namespace wpi::cmd;
class WaitUntilCommandTest : public CommandTestBase {};
TEST_F(WaitUntilCommandTest, WaitUntilCommandSchedule) {

View File

@@ -11,18 +11,18 @@
#include "wpi/commands2/button/NetworkButton.hpp"
#include "wpi/nt/NetworkTableInstance.hpp"
using namespace frc2;
using namespace wpi::cmd;
class NetworkButtonTest : public CommandTestBase {
public:
NetworkButtonTest() {
inst = nt::NetworkTableInstance::Create();
inst = wpi::nt::NetworkTableInstance::Create();
inst.StartLocal();
}
~NetworkButtonTest() override { nt::NetworkTableInstance::Destroy(inst); }
~NetworkButtonTest() override { wpi::nt::NetworkTableInstance::Destroy(inst); }
nt::NetworkTableInstance inst;
wpi::nt::NetworkTableInstance inst;
};
TEST_F(NetworkButtonTest, SetNetworkButton) {

View File

@@ -8,8 +8,8 @@
#include "wpi/driverstation/DriverStation.hpp"
#include "wpi/simulation/DriverStationSim.hpp"
using namespace frc2;
using namespace frc::sim;
using namespace wpi::cmd;
using namespace wpi::sim;
class RobotModeTriggersTest : public CommandTestBase {};
TEST(RobotModeTriggersTest, Autonomous) {

View File

@@ -15,7 +15,7 @@
#include "wpi/commands2/button/Trigger.hpp"
#include "wpi/simulation/SimHooks.hpp"
using namespace frc2;
using namespace wpi::cmd;
class TriggerTest : public CommandTestBase {};
TEST_F(TriggerTest, OnTrue) {
@@ -242,7 +242,7 @@ TEST_F(TriggerTest, Debounce) {
scheduler.Run();
EXPECT_FALSE(scheduler.IsScheduled(&command));
frc::sim::StepTiming(300_ms);
wpi::sim::StepTiming(300_ms);
scheduler.Run();
EXPECT_TRUE(scheduler.IsScheduled(&command));

View File

@@ -8,7 +8,7 @@
#include <utility>
#include <vector>
namespace frc2 {
namespace wpi::cmd {
template <typename T = void, typename... Args,
typename CommonType = std::conditional_t<
@@ -31,4 +31,4 @@ std::vector<CommonType> make_vector(Args&&... args) {
}
}
} // namespace frc2
} // namespace wpi::cmd

View File

@@ -14,7 +14,7 @@
#include "wpi/units/math.hpp"
#define EXPECT_NEAR_UNITS(val1, val2, eps) \
EXPECT_LE(units::math::abs(val1 - val2), eps)
EXPECT_LE(wpi::units::math::abs(val1 - val2), eps)
enum StateTest {
Invalid,
@@ -30,79 +30,79 @@ enum StateTest {
class SysIdRoutineTest : public ::testing::Test {
protected:
std::vector<StateTest> currentStateList{};
std::vector<units::volt_t> sentVoltages{};
frc2::Subsystem m_subsystem{};
frc2::sysid::SysIdRoutine m_sysidRoutine{
frc2::sysid::Config{
std::vector<wpi::units::volt_t> sentVoltages{};
wpi::cmd::Subsystem m_subsystem{};
wpi::cmd::sysid::SysIdRoutine m_sysidRoutine{
wpi::cmd::sysid::Config{
std::nullopt, std::nullopt, std::nullopt,
[this](frc::sysid::State state) {
[this](wpi::sysid::State state) {
switch (state) {
case frc::sysid::State::kQuasistaticForward:
case wpi::sysid::State::kQuasistaticForward:
currentStateList.emplace_back(StateTest::InRecordStateQf);
break;
case frc::sysid::State::kQuasistaticReverse:
case wpi::sysid::State::kQuasistaticReverse:
currentStateList.emplace_back(StateTest::InRecordStateQr);
break;
case frc::sysid::State::kDynamicForward:
case wpi::sysid::State::kDynamicForward:
currentStateList.emplace_back(StateTest::InRecordStateDf);
break;
case frc::sysid::State::kDynamicReverse:
case wpi::sysid::State::kDynamicReverse:
currentStateList.emplace_back(StateTest::InRecordStateDr);
break;
case frc::sysid::State::kNone:
case wpi::sysid::State::kNone:
currentStateList.emplace_back(StateTest::DoneWithRecordState);
break;
}
}},
frc2::sysid::Mechanism{
[this](units::volt_t driveVoltage) {
wpi::cmd::sysid::Mechanism{
[this](wpi::units::volt_t driveVoltage) {
sentVoltages.emplace_back(driveVoltage);
currentStateList.emplace_back(StateTest::InDrive);
},
[this](frc::sysid::SysIdRoutineLog* log) {
[this](wpi::sysid::SysIdRoutineLog* log) {
currentStateList.emplace_back(StateTest::InLog);
log->Motor("Mock Motor").position(0_m).velocity(0_mps).voltage(0_V);
},
&m_subsystem}};
frc2::CommandPtr m_quasistaticForward{
m_sysidRoutine.Quasistatic(frc2::sysid::Direction::kForward)};
frc2::CommandPtr m_quasistaticReverse{
m_sysidRoutine.Quasistatic(frc2::sysid::Direction::kReverse)};
frc2::CommandPtr m_dynamicForward{
m_sysidRoutine.Dynamic(frc2::sysid::Direction::kForward)};
frc2::CommandPtr m_dynamicReverse{
m_sysidRoutine.Dynamic(frc2::sysid::Direction::kReverse)};
wpi::cmd::CommandPtr m_quasistaticForward{
m_sysidRoutine.Quasistatic(wpi::cmd::sysid::Direction::kForward)};
wpi::cmd::CommandPtr m_quasistaticReverse{
m_sysidRoutine.Quasistatic(wpi::cmd::sysid::Direction::kReverse)};
wpi::cmd::CommandPtr m_dynamicForward{
m_sysidRoutine.Dynamic(wpi::cmd::sysid::Direction::kForward)};
wpi::cmd::CommandPtr m_dynamicReverse{
m_sysidRoutine.Dynamic(wpi::cmd::sysid::Direction::kReverse)};
frc2::sysid::SysIdRoutine m_emptySysidRoutine{
frc2::sysid::Config{std::nullopt, std::nullopt, std::nullopt, nullptr},
frc2::sysid::Mechanism{[](units::volt_t driveVoltage) {}, nullptr,
wpi::cmd::sysid::SysIdRoutine m_emptySysidRoutine{
wpi::cmd::sysid::Config{std::nullopt, std::nullopt, std::nullopt, nullptr},
wpi::cmd::sysid::Mechanism{[](wpi::units::volt_t driveVoltage) {}, nullptr,
&m_subsystem}};
frc2::CommandPtr m_emptyRoutineForward{
m_emptySysidRoutine.Quasistatic(frc2::sysid::Direction::kForward)};
wpi::cmd::CommandPtr m_emptyRoutineForward{
m_emptySysidRoutine.Quasistatic(wpi::cmd::sysid::Direction::kForward)};
void RunCommand(frc2::CommandPtr command) {
void RunCommand(wpi::cmd::CommandPtr command) {
command.get()->Initialize();
command.get()->Execute();
frc::sim::StepTiming(1_s);
wpi::sim::StepTiming(1_s);
command.get()->Execute();
command.get()->End(true);
}
void SetUp() override {
frc::sim::PauseTiming();
frc2::CommandPtr m_quasistaticForward{
m_sysidRoutine.Quasistatic(frc2::sysid::Direction::kForward)};
frc2::CommandPtr m_quasistaticReverse{
m_sysidRoutine.Quasistatic(frc2::sysid::Direction::kReverse)};
frc2::CommandPtr m_dynamicForward{
m_sysidRoutine.Dynamic(frc2::sysid::Direction::kForward)};
frc2::CommandPtr m_dynamicReverse{
m_sysidRoutine.Dynamic(frc2::sysid::Direction::kReverse)};
wpi::sim::PauseTiming();
wpi::cmd::CommandPtr m_quasistaticForward{
m_sysidRoutine.Quasistatic(wpi::cmd::sysid::Direction::kForward)};
wpi::cmd::CommandPtr m_quasistaticReverse{
m_sysidRoutine.Quasistatic(wpi::cmd::sysid::Direction::kReverse)};
wpi::cmd::CommandPtr m_dynamicForward{
m_sysidRoutine.Dynamic(wpi::cmd::sysid::Direction::kForward)};
wpi::cmd::CommandPtr m_dynamicReverse{
m_sysidRoutine.Dynamic(wpi::cmd::sysid::Direction::kReverse)};
}
void TearDown() override { frc::sim::ResumeTiming(); }
void TearDown() override { wpi::sim::ResumeTiming(); }
};
TEST_F(SysIdRoutineTest, RecordStateBookendsMotorLogging) {
@@ -151,28 +151,28 @@ TEST_F(SysIdRoutineTest, DeclareCorrectState) {
TEST_F(SysIdRoutineTest, OutputCorrectVoltage) {
RunCommand(std::move(m_quasistaticForward));
std::vector<units::volt_t> expectedVoltages{1_V, 0_V};
std::vector<wpi::units::volt_t> expectedVoltages{1_V, 0_V};
EXPECT_NEAR_UNITS(expectedVoltages[0], sentVoltages[0], 1e-6_V);
EXPECT_NEAR_UNITS(expectedVoltages[1], sentVoltages[1], 1e-6_V);
currentStateList.clear();
sentVoltages.clear();
RunCommand(std::move(m_quasistaticReverse));
expectedVoltages = std::vector<units::volt_t>{-1_V, 0_V};
expectedVoltages = std::vector<wpi::units::volt_t>{-1_V, 0_V};
EXPECT_NEAR_UNITS(expectedVoltages[0], sentVoltages[0], 1e-6_V);
EXPECT_NEAR_UNITS(expectedVoltages[1], sentVoltages[1], 1e-6_V);
currentStateList.clear();
sentVoltages.clear();
RunCommand(std::move(m_dynamicForward));
expectedVoltages = std::vector<units::volt_t>{7_V, 0_V};
expectedVoltages = std::vector<wpi::units::volt_t>{7_V, 0_V};
EXPECT_NEAR_UNITS(expectedVoltages[0], sentVoltages[0], 1e-6_V);
EXPECT_NEAR_UNITS(expectedVoltages[1], sentVoltages[1], 1e-6_V);
currentStateList.clear();
sentVoltages.clear();
RunCommand(std::move(m_dynamicReverse));
expectedVoltages = std::vector<units::volt_t>{-7_V, 0_V};
expectedVoltages = std::vector<wpi::units::volt_t>{-7_V, 0_V};
EXPECT_NEAR_UNITS(expectedVoltages[0], sentVoltages[0], 1e-6_V);
EXPECT_NEAR_UNITS(expectedVoltages[1], sentVoltages[1], 1e-6_V);
currentStateList.clear();