mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-03 03:01:44 +00:00
SCRIPT namespace replacements
This commit is contained in:
committed by
Peter Johnson
parent
ae6c043632
commit
9aca8e0fd6
@@ -13,10 +13,10 @@
|
||||
#include "wpi/util/sendable/SendableBuilder.hpp"
|
||||
#include "wpi/util/sendable/SendableRegistry.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
Command::Command() {
|
||||
wpi::SendableRegistry::Add(this, GetTypeName(*this));
|
||||
wpi::util::SendableRegistry::Add(this, GetTypeName(*this));
|
||||
}
|
||||
|
||||
Command::~Command() {
|
||||
@@ -32,7 +32,7 @@ void Command::Initialize() {}
|
||||
void Command::Execute() {}
|
||||
void Command::End(bool interrupted) {}
|
||||
|
||||
wpi::SmallSet<Subsystem*, 4> Command::GetRequirements() const {
|
||||
wpi::util::SmallSet<Subsystem*, 4> Command::GetRequirements() const {
|
||||
return m_requirements;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ void Command::AddRequirements(Requirements requirements) {
|
||||
m_requirements.insert(requirements.begin(), requirements.end());
|
||||
}
|
||||
|
||||
void Command::AddRequirements(wpi::SmallSet<Subsystem*, 4> requirements) {
|
||||
void Command::AddRequirements(wpi::util::SmallSet<Subsystem*, 4> requirements) {
|
||||
m_requirements.insert(requirements.begin(), requirements.end());
|
||||
}
|
||||
|
||||
@@ -49,22 +49,22 @@ void Command::AddRequirements(Subsystem* requirement) {
|
||||
}
|
||||
|
||||
void Command::SetName(std::string_view name) {
|
||||
wpi::SendableRegistry::SetName(this, name);
|
||||
wpi::util::SendableRegistry::SetName(this, name);
|
||||
}
|
||||
|
||||
std::string Command::GetName() const {
|
||||
return wpi::SendableRegistry::GetName(this);
|
||||
return wpi::util::SendableRegistry::GetName(this);
|
||||
}
|
||||
|
||||
std::string Command::GetSubsystem() const {
|
||||
return wpi::SendableRegistry::GetSubsystem(this);
|
||||
return wpi::util::SendableRegistry::GetSubsystem(this);
|
||||
}
|
||||
|
||||
void Command::SetSubsystem(std::string_view subsystem) {
|
||||
wpi::SendableRegistry::SetSubsystem(this, subsystem);
|
||||
wpi::util::SendableRegistry::SetSubsystem(this, subsystem);
|
||||
}
|
||||
|
||||
CommandPtr Command::WithTimeout(units::second_t duration) && {
|
||||
CommandPtr Command::WithTimeout(wpi::units::second_t duration) && {
|
||||
return std::move(*this).ToPtr().WithTimeout(duration);
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ bool Command::IsComposed() const {
|
||||
|
||||
void Command::SetComposed(bool isComposed) {
|
||||
if (isComposed) {
|
||||
m_previousComposition = wpi::GetStackTrace(1);
|
||||
m_previousComposition = wpi::util::GetStackTrace(1);
|
||||
} else {
|
||||
m_previousComposition.reset();
|
||||
}
|
||||
@@ -188,7 +188,7 @@ std::optional<std::string> Command::GetPreviousCompositionSite() const {
|
||||
return m_previousComposition;
|
||||
}
|
||||
|
||||
void Command::InitSendable(wpi::SendableBuilder& builder) {
|
||||
void Command::InitSendable(wpi::util::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Command");
|
||||
builder.AddStringProperty(".name", [this] { return GetName(); }, nullptr);
|
||||
builder.AddBooleanProperty(
|
||||
@@ -220,7 +220,7 @@ void Command::InitSendable(wpi::SendableBuilder& builder) {
|
||||
"runsWhenDisabled", [this] { return RunsWhenDisabled(); }, nullptr);
|
||||
}
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
bool RequirementsDisjoint(Command* first, Command* second) {
|
||||
bool disjoint = true;
|
||||
auto&& requirements = second->GetRequirements();
|
||||
@@ -229,4 +229,4 @@ bool RequirementsDisjoint(Command* first, Command* second) {
|
||||
}
|
||||
return disjoint;
|
||||
}
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "wpi/commands2/WrapperCommand.hpp"
|
||||
#include "wpi/system/Errors.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
CommandPtr::CommandPtr(std::unique_ptr<Command>&& command)
|
||||
: m_ptr(std::move(command)) {
|
||||
@@ -32,12 +32,12 @@ CommandPtr::CommandPtr(std::unique_ptr<Command>&& command)
|
||||
CommandPtr::CommandPtr(CommandPtr&& rhs) {
|
||||
m_ptr = std::move(rhs.m_ptr);
|
||||
AssertValid();
|
||||
rhs.m_moveOutSite = wpi::GetStackTrace(1);
|
||||
rhs.m_moveOutSite = wpi::util::GetStackTrace(1);
|
||||
}
|
||||
|
||||
void CommandPtr::AssertValid() const {
|
||||
if (!m_ptr) {
|
||||
throw FRC_MakeError(frc::err::CommandIllegalUse,
|
||||
throw FRC_MakeError(wpi::err::CommandIllegalUse,
|
||||
"Moved-from CommandPtr object used!\nMoved out at:\n{}",
|
||||
m_moveOutSite);
|
||||
}
|
||||
@@ -131,7 +131,7 @@ CommandPtr CommandPtr::BeforeStarting(CommandPtr&& before) && {
|
||||
return std::move(*this);
|
||||
}
|
||||
|
||||
CommandPtr CommandPtr::WithTimeout(units::second_t duration) && {
|
||||
CommandPtr CommandPtr::WithTimeout(wpi::units::second_t duration) && {
|
||||
AssertValid();
|
||||
std::vector<std::unique_ptr<Command>> temp;
|
||||
temp.emplace_back(std::move(m_ptr));
|
||||
|
||||
@@ -24,39 +24,39 @@
|
||||
#include "wpi/util/sendable/SendableBuilder.hpp"
|
||||
#include "wpi/util/sendable/SendableRegistry.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
class CommandScheduler::Impl {
|
||||
public:
|
||||
// A set of the currently-running commands.
|
||||
wpi::SmallSet<Command*, 12> scheduledCommands;
|
||||
wpi::util::SmallSet<Command*, 12> scheduledCommands;
|
||||
|
||||
// A map from required subsystems to their requiring commands. Also used as a
|
||||
// set of the currently-required subsystems.
|
||||
wpi::DenseMap<Subsystem*, Command*> requirements;
|
||||
wpi::util::DenseMap<Subsystem*, Command*> requirements;
|
||||
|
||||
// A map from subsystems registered with the scheduler to their default
|
||||
// commands. Also used as a list of currently-registered subsystems.
|
||||
wpi::DenseMap<Subsystem*, std::unique_ptr<Command>> subsystems;
|
||||
wpi::util::DenseMap<Subsystem*, std::unique_ptr<Command>> subsystems;
|
||||
|
||||
frc::EventLoop defaultButtonLoop;
|
||||
wpi::EventLoop defaultButtonLoop;
|
||||
// The set of currently-registered buttons that will be polled every
|
||||
// iteration.
|
||||
frc::EventLoop* activeButtonLoop{&defaultButtonLoop};
|
||||
wpi::EventLoop* activeButtonLoop{&defaultButtonLoop};
|
||||
|
||||
bool disabled{false};
|
||||
|
||||
// Lists of user-supplied actions to be executed on scheduling events for
|
||||
// every command.
|
||||
wpi::SmallVector<Action, 4> initActions;
|
||||
wpi::SmallVector<Action, 4> executeActions;
|
||||
wpi::SmallVector<InterruptAction, 4> interruptActions;
|
||||
wpi::SmallVector<Action, 4> finishActions;
|
||||
wpi::util::SmallVector<Action, 4> initActions;
|
||||
wpi::util::SmallVector<Action, 4> executeActions;
|
||||
wpi::util::SmallVector<InterruptAction, 4> interruptActions;
|
||||
wpi::util::SmallVector<Action, 4> finishActions;
|
||||
|
||||
// Map of Command* -> CommandPtr for CommandPtrs transferred to the scheduler
|
||||
// via Schedule(CommandPtr&&). These are erased (destroyed) at the very end of
|
||||
// the loop cycle when the command lifecycle is complete.
|
||||
wpi::DenseMap<Command*, CommandPtr> ownedCommands;
|
||||
wpi::util::DenseMap<Command*, CommandPtr> ownedCommands;
|
||||
};
|
||||
|
||||
template <typename TMap, typename TKey>
|
||||
@@ -65,15 +65,15 @@ static bool ContainsKey(const TMap& map, TKey keyToCheck) {
|
||||
}
|
||||
|
||||
CommandScheduler::CommandScheduler()
|
||||
: m_impl(new Impl), m_watchdog(frc::TimedRobot::kDefaultPeriod, [] {
|
||||
: m_impl(new Impl), m_watchdog(wpi::TimedRobot::kDefaultPeriod, [] {
|
||||
std::puts("CommandScheduler loop time overrun.");
|
||||
}) {
|
||||
HAL_ReportUsage("CommandScheduler", "");
|
||||
wpi::SendableRegistry::Add(this, "Scheduler");
|
||||
wpi::util::SendableRegistry::Add(this, "Scheduler");
|
||||
}
|
||||
|
||||
CommandScheduler::~CommandScheduler() {
|
||||
wpi::SendableRegistry::Remove(this);
|
||||
wpi::util::SendableRegistry::Remove(this);
|
||||
std::unique_ptr<Impl>().swap(m_impl);
|
||||
}
|
||||
|
||||
@@ -82,19 +82,19 @@ CommandScheduler& CommandScheduler::GetInstance() {
|
||||
return scheduler;
|
||||
}
|
||||
|
||||
void CommandScheduler::SetPeriod(units::second_t period) {
|
||||
void CommandScheduler::SetPeriod(wpi::units::second_t period) {
|
||||
m_watchdog.SetTimeout(period);
|
||||
}
|
||||
|
||||
frc::EventLoop* CommandScheduler::GetActiveButtonLoop() const {
|
||||
wpi::EventLoop* CommandScheduler::GetActiveButtonLoop() const {
|
||||
return m_impl->activeButtonLoop;
|
||||
}
|
||||
|
||||
void CommandScheduler::SetActiveButtonLoop(frc::EventLoop* loop) {
|
||||
void CommandScheduler::SetActiveButtonLoop(wpi::EventLoop* loop) {
|
||||
m_impl->activeButtonLoop = loop;
|
||||
}
|
||||
|
||||
frc::EventLoop* CommandScheduler::GetDefaultButtonLoop() const {
|
||||
wpi::EventLoop* CommandScheduler::GetDefaultButtonLoop() const {
|
||||
return &(m_impl->defaultButtonLoop);
|
||||
}
|
||||
|
||||
@@ -102,13 +102,13 @@ void CommandScheduler::Schedule(Command* command) {
|
||||
RequireUngrouped(command);
|
||||
|
||||
if (m_impl->disabled || m_impl->scheduledCommands.contains(command) ||
|
||||
(frc::RobotState::IsDisabled() && !command->RunsWhenDisabled())) {
|
||||
(wpi::RobotState::IsDisabled() && !command->RunsWhenDisabled())) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& requirements = command->GetRequirements();
|
||||
|
||||
wpi::SmallVector<Command*, 8> intersection;
|
||||
wpi::util::SmallVector<Command*, 8> intersection;
|
||||
|
||||
bool isDisjoint = true;
|
||||
bool allInterruptible = true;
|
||||
@@ -171,7 +171,7 @@ void CommandScheduler::Run() {
|
||||
// Run the periodic method of all registered subsystems.
|
||||
for (auto&& subsystem : m_impl->subsystems) {
|
||||
subsystem.getFirst()->Periodic();
|
||||
if constexpr (frc::RobotBase::IsSimulation()) {
|
||||
if constexpr (wpi::RobotBase::IsSimulation()) {
|
||||
subsystem.getFirst()->SimulationPeriodic();
|
||||
}
|
||||
m_watchdog.AddEpoch(subsystem.getFirst()->GetName() + ".Periodic()");
|
||||
@@ -179,14 +179,14 @@ void CommandScheduler::Run() {
|
||||
|
||||
// Cache the active instance to avoid concurrency problems if SetActiveLoop()
|
||||
// is called from inside the button bindings.
|
||||
frc::EventLoop* loopCache = m_impl->activeButtonLoop;
|
||||
wpi::EventLoop* loopCache = m_impl->activeButtonLoop;
|
||||
// Poll buttons for new commands to add.
|
||||
loopCache->Poll();
|
||||
m_watchdog.AddEpoch("buttons.Run()");
|
||||
|
||||
bool isDisabled = frc::RobotState::IsDisabled();
|
||||
bool isDisabled = wpi::RobotState::IsDisabled();
|
||||
// create a new set to avoid iterator invalidation.
|
||||
for (Command* command : wpi::SmallSet(m_impl->scheduledCommands)) {
|
||||
for (Command* command : wpi::util::SmallSet(m_impl->scheduledCommands)) {
|
||||
if (!IsScheduled(command)) {
|
||||
continue; // skip as the normal scheduledCommands was modified
|
||||
}
|
||||
@@ -284,7 +284,7 @@ void CommandScheduler::UnregisterAllSubsystems() {
|
||||
void CommandScheduler::SetDefaultCommand(Subsystem* subsystem,
|
||||
CommandPtr&& defaultCommand) {
|
||||
if (!defaultCommand.get()->HasRequirement(subsystem)) {
|
||||
throw FRC_MakeError(frc::err::CommandIllegalUse, "{}",
|
||||
throw FRC_MakeError(wpi::err::CommandIllegalUse, "{}",
|
||||
"Default commands must require their subsystem!");
|
||||
}
|
||||
RequireUngrouped(defaultCommand.get());
|
||||
@@ -347,7 +347,7 @@ void CommandScheduler::Cancel(std::initializer_list<Command*> commands) {
|
||||
}
|
||||
|
||||
void CommandScheduler::CancelAll() {
|
||||
wpi::SmallVector<Command*, 16> commands;
|
||||
wpi::util::SmallVector<Command*, 16> commands;
|
||||
for (auto&& command : m_impl->scheduledCommands) {
|
||||
commands.emplace_back(command);
|
||||
}
|
||||
@@ -430,7 +430,7 @@ void CommandScheduler::OnCommandFinish(Action action) {
|
||||
void CommandScheduler::RequireUngrouped(const Command* command) {
|
||||
auto stacktrace = command->GetPreviousCompositionSite();
|
||||
if (stacktrace.has_value()) {
|
||||
throw FRC_MakeError(frc::err::CommandIllegalUse,
|
||||
throw FRC_MakeError(wpi::err::CommandIllegalUse,
|
||||
"Commands that have been composed may not be added to "
|
||||
"another composition or scheduled individually!"
|
||||
"\nOriginally composed at:\n{}",
|
||||
@@ -454,7 +454,7 @@ void CommandScheduler::RequireUngrouped(
|
||||
|
||||
void CommandScheduler::RequireUngroupedAndUnscheduled(const Command* command) {
|
||||
if (IsScheduled(command)) {
|
||||
throw FRC_MakeError(frc::err::CommandIllegalUse,
|
||||
throw FRC_MakeError(wpi::err::CommandIllegalUse,
|
||||
"Commands that have been scheduled individually may "
|
||||
"not be added to another composition!");
|
||||
}
|
||||
@@ -475,7 +475,7 @@ void CommandScheduler::RequireUngroupedAndUnscheduled(
|
||||
}
|
||||
}
|
||||
|
||||
void CommandScheduler::InitSendable(wpi::SendableBuilder& builder) {
|
||||
void CommandScheduler::InitSendable(wpi::util::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Scheduler");
|
||||
builder.AddStringArrayProperty(
|
||||
"Names",
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "wpi/util/FunctionExtras.hpp"
|
||||
#include "wpi/util/deprecated.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
// Factories
|
||||
|
||||
@@ -73,7 +73,7 @@ CommandPtr cmd::Print(std::string_view msg) {
|
||||
return PrintCommand(msg).ToPtr();
|
||||
}
|
||||
|
||||
CommandPtr cmd::DeferredProxy(wpi::unique_function<Command*()> supplier) {
|
||||
CommandPtr cmd::DeferredProxy(wpi::util::unique_function<Command*()> supplier) {
|
||||
return Defer(
|
||||
[supplier = std::move(supplier)]() mutable {
|
||||
// There is no non-owning version of AsProxy(), so use the non-owning
|
||||
@@ -83,13 +83,13 @@ CommandPtr cmd::DeferredProxy(wpi::unique_function<Command*()> supplier) {
|
||||
{});
|
||||
}
|
||||
|
||||
CommandPtr cmd::DeferredProxy(wpi::unique_function<CommandPtr()> supplier) {
|
||||
CommandPtr cmd::DeferredProxy(wpi::util::unique_function<CommandPtr()> supplier) {
|
||||
return Defer([supplier = std::move(
|
||||
supplier)]() mutable { return supplier().AsProxy(); },
|
||||
{});
|
||||
}
|
||||
|
||||
CommandPtr cmd::Wait(units::second_t duration) {
|
||||
CommandPtr cmd::Wait(wpi::units::second_t duration) {
|
||||
return WaitCommand(duration).ToPtr();
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ CommandPtr cmd::Either(CommandPtr&& onTrue, CommandPtr&& onFalse,
|
||||
.ToPtr();
|
||||
}
|
||||
|
||||
CommandPtr cmd::Defer(wpi::unique_function<CommandPtr()> supplier,
|
||||
CommandPtr cmd::Defer(wpi::util::unique_function<CommandPtr()> supplier,
|
||||
Requirements requirements) {
|
||||
return DeferredCommand(std::move(supplier), requirements).ToPtr();
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#include "wpi/util/sendable/SendableBuilder.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
ConditionalCommand::ConditionalCommand(std::unique_ptr<Command>&& onTrue,
|
||||
std::unique_ptr<Command>&& onFalse,
|
||||
@@ -69,7 +69,7 @@ Command::InterruptionBehavior ConditionalCommand::GetInterruptionBehavior()
|
||||
}
|
||||
}
|
||||
|
||||
void ConditionalCommand::InitSendable(wpi::SendableBuilder& builder) {
|
||||
void ConditionalCommand::InitSendable(wpi::util::SendableBuilder& builder) {
|
||||
Command::InitSendable(builder);
|
||||
builder.AddStringProperty(
|
||||
"onTrue", [this] { return m_onTrue->GetName(); }, nullptr);
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
#include "wpi/commands2/Commands.hpp"
|
||||
#include "wpi/util/sendable/SendableBuilder.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
DeferredCommand::DeferredCommand(wpi::unique_function<CommandPtr()> supplier,
|
||||
DeferredCommand::DeferredCommand(wpi::util::unique_function<CommandPtr()> supplier,
|
||||
Requirements requirements)
|
||||
: m_supplier{std::move(supplier)} {
|
||||
AddRequirements(requirements);
|
||||
@@ -40,7 +40,7 @@ bool DeferredCommand::IsFinished() {
|
||||
return m_command->IsFinished();
|
||||
}
|
||||
|
||||
void DeferredCommand::InitSendable(wpi::SendableBuilder& builder) {
|
||||
void DeferredCommand::InitSendable(wpi::util::SendableBuilder& builder) {
|
||||
Command::InitSendable(builder);
|
||||
builder.AddStringProperty(
|
||||
"deferred", [this] { return m_command->GetName(); }, nullptr);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <utility>
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
FunctionalCommand::FunctionalCommand(std::function<void()> onInit,
|
||||
std::function<void()> onExecute,
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <utility>
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
InstantCommand::InstantCommand(std::function<void()> toRun,
|
||||
Requirements requirements)
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
|
||||
#include <utility>
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
NotifierCommand::NotifierCommand(std::function<void()> toRun,
|
||||
units::second_t period,
|
||||
wpi::units::second_t period,
|
||||
Requirements requirements)
|
||||
: m_toRun(toRun), m_notifier{std::move(toRun)}, m_period{period} {
|
||||
AddRequirements(requirements);
|
||||
@@ -24,7 +24,7 @@ NotifierCommand::NotifierCommand(NotifierCommand&& other)
|
||||
NotifierCommand::NotifierCommand(const NotifierCommand& other)
|
||||
: CommandHelper(other),
|
||||
m_toRun(other.m_toRun),
|
||||
m_notifier(frc::Notifier(other.m_toRun)),
|
||||
m_notifier(wpi::Notifier(other.m_toRun)),
|
||||
m_period(other.m_period) {}
|
||||
|
||||
void NotifierCommand::Initialize() {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
ParallelCommandGroup::ParallelCommandGroup(
|
||||
std::vector<std::unique_ptr<Command>>&& commands) {
|
||||
@@ -69,7 +69,7 @@ void ParallelCommandGroup::AddCommands(
|
||||
CommandScheduler::GetInstance().RequireUngroupedAndUnscheduled(commands);
|
||||
|
||||
if (isRunning) {
|
||||
throw FRC_MakeError(frc::err::CommandIllegalUse,
|
||||
throw FRC_MakeError(wpi::err::CommandIllegalUse,
|
||||
"Commands cannot be added to a CommandGroup "
|
||||
"while the group is running");
|
||||
}
|
||||
@@ -85,7 +85,7 @@ void ParallelCommandGroup::AddCommands(
|
||||
}
|
||||
m_commands.emplace_back(std::move(command), false);
|
||||
} else {
|
||||
throw FRC_MakeError(frc::err::CommandIllegalUse,
|
||||
throw FRC_MakeError(wpi::err::CommandIllegalUse,
|
||||
"Multiple commands in a parallel group cannot "
|
||||
"require the same subsystems");
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#include "wpi/util/sendable/SendableBuilder.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
ParallelDeadlineGroup::ParallelDeadlineGroup(
|
||||
std::unique_ptr<Command>&& deadline,
|
||||
@@ -69,7 +69,7 @@ void ParallelDeadlineGroup::AddCommands(
|
||||
CommandScheduler::GetInstance().RequireUngroupedAndUnscheduled(commands);
|
||||
|
||||
if (!m_finished) {
|
||||
throw FRC_MakeError(frc::err::CommandIllegalUse,
|
||||
throw FRC_MakeError(wpi::err::CommandIllegalUse,
|
||||
"Commands cannot be added to a CommandGroup "
|
||||
"while the group is running");
|
||||
}
|
||||
@@ -85,7 +85,7 @@ void ParallelDeadlineGroup::AddCommands(
|
||||
}
|
||||
m_commands.emplace_back(std::move(command), false);
|
||||
} else {
|
||||
throw FRC_MakeError(frc::err::CommandIllegalUse,
|
||||
throw FRC_MakeError(wpi::err::CommandIllegalUse,
|
||||
"Multiple commands in a parallel group cannot "
|
||||
"require the same subsystems");
|
||||
}
|
||||
@@ -100,7 +100,7 @@ void ParallelDeadlineGroup::SetDeadline(std::unique_ptr<Command>&& deadline) {
|
||||
m_runWhenDisabled &= m_deadline->RunsWhenDisabled();
|
||||
}
|
||||
|
||||
void ParallelDeadlineGroup::InitSendable(wpi::SendableBuilder& builder) {
|
||||
void ParallelDeadlineGroup::InitSendable(wpi::util::SendableBuilder& builder) {
|
||||
Command::InitSendable(builder);
|
||||
|
||||
builder.AddStringProperty(
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
ParallelRaceGroup::ParallelRaceGroup(
|
||||
std::vector<std::unique_ptr<Command>>&& commands) {
|
||||
@@ -56,7 +56,7 @@ void ParallelRaceGroup::AddCommands(
|
||||
CommandScheduler::GetInstance().RequireUngroupedAndUnscheduled(commands);
|
||||
|
||||
if (isRunning) {
|
||||
throw FRC_MakeError(frc::err::CommandIllegalUse,
|
||||
throw FRC_MakeError(wpi::err::CommandIllegalUse,
|
||||
"Commands cannot be added to a CommandGroup "
|
||||
"while the group is running");
|
||||
}
|
||||
@@ -72,7 +72,7 @@ void ParallelRaceGroup::AddCommands(
|
||||
}
|
||||
m_commands.emplace_back(std::move(command));
|
||||
} else {
|
||||
throw FRC_MakeError(frc::err::CommandIllegalUse,
|
||||
throw FRC_MakeError(wpi::err::CommandIllegalUse,
|
||||
"Multiple commands in a parallel group cannot "
|
||||
"require the same subsystems");
|
||||
}
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
|
||||
#include "wpi/util/print.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
PrintCommand::PrintCommand(std::string_view message)
|
||||
: CommandHelper{[str = std::string(message)] { wpi::print("{}\n", str); },
|
||||
: CommandHelper{[str = std::string(message)] { wpi::util::print("{}\n", str); },
|
||||
{}} {}
|
||||
|
||||
bool PrintCommand::RunsWhenDisabled() const {
|
||||
|
||||
@@ -12,13 +12,13 @@
|
||||
#include "wpi/util/deprecated.hpp"
|
||||
#include "wpi/util/sendable/SendableBuilder.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
WPI_IGNORE_DEPRECATED
|
||||
ProxyCommand::ProxyCommand(wpi::unique_function<Command*()> supplier)
|
||||
ProxyCommand::ProxyCommand(wpi::util::unique_function<Command*()> supplier)
|
||||
: m_supplier(std::move(supplier)) {}
|
||||
|
||||
ProxyCommand::ProxyCommand(wpi::unique_function<CommandPtr()> supplier)
|
||||
ProxyCommand::ProxyCommand(wpi::util::unique_function<CommandPtr()> supplier)
|
||||
: ProxyCommand([supplier = std::move(supplier),
|
||||
holder = std::optional<CommandPtr>{}]() mutable {
|
||||
holder = supplier();
|
||||
@@ -38,7 +38,7 @@ ProxyCommand::ProxyCommand(std::unique_ptr<Command> command) {
|
||||
|
||||
void ProxyCommand::Initialize() {
|
||||
m_command = m_supplier();
|
||||
frc2::CommandScheduler::GetInstance().Schedule(m_command);
|
||||
wpi::cmd::CommandScheduler::GetInstance().Schedule(m_command);
|
||||
}
|
||||
|
||||
void ProxyCommand::End(bool interrupted) {
|
||||
@@ -55,7 +55,7 @@ bool ProxyCommand::IsFinished() {
|
||||
return m_command == nullptr || !m_command->IsScheduled();
|
||||
}
|
||||
|
||||
void ProxyCommand::InitSendable(wpi::SendableBuilder& builder) {
|
||||
void ProxyCommand::InitSendable(wpi::util::SendableBuilder& builder) {
|
||||
Command::InitSendable(builder);
|
||||
builder.AddStringProperty(
|
||||
"proxied",
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include "wpi/util/sendable/SendableBuilder.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
RepeatCommand::RepeatCommand(std::unique_ptr<Command>&& command) {
|
||||
CommandScheduler::GetInstance().RequireUngroupedAndUnscheduled(command.get());
|
||||
@@ -58,7 +58,7 @@ Command::InterruptionBehavior RepeatCommand::GetInterruptionBehavior() const {
|
||||
return m_command->GetInterruptionBehavior();
|
||||
}
|
||||
|
||||
void RepeatCommand::InitSendable(wpi::SendableBuilder& builder) {
|
||||
void RepeatCommand::InitSendable(wpi::util::SendableBuilder& builder) {
|
||||
Command::InitSendable(builder);
|
||||
builder.AddStringProperty(
|
||||
"command", [this] { return m_command->GetName(); }, nullptr);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <utility>
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
RunCommand::RunCommand(std::function<void()> toRun, Requirements requirements)
|
||||
: CommandHelper([] {}, std::move(toRun), [](bool interrupted) {},
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "wpi/commands2/ScheduleCommand.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
ScheduleCommand::ScheduleCommand(std::span<Command* const> toSchedule) {
|
||||
for (auto cmd : toSchedule) {
|
||||
@@ -18,7 +18,7 @@ ScheduleCommand::ScheduleCommand(Command* toSchedule) {
|
||||
|
||||
void ScheduleCommand::Initialize() {
|
||||
for (auto command : m_toSchedule) {
|
||||
frc2::CommandScheduler::GetInstance().Schedule(command);
|
||||
wpi::cmd::CommandScheduler::GetInstance().Schedule(command);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include "wpi/util/sendable/SendableBuilder.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
SequentialCommandGroup::SequentialCommandGroup(
|
||||
std::vector<std::unique_ptr<Command>>&& commands) {
|
||||
@@ -68,7 +68,7 @@ void SequentialCommandGroup::AddCommands(
|
||||
CommandScheduler::GetInstance().RequireUngroupedAndUnscheduled(commands);
|
||||
|
||||
if (m_currentCommandIndex != invalid_index) {
|
||||
throw FRC_MakeError(frc::err::CommandIllegalUse,
|
||||
throw FRC_MakeError(wpi::err::CommandIllegalUse,
|
||||
"Commands cannot be added to a CommandGroup "
|
||||
"while the group is running");
|
||||
}
|
||||
@@ -85,7 +85,7 @@ void SequentialCommandGroup::AddCommands(
|
||||
}
|
||||
}
|
||||
|
||||
void SequentialCommandGroup::InitSendable(wpi::SendableBuilder& builder) {
|
||||
void SequentialCommandGroup::InitSendable(wpi::util::SendableBuilder& builder) {
|
||||
Command::InitSendable(builder);
|
||||
builder.AddIntegerProperty(
|
||||
"index", [this] { return m_currentCommandIndex; }, nullptr);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <utility>
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
StartEndCommand::StartEndCommand(std::function<void()> onInit,
|
||||
std::function<void()> onEnd,
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "wpi/commands2/Commands.hpp"
|
||||
#include "wpi/util/Demangle.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
Subsystem::~Subsystem() {
|
||||
CommandScheduler::GetInstance().UnregisterSubsystem(this);
|
||||
}
|
||||
@@ -21,7 +21,7 @@ void Subsystem::Periodic() {}
|
||||
void Subsystem::SimulationPeriodic() {}
|
||||
|
||||
std::string Subsystem::GetName() const {
|
||||
return wpi::GetTypeName(*this);
|
||||
return wpi::util::GetTypeName(*this);
|
||||
}
|
||||
|
||||
void Subsystem::SetDefaultCommand(CommandPtr&& defaultCommand) {
|
||||
@@ -72,6 +72,6 @@ CommandPtr Subsystem::StartRun(std::function<void()> start,
|
||||
return cmd::StartRun(std::move(start), std::move(run), {this});
|
||||
}
|
||||
|
||||
CommandPtr Subsystem::Defer(wpi::unique_function<CommandPtr()> supplier) {
|
||||
CommandPtr Subsystem::Defer(wpi::util::unique_function<CommandPtr()> supplier) {
|
||||
return cmd::Defer(std::move(supplier), {this});
|
||||
}
|
||||
|
||||
@@ -11,19 +11,19 @@
|
||||
#include "wpi/util/sendable/SendableBuilder.hpp"
|
||||
#include "wpi/util/sendable/SendableRegistry.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
SubsystemBase::SubsystemBase() {
|
||||
wpi::SendableRegistry::Add(this, GetTypeName(*this));
|
||||
wpi::util::SendableRegistry::Add(this, GetTypeName(*this));
|
||||
CommandScheduler::GetInstance().RegisterSubsystem({this});
|
||||
}
|
||||
|
||||
SubsystemBase::SubsystemBase(std::string_view name) {
|
||||
wpi::SendableRegistry::Add(this, name);
|
||||
wpi::util::SendableRegistry::Add(this, name);
|
||||
CommandScheduler::GetInstance().RegisterSubsystem({this});
|
||||
}
|
||||
|
||||
void SubsystemBase::InitSendable(wpi::SendableBuilder& builder) {
|
||||
void SubsystemBase::InitSendable(wpi::util::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Subsystem");
|
||||
builder.AddBooleanProperty(
|
||||
".hasDefault", [this] { return GetDefaultCommand() != nullptr; },
|
||||
@@ -54,21 +54,21 @@ void SubsystemBase::InitSendable(wpi::SendableBuilder& builder) {
|
||||
}
|
||||
|
||||
std::string SubsystemBase::GetName() const {
|
||||
return wpi::SendableRegistry::GetName(this);
|
||||
return wpi::util::SendableRegistry::GetName(this);
|
||||
}
|
||||
|
||||
void SubsystemBase::SetName(std::string_view name) {
|
||||
wpi::SendableRegistry::SetName(this, name);
|
||||
wpi::util::SendableRegistry::SetName(this, name);
|
||||
}
|
||||
|
||||
std::string SubsystemBase::GetSubsystem() const {
|
||||
return wpi::SendableRegistry::GetSubsystem(this);
|
||||
return wpi::util::SendableRegistry::GetSubsystem(this);
|
||||
}
|
||||
|
||||
void SubsystemBase::SetSubsystem(std::string_view name) {
|
||||
wpi::SendableRegistry::SetSubsystem(this, name);
|
||||
wpi::util::SendableRegistry::SetSubsystem(this, name);
|
||||
}
|
||||
|
||||
void SubsystemBase::AddChild(std::string name, wpi::Sendable* child) {
|
||||
wpi::SendableRegistry::Add(child, GetSubsystem(), name);
|
||||
void SubsystemBase::AddChild(std::string name, wpi::util::Sendable* child) {
|
||||
wpi::util::SendableRegistry::Add(child, GetSubsystem(), name);
|
||||
}
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
|
||||
#include "wpi/util/sendable/SendableBuilder.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
WaitCommand::WaitCommand(units::second_t duration) : m_duration{duration} {
|
||||
WaitCommand::WaitCommand(wpi::units::second_t duration) : m_duration{duration} {
|
||||
SetName(fmt::format("{}: {}", GetName(), duration));
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ bool WaitCommand::RunsWhenDisabled() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
void WaitCommand::InitSendable(wpi::SendableBuilder& builder) {
|
||||
void WaitCommand::InitSendable(wpi::util::SendableBuilder& builder) {
|
||||
Command::InitSendable(builder);
|
||||
builder.AddDoubleProperty(
|
||||
"duration", [this] { return m_duration.value(); }, nullptr);
|
||||
|
||||
@@ -8,13 +8,13 @@
|
||||
|
||||
#include "wpi/system/Timer.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
WaitUntilCommand::WaitUntilCommand(std::function<bool()> condition)
|
||||
: m_condition{std::move(condition)} {}
|
||||
|
||||
WaitUntilCommand::WaitUntilCommand(units::second_t time)
|
||||
: m_condition{[=] { return frc::Timer::GetMatchTime() - time > 0_s; }} {}
|
||||
WaitUntilCommand::WaitUntilCommand(wpi::units::second_t time)
|
||||
: m_condition{[=] { return wpi::Timer::GetMatchTime() - time > 0_s; }} {}
|
||||
|
||||
bool WaitUntilCommand::IsFinished() {
|
||||
return m_condition();
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "wpi/commands2/Command.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
WrapperCommand::WrapperCommand(std::unique_ptr<Command>&& command) {
|
||||
CommandScheduler::GetInstance().RequireUngroupedAndUnscheduled(command.get());
|
||||
@@ -42,6 +42,6 @@ Command::InterruptionBehavior WrapperCommand::GetInterruptionBehavior() const {
|
||||
return m_command->GetInterruptionBehavior();
|
||||
}
|
||||
|
||||
wpi::SmallSet<Subsystem*, 4> WrapperCommand::GetRequirements() const {
|
||||
wpi::util::SmallSet<Subsystem*, 4> WrapperCommand::GetRequirements() const {
|
||||
return m_command->GetRequirements();
|
||||
}
|
||||
|
||||
@@ -4,128 +4,128 @@
|
||||
|
||||
#include "wpi/commands2/button/CommandGamepad.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
CommandGamepad::CommandGamepad(int port)
|
||||
: CommandGenericHID(port), m_hid{frc::Gamepad(port)} {}
|
||||
: CommandGenericHID(port), m_hid{wpi::Gamepad(port)} {}
|
||||
|
||||
frc::Gamepad& CommandGamepad::GetHID() {
|
||||
wpi::Gamepad& CommandGamepad::GetHID() {
|
||||
return m_hid;
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::SouthFace(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kSouthFace, loop);
|
||||
Trigger CommandGamepad::SouthFace(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kSouthFace, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::EastFace(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kEastFace, loop);
|
||||
Trigger CommandGamepad::EastFace(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kEastFace, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::WestFace(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kWestFace, loop);
|
||||
Trigger CommandGamepad::WestFace(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kWestFace, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::NorthFace(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kNorthFace, loop);
|
||||
Trigger CommandGamepad::NorthFace(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kNorthFace, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::Back(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kBack, loop);
|
||||
Trigger CommandGamepad::Back(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kBack, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::Guide(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kGuide, loop);
|
||||
Trigger CommandGamepad::Guide(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kGuide, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::Start(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kStart, loop);
|
||||
Trigger CommandGamepad::Start(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kStart, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::LeftStick(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kLeftStick, loop);
|
||||
Trigger CommandGamepad::LeftStick(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kLeftStick, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::RightStick(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kRightStick, loop);
|
||||
Trigger CommandGamepad::RightStick(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kRightStick, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::LeftShoulder(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kLeftShoulder, loop);
|
||||
Trigger CommandGamepad::LeftShoulder(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kLeftShoulder, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::RightShoulder(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kRightShoulder, loop);
|
||||
Trigger CommandGamepad::RightShoulder(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kRightShoulder, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::DpadUp(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kDpadUp, loop);
|
||||
Trigger CommandGamepad::DpadUp(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kDpadUp, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::DpadDown(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kDpadDown, loop);
|
||||
Trigger CommandGamepad::DpadDown(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kDpadDown, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::DpadLeft(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kDpadLeft, loop);
|
||||
Trigger CommandGamepad::DpadLeft(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kDpadLeft, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::DpadRight(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kDpadRight, loop);
|
||||
Trigger CommandGamepad::DpadRight(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kDpadRight, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::Misc1(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kMisc1, loop);
|
||||
Trigger CommandGamepad::Misc1(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kMisc1, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::RightPaddle1(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kRightPaddle1, loop);
|
||||
Trigger CommandGamepad::RightPaddle1(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kRightPaddle1, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::LeftPaddle1(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kLeftPaddle1, loop);
|
||||
Trigger CommandGamepad::LeftPaddle1(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kLeftPaddle1, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::RightPaddle2(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kRightPaddle2, loop);
|
||||
Trigger CommandGamepad::RightPaddle2(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kRightPaddle2, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::LeftPaddle2(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kLeftPaddle2, loop);
|
||||
Trigger CommandGamepad::LeftPaddle2(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kLeftPaddle2, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::Touchpad(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kTouchpad, loop);
|
||||
Trigger CommandGamepad::Touchpad(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kTouchpad, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::Misc2(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kMisc2, loop);
|
||||
Trigger CommandGamepad::Misc2(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kMisc2, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::Misc3(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kMisc3, loop);
|
||||
Trigger CommandGamepad::Misc3(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kMisc3, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::Misc4(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kMisc4, loop);
|
||||
Trigger CommandGamepad::Misc4(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kMisc4, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::Misc5(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kMisc5, loop);
|
||||
Trigger CommandGamepad::Misc5(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kMisc5, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::Misc6(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kMisc6, loop);
|
||||
Trigger CommandGamepad::Misc6(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kMisc6, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::LeftTrigger(double threshold,
|
||||
frc::EventLoop* loop) const {
|
||||
wpi::EventLoop* loop) const {
|
||||
return Trigger(loop, [this, threshold] {
|
||||
return m_hid.GetLeftTriggerAxis() > threshold;
|
||||
});
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::RightTrigger(double threshold,
|
||||
frc::EventLoop* loop) const {
|
||||
wpi::EventLoop* loop) const {
|
||||
return Trigger(loop, [this, threshold] {
|
||||
return m_hid.GetRightTriggerAxis() > threshold;
|
||||
});
|
||||
|
||||
@@ -4,87 +4,87 @@
|
||||
|
||||
#include "wpi/commands2/button/CommandGenericHID.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
CommandGenericHID::CommandGenericHID(int port) : m_hid{port} {}
|
||||
|
||||
frc::GenericHID& CommandGenericHID::GetHID() {
|
||||
wpi::GenericHID& CommandGenericHID::GetHID() {
|
||||
return m_hid;
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::Button(int button, frc::EventLoop* loop) const {
|
||||
Trigger CommandGenericHID::Button(int button, wpi::EventLoop* loop) const {
|
||||
return Trigger(loop, [this, button] { return m_hid.GetRawButton(button); });
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::POV(frc::DriverStation::POVDirection angle,
|
||||
frc::EventLoop* loop) const {
|
||||
Trigger CommandGenericHID::POV(wpi::DriverStation::POVDirection angle,
|
||||
wpi::EventLoop* loop) const {
|
||||
return POV(0, angle, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::POV(int pov, frc::DriverStation::POVDirection angle,
|
||||
frc::EventLoop* loop) const {
|
||||
Trigger CommandGenericHID::POV(int pov, wpi::DriverStation::POVDirection angle,
|
||||
wpi::EventLoop* loop) const {
|
||||
return Trigger(loop,
|
||||
[this, pov, angle] { return m_hid.GetPOV(pov) == angle; });
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::POVUp(frc::EventLoop* loop) const {
|
||||
return POV(frc::DriverStation::POVDirection::kUp, loop);
|
||||
Trigger CommandGenericHID::POVUp(wpi::EventLoop* loop) const {
|
||||
return POV(wpi::DriverStation::POVDirection::kUp, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::POVUpRight(frc::EventLoop* loop) const {
|
||||
return POV(frc::DriverStation::POVDirection::kUpRight, loop);
|
||||
Trigger CommandGenericHID::POVUpRight(wpi::EventLoop* loop) const {
|
||||
return POV(wpi::DriverStation::POVDirection::kUpRight, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::POVRight(frc::EventLoop* loop) const {
|
||||
return POV(frc::DriverStation::POVDirection::kRight, loop);
|
||||
Trigger CommandGenericHID::POVRight(wpi::EventLoop* loop) const {
|
||||
return POV(wpi::DriverStation::POVDirection::kRight, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::POVDownRight(frc::EventLoop* loop) const {
|
||||
return POV(frc::DriverStation::POVDirection::kDownRight, loop);
|
||||
Trigger CommandGenericHID::POVDownRight(wpi::EventLoop* loop) const {
|
||||
return POV(wpi::DriverStation::POVDirection::kDownRight, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::POVDown(frc::EventLoop* loop) const {
|
||||
return POV(frc::DriverStation::POVDirection::kDown, loop);
|
||||
Trigger CommandGenericHID::POVDown(wpi::EventLoop* loop) const {
|
||||
return POV(wpi::DriverStation::POVDirection::kDown, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::POVDownLeft(frc::EventLoop* loop) const {
|
||||
return POV(frc::DriverStation::POVDirection::kDownLeft, loop);
|
||||
Trigger CommandGenericHID::POVDownLeft(wpi::EventLoop* loop) const {
|
||||
return POV(wpi::DriverStation::POVDirection::kDownLeft, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::POVLeft(frc::EventLoop* loop) const {
|
||||
return POV(frc::DriverStation::POVDirection::kLeft, loop);
|
||||
Trigger CommandGenericHID::POVLeft(wpi::EventLoop* loop) const {
|
||||
return POV(wpi::DriverStation::POVDirection::kLeft, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::POVUpLeft(frc::EventLoop* loop) const {
|
||||
return POV(frc::DriverStation::POVDirection::kUpLeft, loop);
|
||||
Trigger CommandGenericHID::POVUpLeft(wpi::EventLoop* loop) const {
|
||||
return POV(wpi::DriverStation::POVDirection::kUpLeft, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::POVCenter(frc::EventLoop* loop) const {
|
||||
return POV(frc::DriverStation::POVDirection::kCenter, loop);
|
||||
Trigger CommandGenericHID::POVCenter(wpi::EventLoop* loop) const {
|
||||
return POV(wpi::DriverStation::POVDirection::kCenter, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::AxisLessThan(int axis, double threshold,
|
||||
frc::EventLoop* loop) const {
|
||||
wpi::EventLoop* loop) const {
|
||||
return Trigger(loop, [this, axis, threshold]() {
|
||||
return m_hid.GetRawAxis(axis) < threshold;
|
||||
});
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::AxisGreaterThan(int axis, double threshold,
|
||||
frc::EventLoop* loop) const {
|
||||
wpi::EventLoop* loop) const {
|
||||
return Trigger(loop, [this, axis, threshold]() {
|
||||
return m_hid.GetRawAxis(axis) > threshold;
|
||||
});
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::AxisMagnitudeGreaterThan(
|
||||
int axis, double threshold, frc::EventLoop* loop) const {
|
||||
int axis, double threshold, wpi::EventLoop* loop) const {
|
||||
return Trigger(loop, [this, axis, threshold]() {
|
||||
return std::abs(m_hid.GetRawAxis(axis)) > threshold;
|
||||
});
|
||||
}
|
||||
|
||||
void CommandGenericHID::SetRumble(frc::GenericHID::RumbleType type,
|
||||
void CommandGenericHID::SetRumble(wpi::GenericHID::RumbleType type,
|
||||
double value) {
|
||||
m_hid.SetRumble(type, value);
|
||||
}
|
||||
|
||||
@@ -4,28 +4,28 @@
|
||||
|
||||
#include "wpi/commands2/button/CommandJoystick.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
CommandJoystick::CommandJoystick(int port)
|
||||
: CommandGenericHID(port), m_hid{frc::Joystick(port)} {}
|
||||
: CommandGenericHID(port), m_hid{wpi::Joystick(port)} {}
|
||||
|
||||
frc::Joystick& CommandJoystick::GetHID() {
|
||||
wpi::Joystick& CommandJoystick::GetHID() {
|
||||
return m_hid;
|
||||
}
|
||||
|
||||
Trigger CommandJoystick::Trigger(frc::EventLoop* loop) const {
|
||||
return Button(frc::Joystick::ButtonType::kTriggerButton, loop);
|
||||
Trigger CommandJoystick::Trigger(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Joystick::ButtonType::kTriggerButton, loop);
|
||||
}
|
||||
|
||||
Trigger CommandJoystick::Top(frc::EventLoop* loop) const {
|
||||
return Button(frc::Joystick::ButtonType::kTopButton, loop);
|
||||
Trigger CommandJoystick::Top(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Joystick::ButtonType::kTopButton, loop);
|
||||
}
|
||||
|
||||
double CommandJoystick::GetMagnitude() const {
|
||||
return m_hid.GetMagnitude();
|
||||
}
|
||||
|
||||
units::radian_t CommandJoystick::GetDirection() const {
|
||||
wpi::units::radian_t CommandJoystick::GetDirection() const {
|
||||
// https://docs.wpilib.org/en/stable/docs/software/basic-programming/coordinate-system.html#joystick-and-controller-coordinate-system
|
||||
// A positive rotation around the X axis moves the joystick right, and a
|
||||
// positive rotation around the Y axis moves the joystick backward. When
|
||||
|
||||
@@ -7,23 +7,23 @@
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
NetworkButton::NetworkButton(nt::BooleanTopic topic)
|
||||
NetworkButton::NetworkButton(wpi::nt::BooleanTopic topic)
|
||||
: NetworkButton(topic.Subscribe(false)) {}
|
||||
|
||||
NetworkButton::NetworkButton(nt::BooleanSubscriber sub)
|
||||
: Trigger([sub = std::make_shared<nt::BooleanSubscriber>(std::move(sub))] {
|
||||
NetworkButton::NetworkButton(wpi::nt::BooleanSubscriber sub)
|
||||
: Trigger([sub = std::make_shared<wpi::nt::BooleanSubscriber>(std::move(sub))] {
|
||||
return sub->GetTopic().GetInstance().IsConnected() && sub->Get();
|
||||
}) {}
|
||||
|
||||
NetworkButton::NetworkButton(std::shared_ptr<nt::NetworkTable> table,
|
||||
NetworkButton::NetworkButton(std::shared_ptr<wpi::nt::NetworkTable> table,
|
||||
std::string_view field)
|
||||
: NetworkButton(table->GetBooleanTopic(field)) {}
|
||||
|
||||
NetworkButton::NetworkButton(std::string_view table, std::string_view field)
|
||||
: NetworkButton(nt::NetworkTableInstance::GetDefault(), table, field) {}
|
||||
: NetworkButton(wpi::nt::NetworkTableInstance::GetDefault(), table, field) {}
|
||||
|
||||
NetworkButton::NetworkButton(nt::NetworkTableInstance inst,
|
||||
NetworkButton::NetworkButton(wpi::nt::NetworkTableInstance inst,
|
||||
std::string_view table, std::string_view field)
|
||||
: NetworkButton(inst.GetTable(table), field) {}
|
||||
|
||||
@@ -6,20 +6,20 @@
|
||||
|
||||
#include "wpi/driverstation/DriverStation.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
Trigger RobotModeTriggers::Autonomous() {
|
||||
return Trigger{&frc::DriverStation::IsAutonomousEnabled};
|
||||
return Trigger{&wpi::DriverStation::IsAutonomousEnabled};
|
||||
}
|
||||
|
||||
Trigger RobotModeTriggers::Teleop() {
|
||||
return Trigger{&frc::DriverStation::IsTeleopEnabled};
|
||||
return Trigger{&wpi::DriverStation::IsTeleopEnabled};
|
||||
}
|
||||
|
||||
Trigger RobotModeTriggers::Disabled() {
|
||||
return Trigger{&frc::DriverStation::IsDisabled};
|
||||
return Trigger{&wpi::DriverStation::IsDisabled};
|
||||
}
|
||||
|
||||
Trigger RobotModeTriggers::Test() {
|
||||
return Trigger{&frc::DriverStation::IsTestEnabled};
|
||||
return Trigger{&wpi::DriverStation::IsTestEnabled};
|
||||
}
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
#include "wpi/math/filter/Debouncer.hpp"
|
||||
|
||||
using namespace frc;
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
Trigger::Trigger(const Trigger& other) = default;
|
||||
|
||||
void Trigger::AddBinding(wpi::unique_function<void(bool, bool)>&& body) {
|
||||
void Trigger::AddBinding(wpi::util::unique_function<void(bool, bool)>&& body) {
|
||||
m_loop->Bind([condition = m_condition, previous = m_condition(),
|
||||
body = std::move(body)]() mutable {
|
||||
bool current = condition();
|
||||
@@ -28,7 +28,7 @@ void Trigger::AddBinding(wpi::unique_function<void(bool, bool)>&& body) {
|
||||
Trigger Trigger::OnChange(Command* command) {
|
||||
AddBinding([command](bool previous, bool current) {
|
||||
if (previous != current) {
|
||||
frc2::CommandScheduler::GetInstance().Schedule(command);
|
||||
wpi::cmd::CommandScheduler::GetInstance().Schedule(command);
|
||||
}
|
||||
});
|
||||
return *this;
|
||||
@@ -37,7 +37,7 @@ Trigger Trigger::OnChange(Command* command) {
|
||||
Trigger Trigger::OnChange(CommandPtr&& command) {
|
||||
AddBinding([command = std::move(command)](bool previous, bool current) {
|
||||
if (previous != current) {
|
||||
frc2::CommandScheduler::GetInstance().Schedule(command);
|
||||
wpi::cmd::CommandScheduler::GetInstance().Schedule(command);
|
||||
}
|
||||
});
|
||||
return *this;
|
||||
@@ -46,7 +46,7 @@ Trigger Trigger::OnChange(CommandPtr&& command) {
|
||||
Trigger Trigger::OnTrue(Command* command) {
|
||||
AddBinding([command](bool previous, bool current) {
|
||||
if (!previous && current) {
|
||||
frc2::CommandScheduler::GetInstance().Schedule(command);
|
||||
wpi::cmd::CommandScheduler::GetInstance().Schedule(command);
|
||||
}
|
||||
});
|
||||
return *this;
|
||||
@@ -55,7 +55,7 @@ Trigger Trigger::OnTrue(Command* command) {
|
||||
Trigger Trigger::OnTrue(CommandPtr&& command) {
|
||||
AddBinding([command = std::move(command)](bool previous, bool current) {
|
||||
if (!previous && current) {
|
||||
frc2::CommandScheduler::GetInstance().Schedule(command);
|
||||
wpi::cmd::CommandScheduler::GetInstance().Schedule(command);
|
||||
}
|
||||
});
|
||||
return *this;
|
||||
@@ -64,7 +64,7 @@ Trigger Trigger::OnTrue(CommandPtr&& command) {
|
||||
Trigger Trigger::OnFalse(Command* command) {
|
||||
AddBinding([command](bool previous, bool current) {
|
||||
if (previous && !current) {
|
||||
frc2::CommandScheduler::GetInstance().Schedule(command);
|
||||
wpi::cmd::CommandScheduler::GetInstance().Schedule(command);
|
||||
}
|
||||
});
|
||||
return *this;
|
||||
@@ -73,7 +73,7 @@ Trigger Trigger::OnFalse(Command* command) {
|
||||
Trigger Trigger::OnFalse(CommandPtr&& command) {
|
||||
AddBinding([command = std::move(command)](bool previous, bool current) {
|
||||
if (previous && !current) {
|
||||
frc2::CommandScheduler::GetInstance().Schedule(command);
|
||||
wpi::cmd::CommandScheduler::GetInstance().Schedule(command);
|
||||
}
|
||||
});
|
||||
return *this;
|
||||
@@ -82,7 +82,7 @@ Trigger Trigger::OnFalse(CommandPtr&& command) {
|
||||
Trigger Trigger::WhileTrue(Command* command) {
|
||||
AddBinding([command](bool previous, bool current) {
|
||||
if (!previous && current) {
|
||||
frc2::CommandScheduler::GetInstance().Schedule(command);
|
||||
wpi::cmd::CommandScheduler::GetInstance().Schedule(command);
|
||||
} else if (previous && !current) {
|
||||
command->Cancel();
|
||||
}
|
||||
@@ -93,7 +93,7 @@ Trigger Trigger::WhileTrue(Command* command) {
|
||||
Trigger Trigger::WhileTrue(CommandPtr&& command) {
|
||||
AddBinding([command = std::move(command)](bool previous, bool current) {
|
||||
if (!previous && current) {
|
||||
frc2::CommandScheduler::GetInstance().Schedule(command);
|
||||
wpi::cmd::CommandScheduler::GetInstance().Schedule(command);
|
||||
} else if (previous && !current) {
|
||||
command.Cancel();
|
||||
}
|
||||
@@ -104,7 +104,7 @@ Trigger Trigger::WhileTrue(CommandPtr&& command) {
|
||||
Trigger Trigger::WhileFalse(Command* command) {
|
||||
AddBinding([command](bool previous, bool current) {
|
||||
if (previous && !current) {
|
||||
frc2::CommandScheduler::GetInstance().Schedule(command);
|
||||
wpi::cmd::CommandScheduler::GetInstance().Schedule(command);
|
||||
} else if (!previous && current) {
|
||||
command->Cancel();
|
||||
}
|
||||
@@ -115,7 +115,7 @@ Trigger Trigger::WhileFalse(Command* command) {
|
||||
Trigger Trigger::WhileFalse(CommandPtr&& command) {
|
||||
AddBinding([command = std::move(command)](bool previous, bool current) {
|
||||
if (!previous && current) {
|
||||
frc2::CommandScheduler::GetInstance().Schedule(command);
|
||||
wpi::cmd::CommandScheduler::GetInstance().Schedule(command);
|
||||
} else if (previous && !current) {
|
||||
command.Cancel();
|
||||
}
|
||||
@@ -129,7 +129,7 @@ Trigger Trigger::ToggleOnTrue(Command* command) {
|
||||
if (command->IsScheduled()) {
|
||||
command->Cancel();
|
||||
} else {
|
||||
frc2::CommandScheduler::GetInstance().Schedule(command);
|
||||
wpi::cmd::CommandScheduler::GetInstance().Schedule(command);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -142,7 +142,7 @@ Trigger Trigger::ToggleOnTrue(CommandPtr&& command) {
|
||||
if (command.IsScheduled()) {
|
||||
command.Cancel();
|
||||
} else {
|
||||
frc2::CommandScheduler::GetInstance().Schedule(command);
|
||||
wpi::cmd::CommandScheduler::GetInstance().Schedule(command);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -155,7 +155,7 @@ Trigger Trigger::ToggleOnFalse(Command* command) {
|
||||
if (command->IsScheduled()) {
|
||||
command->Cancel();
|
||||
} else {
|
||||
frc2::CommandScheduler::GetInstance().Schedule(command);
|
||||
wpi::cmd::CommandScheduler::GetInstance().Schedule(command);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -168,16 +168,16 @@ Trigger Trigger::ToggleOnFalse(CommandPtr&& command) {
|
||||
if (command.IsScheduled()) {
|
||||
command.Cancel();
|
||||
} else {
|
||||
frc2::CommandScheduler::GetInstance().Schedule(command);
|
||||
wpi::cmd::CommandScheduler::GetInstance().Schedule(command);
|
||||
}
|
||||
}
|
||||
});
|
||||
return *this;
|
||||
}
|
||||
|
||||
Trigger Trigger::Debounce(units::second_t debounceTime,
|
||||
frc::Debouncer::DebounceType type) {
|
||||
return Trigger(m_loop, [debouncer = frc::Debouncer(debounceTime, type),
|
||||
Trigger Trigger::Debounce(wpi::units::second_t debounceTime,
|
||||
wpi::math::Debouncer::DebounceType type) {
|
||||
return Trigger(m_loop, [debouncer = wpi::math::Debouncer(debounceTime, type),
|
||||
condition = m_condition]() mutable {
|
||||
return debouncer.Calculate(condition());
|
||||
});
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
|
||||
#include "wpi/sysid/SysIdRoutineLog.hpp"
|
||||
|
||||
using namespace frc2::sysid;
|
||||
using namespace wpi::cmd::sysid;
|
||||
|
||||
frc2::CommandPtr SysIdRoutine::Quasistatic(Direction direction) {
|
||||
frc::sysid::State state;
|
||||
wpi::cmd::CommandPtr SysIdRoutine::Quasistatic(Direction direction) {
|
||||
wpi::sysid::State state;
|
||||
if (direction == Direction::kForward) {
|
||||
state = frc::sysid::State::kQuasistaticForward;
|
||||
state = wpi::sysid::State::kQuasistaticForward;
|
||||
} else { // if (direction == Direction::kReverse) {
|
||||
state = frc::sysid::State::kQuasistaticReverse;
|
||||
state = wpi::sysid::State::kQuasistaticReverse;
|
||||
}
|
||||
|
||||
double outputSign = direction == Direction::kForward ? 1.0 : -1.0;
|
||||
@@ -29,21 +29,21 @@ frc2::CommandPtr SysIdRoutine::Quasistatic(Direction direction) {
|
||||
})
|
||||
.FinallyDo([this] {
|
||||
m_mechanism.m_drive(0_V);
|
||||
m_recordState(frc::sysid::State::kNone);
|
||||
m_recordState(wpi::sysid::State::kNone);
|
||||
timer.Stop();
|
||||
})
|
||||
.WithName("sysid-" +
|
||||
frc::sysid::SysIdRoutineLog::StateEnumToString(state) +
|
||||
wpi::sysid::SysIdRoutineLog::StateEnumToString(state) +
|
||||
"-" + m_mechanism.m_name)
|
||||
.WithTimeout(m_config.m_timeout));
|
||||
}
|
||||
|
||||
frc2::CommandPtr SysIdRoutine::Dynamic(Direction direction) {
|
||||
frc::sysid::State state;
|
||||
wpi::cmd::CommandPtr SysIdRoutine::Dynamic(Direction direction) {
|
||||
wpi::sysid::State state;
|
||||
if (direction == Direction::kForward) {
|
||||
state = frc::sysid::State::kDynamicForward;
|
||||
state = wpi::sysid::State::kDynamicForward;
|
||||
} else { // if (direction == Direction::kReverse) {
|
||||
state = frc::sysid::State::kDynamicReverse;
|
||||
state = wpi::sysid::State::kDynamicReverse;
|
||||
}
|
||||
|
||||
double outputSign = direction == Direction::kForward ? 1.0 : -1.0;
|
||||
@@ -57,10 +57,10 @@ frc2::CommandPtr SysIdRoutine::Dynamic(Direction direction) {
|
||||
}))
|
||||
.FinallyDo([this] {
|
||||
m_mechanism.m_drive(0_V);
|
||||
m_recordState(frc::sysid::State::kNone);
|
||||
m_recordState(wpi::sysid::State::kNone);
|
||||
})
|
||||
.WithName("sysid-" +
|
||||
frc::sysid::SysIdRoutineLog::StateEnumToString(state) + "-" +
|
||||
wpi::sysid::SysIdRoutineLog::StateEnumToString(state) + "-" +
|
||||
m_mechanism.m_name)
|
||||
.WithTimeout(m_config.m_timeout);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "wpi/util/StackTrace.hpp"
|
||||
#include "wpi/util/sendable/Sendable.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
|
||||
/**
|
||||
* A state machine representing a complete action to be performed by the robot.
|
||||
@@ -37,7 +37,7 @@ namespace frc2 {
|
||||
* @see CommandScheduler
|
||||
* @see CommandHelper
|
||||
*/
|
||||
class Command : public wpi::Sendable, public wpi::SendableHelper<Command> {
|
||||
class Command : public wpi::util::Sendable, public wpi::util::SendableHelper<Command> {
|
||||
public:
|
||||
~Command() override;
|
||||
|
||||
@@ -87,7 +87,7 @@ class Command : public wpi::Sendable, public wpi::SendableHelper<Command> {
|
||||
* @return the set of subsystems that are required
|
||||
* @see InterruptionBehavior
|
||||
*/
|
||||
virtual wpi::SmallSet<Subsystem*, 4> GetRequirements() const;
|
||||
virtual wpi::util::SmallSet<Subsystem*, 4> GetRequirements() const;
|
||||
|
||||
/**
|
||||
* Adds the specified Subsystem requirements to the command.
|
||||
@@ -121,7 +121,7 @@ class Command : public wpi::Sendable, public wpi::SendableHelper<Command> {
|
||||
*
|
||||
* @param requirements the Subsystem requirements to add
|
||||
*/
|
||||
void AddRequirements(wpi::SmallSet<Subsystem*, 4> requirements);
|
||||
void AddRequirements(wpi::util::SmallSet<Subsystem*, 4> requirements);
|
||||
|
||||
/**
|
||||
* Adds the specified Subsystem requirement to the command.
|
||||
@@ -191,7 +191,7 @@ class Command : public wpi::Sendable, public wpi::SendableHelper<Command> {
|
||||
* @param duration the timeout duration
|
||||
* @return the command with the timeout added
|
||||
*/
|
||||
CommandPtr WithTimeout(units::second_t duration) &&;
|
||||
CommandPtr WithTimeout(wpi::units::second_t duration) &&;
|
||||
|
||||
/**
|
||||
* Decorates this command with an interrupt condition. If the specified
|
||||
@@ -473,14 +473,14 @@ class Command : public wpi::Sendable, public wpi::SendableHelper<Command> {
|
||||
*/
|
||||
virtual CommandPtr ToPtr() && = 0;
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::util::SendableBuilder& builder) override;
|
||||
|
||||
protected:
|
||||
Command();
|
||||
|
||||
private:
|
||||
/// Requirements set.
|
||||
wpi::SmallSet<Subsystem*, 4> m_requirements;
|
||||
wpi::util::SmallSet<Subsystem*, 4> m_requirements;
|
||||
|
||||
std::optional<std::string> m_previousComposition;
|
||||
};
|
||||
@@ -493,4 +493,4 @@ class Command : public wpi::Sendable, public wpi::SendableHelper<Command> {
|
||||
* @return False if first and second share a requirement.
|
||||
*/
|
||||
bool RequirementsDisjoint(Command* first, Command* second);
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "wpi/commands2/Command.hpp"
|
||||
#include "wpi/commands2/CommandPtr.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
|
||||
/**
|
||||
* CRTP implementation to allow polymorphic decorator functions in Command.
|
||||
@@ -33,4 +33,4 @@ class CommandHelper : public Base {
|
||||
std::make_unique<CRTP>(std::move(*static_cast<CRTP*>(this))));
|
||||
}
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "wpi/commands2/Command.hpp"
|
||||
#include "wpi/commands2/Requirements.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* A wrapper around std::unique_ptr<Command> so commands have move-only
|
||||
* semantics. Commands should only be stored and passed around when held in a
|
||||
@@ -125,7 +125,7 @@ class [[nodiscard]] CommandPtr final {
|
||||
* @param duration the timeout duration
|
||||
* @return the command with the timeout added
|
||||
*/
|
||||
CommandPtr WithTimeout(units::second_t duration) &&;
|
||||
CommandPtr WithTimeout(wpi::units::second_t duration) &&;
|
||||
|
||||
/**
|
||||
* Decorates this command with an interrupt condition. If the specified
|
||||
@@ -339,4 +339,4 @@ class [[nodiscard]] CommandPtr final {
|
||||
void AssertValid() const;
|
||||
};
|
||||
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "wpi/util/sendable/Sendable.hpp"
|
||||
#include "wpi/util/sendable/SendableHelper.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
class Command;
|
||||
class CommandPtr;
|
||||
class Subsystem;
|
||||
@@ -34,8 +34,8 @@ class Subsystem;
|
||||
*
|
||||
* This class is provided by the NewCommands VendorDep
|
||||
*/
|
||||
class CommandScheduler final : public wpi::Sendable,
|
||||
public wpi::SendableHelper<CommandScheduler> {
|
||||
class CommandScheduler final : public wpi::util::Sendable,
|
||||
public wpi::util::SendableHelper<CommandScheduler> {
|
||||
public:
|
||||
/**
|
||||
* Returns the Scheduler instance.
|
||||
@@ -56,30 +56,30 @@ class CommandScheduler final : public wpi::Sendable,
|
||||
* Changes the period of the loop overrun watchdog. This should be kept in
|
||||
* sync with the TimedRobot period.
|
||||
*/
|
||||
void SetPeriod(units::second_t period);
|
||||
void SetPeriod(wpi::units::second_t period);
|
||||
|
||||
/**
|
||||
* Get the active button poll.
|
||||
*
|
||||
* @return a reference to the current {@link frc::EventLoop} object polling
|
||||
* @return a reference to the current {@link wpi::EventLoop} object polling
|
||||
* buttons.
|
||||
*/
|
||||
frc::EventLoop* GetActiveButtonLoop() const;
|
||||
wpi::EventLoop* GetActiveButtonLoop() const;
|
||||
|
||||
/**
|
||||
* Replace the button poll with another one.
|
||||
*
|
||||
* @param loop the new button polling loop object.
|
||||
*/
|
||||
void SetActiveButtonLoop(frc::EventLoop* loop);
|
||||
void SetActiveButtonLoop(wpi::EventLoop* loop);
|
||||
|
||||
/**
|
||||
* Get the default button poll.
|
||||
*
|
||||
* @return a reference to the default {@link frc::EventLoop} object polling
|
||||
* @return a reference to the default {@link wpi::EventLoop} object polling
|
||||
* buttons.
|
||||
*/
|
||||
frc::EventLoop* GetDefaultButtonLoop() const;
|
||||
wpi::EventLoop* GetDefaultButtonLoop() const;
|
||||
|
||||
/**
|
||||
* Schedules a command for execution. Does nothing if the command is already
|
||||
@@ -212,7 +212,7 @@ class CommandScheduler final : public wpi::Sendable,
|
||||
template <std::derived_from<Command> T>
|
||||
void SetDefaultCommand(Subsystem* subsystem, T&& defaultCommand) {
|
||||
if (!defaultCommand.HasRequirement(subsystem)) {
|
||||
throw FRC_MakeError(frc::err::CommandIllegalUse,
|
||||
throw FRC_MakeError(wpi::err::CommandIllegalUse,
|
||||
"Default commands must require their subsystem!");
|
||||
}
|
||||
SetDefaultCommandImpl(subsystem, std::make_unique<std::decay_t<T>>(
|
||||
@@ -467,7 +467,7 @@ class CommandScheduler final : public wpi::Sendable,
|
||||
void RequireUngroupedAndUnscheduled(
|
||||
std::initializer_list<const Command*> commands);
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::util::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
// Constructor; private as this is a singleton
|
||||
@@ -481,11 +481,11 @@ class CommandScheduler final : public wpi::Sendable,
|
||||
class Impl;
|
||||
std::unique_ptr<Impl> m_impl;
|
||||
|
||||
frc::Watchdog m_watchdog;
|
||||
wpi::Watchdog m_watchdog;
|
||||
|
||||
friend class CommandTestBase;
|
||||
|
||||
template <typename T>
|
||||
friend class CommandTestBaseWithParam;
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "wpi/commands2/SelectCommand.hpp"
|
||||
#include "wpi/util/deprecated.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
class Subsystem;
|
||||
|
||||
/**
|
||||
@@ -104,7 +104,7 @@ CommandPtr Print(std::string_view msg);
|
||||
*
|
||||
* @param duration after how long the command finishes
|
||||
*/
|
||||
CommandPtr Wait(units::second_t duration);
|
||||
CommandPtr Wait(wpi::units::second_t duration);
|
||||
|
||||
/**
|
||||
* Constructs a command that does nothing, finishing once a condition becomes
|
||||
@@ -149,7 +149,7 @@ CommandPtr Select(std::function<Key()> selector,
|
||||
* @param supplier the command supplier
|
||||
* @param requirements the set of requirements for this command
|
||||
*/
|
||||
CommandPtr Defer(wpi::unique_function<CommandPtr()> supplier,
|
||||
CommandPtr Defer(wpi::util::unique_function<CommandPtr()> supplier,
|
||||
Requirements requirements);
|
||||
|
||||
/**
|
||||
@@ -159,7 +159,7 @@ CommandPtr Defer(wpi::unique_function<CommandPtr()> supplier,
|
||||
*
|
||||
* @param supplier the command supplier
|
||||
*/
|
||||
CommandPtr DeferredProxy(wpi::unique_function<Command*()> supplier);
|
||||
CommandPtr DeferredProxy(wpi::util::unique_function<Command*()> supplier);
|
||||
|
||||
/**
|
||||
* Constructs a command that schedules the command returned from the supplier
|
||||
@@ -168,7 +168,7 @@ CommandPtr DeferredProxy(wpi::unique_function<Command*()> supplier);
|
||||
*
|
||||
* @param supplier the command supplier
|
||||
*/
|
||||
CommandPtr DeferredProxy(wpi::unique_function<CommandPtr()> supplier);
|
||||
CommandPtr DeferredProxy(wpi::util::unique_function<CommandPtr()> supplier);
|
||||
// Command Groups
|
||||
|
||||
namespace impl {
|
||||
@@ -263,4 +263,4 @@ CommandPtr Deadline(CommandPtr&& deadline, CommandPtrs&&... commands) {
|
||||
|
||||
} // namespace cmd
|
||||
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "wpi/commands2/Command.hpp"
|
||||
#include "wpi/commands2/CommandHelper.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* A command composition that runs one of two commands, depending on the value
|
||||
* of the given condition when this command is initialized.
|
||||
@@ -73,7 +73,7 @@ class ConditionalCommand : public CommandHelper<Command, ConditionalCommand> {
|
||||
|
||||
InterruptionBehavior GetInterruptionBehavior() const override;
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::util::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<Command> m_onTrue;
|
||||
@@ -82,4 +82,4 @@ class ConditionalCommand : public CommandHelper<Command, ConditionalCommand> {
|
||||
Command* m_selectedCommand{nullptr};
|
||||
bool m_runsWhenDisabled = true;
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "wpi/commands2/Requirements.hpp"
|
||||
#include "wpi/util/FunctionExtras.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* Defers Command construction to runtime. Runs the command returned by a
|
||||
* supplier when this command is initialized, and ends when it ends. Useful for
|
||||
@@ -37,7 +37,7 @@ class DeferredCommand : public CommandHelper<Command, DeferredCommand> {
|
||||
* @param requirements The command requirements.
|
||||
*
|
||||
*/
|
||||
DeferredCommand(wpi::unique_function<CommandPtr()> supplier,
|
||||
DeferredCommand(wpi::util::unique_function<CommandPtr()> supplier,
|
||||
Requirements requirements);
|
||||
|
||||
DeferredCommand(DeferredCommand&& other) = default;
|
||||
@@ -50,10 +50,10 @@ class DeferredCommand : public CommandHelper<Command, DeferredCommand> {
|
||||
|
||||
bool IsFinished() override;
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::util::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
wpi::unique_function<CommandPtr()> m_supplier;
|
||||
wpi::util::unique_function<CommandPtr()> m_supplier;
|
||||
std::unique_ptr<Command> m_command;
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "wpi/commands2/CommandHelper.hpp"
|
||||
#include "wpi/commands2/Requirements.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* A command that allows the user to pass in functions for each of the basic
|
||||
* command methods through the constructor. Useful for inline definitions of
|
||||
@@ -56,4 +56,4 @@ class FunctionalCommand : public CommandHelper<Command, FunctionalCommand> {
|
||||
std::function<void(bool)> m_onEnd;
|
||||
std::function<bool()> m_isFinished;
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "wpi/commands2/FunctionalCommand.hpp"
|
||||
#include "wpi/commands2/Requirements.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* A Command that runs instantly; it will initialize, execute once, and end on
|
||||
* the same iteration of the scheduler. Users can either pass in a Runnable and
|
||||
@@ -40,4 +40,4 @@ class InstantCommand : public CommandHelper<FunctionalCommand, InstantCommand> {
|
||||
*/
|
||||
InstantCommand();
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "wpi/system/Notifier.hpp"
|
||||
#include "wpi/units/time.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* A command that starts a notifier to run the given runnable periodically in a
|
||||
* separate thread. Has no end condition as-is; either subclass it or use
|
||||
@@ -34,7 +34,7 @@ class NotifierCommand : public CommandHelper<Command, NotifierCommand> {
|
||||
* @param period the period at which the notifier should run
|
||||
* @param requirements the subsystems required by this command
|
||||
*/
|
||||
NotifierCommand(std::function<void()> toRun, units::second_t period,
|
||||
NotifierCommand(std::function<void()> toRun, wpi::units::second_t period,
|
||||
Requirements requirements = {});
|
||||
|
||||
NotifierCommand(NotifierCommand&& other);
|
||||
@@ -47,7 +47,7 @@ class NotifierCommand : public CommandHelper<Command, NotifierCommand> {
|
||||
|
||||
private:
|
||||
std::function<void()> m_toRun;
|
||||
frc::Notifier m_notifier;
|
||||
units::second_t m_period;
|
||||
wpi::Notifier m_notifier;
|
||||
wpi::units::second_t m_period;
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "wpi/commands2/CommandHelper.hpp"
|
||||
#include "wpi/util/DecayedDerivedFrom.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* A command composition that runs a set of commands in parallel, ending when
|
||||
* the last command ends.
|
||||
@@ -51,7 +51,7 @@ class ParallelCommandGroup
|
||||
*
|
||||
* @param commands the commands to include in this composition.
|
||||
*/
|
||||
template <wpi::DecayedDerivedFrom<Command>... Commands>
|
||||
template <wpi::util::DecayedDerivedFrom<Command>... Commands>
|
||||
explicit ParallelCommandGroup(Commands&&... commands) {
|
||||
AddCommands(std::forward<Commands>(commands)...);
|
||||
}
|
||||
@@ -69,7 +69,7 @@ class ParallelCommandGroup
|
||||
*
|
||||
* @param commands Commands to add to the group.
|
||||
*/
|
||||
template <wpi::DecayedDerivedFrom<Command>... Commands>
|
||||
template <wpi::util::DecayedDerivedFrom<Command>... Commands>
|
||||
void AddCommands(Commands&&... commands) {
|
||||
std::vector<std::unique_ptr<Command>> foo;
|
||||
((void)foo.emplace_back(std::make_unique<std::decay_t<Commands>>(
|
||||
@@ -99,7 +99,7 @@ class ParallelCommandGroup
|
||||
Command::InterruptionBehavior::kCancelIncoming};
|
||||
bool isRunning = false;
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma warning(pop)
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "wpi/commands2/CommandHelper.hpp"
|
||||
#include "wpi/util/DecayedDerivedFrom.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* A command composition that runs a set of commands in parallel, ending only
|
||||
* when a specific command (the "deadline") ends, interrupting all other
|
||||
@@ -55,8 +55,8 @@ class ParallelDeadlineGroup
|
||||
* @param deadline the command that determines when the composition ends
|
||||
* @param commands the commands to be executed
|
||||
*/
|
||||
template <wpi::DecayedDerivedFrom<Command> T,
|
||||
wpi::DecayedDerivedFrom<Command>... Commands>
|
||||
template <wpi::util::DecayedDerivedFrom<Command> T,
|
||||
wpi::util::DecayedDerivedFrom<Command>... Commands>
|
||||
explicit ParallelDeadlineGroup(T&& deadline, Commands&&... commands) {
|
||||
SetDeadline(std::make_unique<std::decay_t<T>>(std::forward<T>(deadline)));
|
||||
AddCommands(std::forward<Commands>(commands)...);
|
||||
@@ -75,7 +75,7 @@ class ParallelDeadlineGroup
|
||||
*
|
||||
* @param commands Commands to add to the group.
|
||||
*/
|
||||
template <wpi::DecayedDerivedFrom<Command>... Commands>
|
||||
template <wpi::util::DecayedDerivedFrom<Command>... Commands>
|
||||
void AddCommands(Commands&&... commands) {
|
||||
std::vector<std::unique_ptr<Command>> foo;
|
||||
((void)foo.emplace_back(std::make_unique<std::decay_t<Commands>>(
|
||||
@@ -96,7 +96,7 @@ class ParallelDeadlineGroup
|
||||
|
||||
Command::InterruptionBehavior GetInterruptionBehavior() const override;
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::util::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
void AddCommands(std::vector<std::unique_ptr<Command>>&& commands);
|
||||
@@ -110,7 +110,7 @@ class ParallelDeadlineGroup
|
||||
Command::InterruptionBehavior::kCancelIncoming};
|
||||
bool m_finished{true};
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma warning(pop)
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "wpi/commands2/CommandHelper.hpp"
|
||||
#include "wpi/util/DecayedDerivedFrom.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* A composition that runs a set of commands in parallel, ending when any one of
|
||||
* the commands ends and interrupting all the others.
|
||||
@@ -40,7 +40,7 @@ class ParallelRaceGroup : public CommandHelper<Command, ParallelRaceGroup> {
|
||||
*/
|
||||
explicit ParallelRaceGroup(std::vector<std::unique_ptr<Command>>&& commands);
|
||||
|
||||
template <wpi::DecayedDerivedFrom<Command>... Commands>
|
||||
template <wpi::util::DecayedDerivedFrom<Command>... Commands>
|
||||
explicit ParallelRaceGroup(Commands&&... commands) {
|
||||
AddCommands(std::forward<Commands>(commands)...);
|
||||
}
|
||||
@@ -58,7 +58,7 @@ class ParallelRaceGroup : public CommandHelper<Command, ParallelRaceGroup> {
|
||||
*
|
||||
* @param commands Commands to add to the group.
|
||||
*/
|
||||
template <wpi::DecayedDerivedFrom<Command>... Commands>
|
||||
template <wpi::util::DecayedDerivedFrom<Command>... Commands>
|
||||
void AddCommands(Commands&&... commands) {
|
||||
std::vector<std::unique_ptr<Command>> foo;
|
||||
((void)foo.emplace_back(std::make_unique<std::decay_t<Commands>>(
|
||||
@@ -89,7 +89,7 @@ class ParallelRaceGroup : public CommandHelper<Command, ParallelRaceGroup> {
|
||||
bool m_finished{false};
|
||||
bool isRunning = false;
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma warning(pop)
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "wpi/commands2/CommandHelper.hpp"
|
||||
#include "wpi/commands2/InstantCommand.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* A command that prints a string when initialized.
|
||||
*
|
||||
@@ -30,4 +30,4 @@ class PrintCommand : public CommandHelper<InstantCommand, PrintCommand> {
|
||||
|
||||
bool RunsWhenDisabled() const override;
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "wpi/util/FunctionExtras.hpp"
|
||||
#include "wpi/util/deprecated.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* Schedules a given command when this command is initialized and ends when it
|
||||
* ends, but does not directly run it. Use this for including a command in a
|
||||
@@ -45,7 +45,7 @@ class ProxyCommand : public CommandHelper<Command, ProxyCommand> {
|
||||
*/
|
||||
WPI_IGNORE_DEPRECATED
|
||||
[[deprecated("Defer a proxy command instead.")]]
|
||||
explicit ProxyCommand(wpi::unique_function<Command*()> supplier);
|
||||
explicit ProxyCommand(wpi::util::unique_function<Command*()> supplier);
|
||||
|
||||
/**
|
||||
* Creates a new ProxyCommand that schedules the supplied command when
|
||||
@@ -64,7 +64,7 @@ class ProxyCommand : public CommandHelper<Command, ProxyCommand> {
|
||||
* @see DeferredCommand
|
||||
*/
|
||||
[[deprecated("Defer a proxy command instead.")]]
|
||||
explicit ProxyCommand(wpi::unique_function<CommandPtr()> supplier);
|
||||
explicit ProxyCommand(wpi::util::unique_function<CommandPtr()> supplier);
|
||||
WPI_UNIGNORE_DEPRECATED
|
||||
|
||||
/**
|
||||
@@ -94,10 +94,10 @@ class ProxyCommand : public CommandHelper<Command, ProxyCommand> {
|
||||
|
||||
bool IsFinished() override;
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::util::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
wpi::unique_function<Command*()> m_supplier;
|
||||
wpi::util::unique_function<Command*()> m_supplier;
|
||||
Command* m_command = nullptr;
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "wpi/commands2/Command.hpp"
|
||||
#include "wpi/commands2/CommandHelper.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* A command that runs another command repeatedly, restarting it when it ends,
|
||||
* until this command is interrupted. Command instances that are passed to it
|
||||
@@ -71,13 +71,13 @@ class RepeatCommand : public CommandHelper<Command, RepeatCommand> {
|
||||
|
||||
Command::InterruptionBehavior GetInterruptionBehavior() const override;
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::util::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<Command> m_command;
|
||||
bool m_ended;
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma warning(pop)
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#include "wpi/commands2/Subsystem.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
|
||||
/**
|
||||
* Represents requirements for a command, which is a set of (pointers to)
|
||||
@@ -43,4 +43,4 @@ class Requirements {
|
||||
std::vector<Subsystem*> m_subsystems;
|
||||
};
|
||||
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "wpi/commands2/FunctionalCommand.hpp"
|
||||
#include "wpi/commands2/Requirements.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* A command that runs a Runnable continuously. Has no end condition as-is;
|
||||
* either subclass it or use Command.WithTimeout() or
|
||||
@@ -35,4 +35,4 @@ class RunCommand : public CommandHelper<FunctionalCommand, RunCommand> {
|
||||
|
||||
RunCommand(const RunCommand& other) = default;
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "wpi/commands2/CommandHelper.hpp"
|
||||
#include "wpi/util/SmallSet.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* Schedules the given commands when this command is initialized. Useful for
|
||||
* forking off from CommandGroups. Note that if run from a composition, the
|
||||
@@ -42,6 +42,6 @@ class ScheduleCommand : public CommandHelper<Command, ScheduleCommand> {
|
||||
bool RunsWhenDisabled() const override;
|
||||
|
||||
private:
|
||||
wpi::SmallSet<Command*, 4> m_toSchedule;
|
||||
wpi::util::SmallSet<Command*, 4> m_toSchedule;
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "wpi/commands2/PrintCommand.hpp"
|
||||
#include "wpi/util/sendable/SendableBuilder.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* A command composition that runs one of a selection of commands using a
|
||||
* selector and a key to command mapping.
|
||||
@@ -117,7 +117,7 @@ class SelectCommand : public CommandHelper<Command, SelectCommand<Key>> {
|
||||
return m_interruptBehavior;
|
||||
}
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override {
|
||||
void InitSendable(wpi::util::SendableBuilder& builder) override {
|
||||
Command::InitSendable(builder);
|
||||
|
||||
builder.AddStringProperty(
|
||||
@@ -155,7 +155,7 @@ void SelectCommand<T>::Initialize() {
|
||||
m_selectedCommand->Initialize();
|
||||
}
|
||||
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma warning(pop)
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "wpi/commands2/CommandHelper.hpp"
|
||||
#include "wpi/util/DecayedDerivedFrom.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
|
||||
const size_t invalid_index = std::numeric_limits<size_t>::max();
|
||||
|
||||
@@ -52,7 +52,7 @@ class SequentialCommandGroup
|
||||
*
|
||||
* @param commands the commands to include in this composition.
|
||||
*/
|
||||
template <wpi::DecayedDerivedFrom<Command>... Commands>
|
||||
template <wpi::util::DecayedDerivedFrom<Command>... Commands>
|
||||
explicit SequentialCommandGroup(Commands&&... commands) {
|
||||
AddCommands(std::forward<Commands>(commands)...);
|
||||
}
|
||||
@@ -70,7 +70,7 @@ class SequentialCommandGroup
|
||||
*
|
||||
* @param commands Commands to add, in order of execution.
|
||||
*/
|
||||
template <wpi::DecayedDerivedFrom<Command>... Commands>
|
||||
template <wpi::util::DecayedDerivedFrom<Command>... Commands>
|
||||
void AddCommands(Commands&&... commands) {
|
||||
std::vector<std::unique_ptr<Command>> foo;
|
||||
((void)foo.emplace_back(std::make_unique<std::decay_t<Commands>>(
|
||||
@@ -91,18 +91,18 @@ class SequentialCommandGroup
|
||||
|
||||
Command::InterruptionBehavior GetInterruptionBehavior() const override;
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::util::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
void AddCommands(std::vector<std::unique_ptr<Command>>&& commands);
|
||||
|
||||
wpi::SmallVector<std::unique_ptr<Command>, 4> m_commands;
|
||||
wpi::util::SmallVector<std::unique_ptr<Command>, 4> m_commands;
|
||||
size_t m_currentCommandIndex{invalid_index};
|
||||
bool m_runWhenDisabled{true};
|
||||
Command::InterruptionBehavior m_interruptBehavior{
|
||||
Command::InterruptionBehavior::kCancelIncoming};
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma warning(pop)
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "wpi/commands2/FunctionalCommand.hpp"
|
||||
#include "wpi/commands2/Requirements.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* A command that runs a given runnable when it is initialized, and another
|
||||
* runnable when it ends. Useful for running and then stopping a motor, or
|
||||
@@ -38,4 +38,4 @@ class StartEndCommand
|
||||
|
||||
StartEndCommand(const StartEndCommand& other) = default;
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "wpi/commands2/CommandScheduler.hpp"
|
||||
#include "wpi/util/FunctionExtras.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
class Command;
|
||||
class CommandPtr;
|
||||
/**
|
||||
@@ -179,6 +179,6 @@ class Subsystem {
|
||||
* @param supplier the command supplier.
|
||||
* @return the command.
|
||||
*/
|
||||
CommandPtr Defer(wpi::unique_function<CommandPtr()> supplier);
|
||||
CommandPtr Defer(wpi::util::unique_function<CommandPtr()> supplier);
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "wpi/util/sendable/Sendable.hpp"
|
||||
#include "wpi/util/sendable/SendableHelper.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* A base for subsystems that handles registration in the constructor, and
|
||||
* provides a more intuitive method for setting the default command.
|
||||
@@ -19,10 +19,10 @@ namespace frc2 {
|
||||
* This class is provided by the NewCommands VendorDep
|
||||
*/
|
||||
class SubsystemBase : public Subsystem,
|
||||
public wpi::Sendable,
|
||||
public wpi::SendableHelper<SubsystemBase> {
|
||||
public wpi::util::Sendable,
|
||||
public wpi::util::SendableHelper<SubsystemBase> {
|
||||
public:
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::util::SendableBuilder& builder) override;
|
||||
|
||||
/**
|
||||
* Gets the name of this Subsystem.
|
||||
@@ -59,7 +59,7 @@ class SubsystemBase : public Subsystem,
|
||||
* @param name name to give child
|
||||
* @param child sendable
|
||||
*/
|
||||
void AddChild(std::string name, wpi::Sendable* child);
|
||||
void AddChild(std::string name, wpi::util::Sendable* child);
|
||||
|
||||
protected:
|
||||
/**
|
||||
@@ -73,4 +73,4 @@ class SubsystemBase : public Subsystem,
|
||||
*/
|
||||
explicit SubsystemBase(std::string_view name);
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "wpi/system/Timer.hpp"
|
||||
#include "wpi/units/time.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* A command that does nothing but takes a specified amount of time to finish.
|
||||
*
|
||||
@@ -23,7 +23,7 @@ class WaitCommand : public CommandHelper<Command, WaitCommand> {
|
||||
*
|
||||
* @param duration the time to wait
|
||||
*/
|
||||
explicit WaitCommand(units::second_t duration);
|
||||
explicit WaitCommand(wpi::units::second_t duration);
|
||||
|
||||
WaitCommand(WaitCommand&& other) = default;
|
||||
|
||||
@@ -37,13 +37,13 @@ class WaitCommand : public CommandHelper<Command, WaitCommand> {
|
||||
|
||||
bool RunsWhenDisabled() const override;
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::util::SendableBuilder& builder) override;
|
||||
|
||||
protected:
|
||||
/// The timer used for waiting.
|
||||
frc::Timer m_timer;
|
||||
wpi::Timer m_timer;
|
||||
|
||||
private:
|
||||
units::second_t m_duration;
|
||||
wpi::units::second_t m_duration;
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "wpi/commands2/CommandHelper.hpp"
|
||||
#include "wpi/units/time.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* A command that does nothing but ends after a specified match time or
|
||||
* condition. Useful for CommandGroups.
|
||||
@@ -37,7 +37,7 @@ class WaitUntilCommand : public CommandHelper<Command, WaitUntilCommand> {
|
||||
*
|
||||
* @param time the match time after which to end, in seconds
|
||||
*/
|
||||
explicit WaitUntilCommand(units::second_t time);
|
||||
explicit WaitUntilCommand(wpi::units::second_t time);
|
||||
|
||||
WaitUntilCommand(WaitUntilCommand&& other) = default;
|
||||
|
||||
@@ -50,4 +50,4 @@ class WaitUntilCommand : public CommandHelper<Command, WaitUntilCommand> {
|
||||
private:
|
||||
std::function<bool()> m_condition;
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "wpi/commands2/Command.hpp"
|
||||
#include "wpi/commands2/CommandHelper.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* A class used internally to wrap commands while overriding a specific method;
|
||||
* all other methods will call through to the wrapped command.
|
||||
@@ -66,13 +66,13 @@ class WrapperCommand : public CommandHelper<Command, WrapperCommand> {
|
||||
|
||||
InterruptionBehavior GetInterruptionBehavior() const override;
|
||||
|
||||
wpi::SmallSet<Subsystem*, 4> GetRequirements() const override;
|
||||
wpi::util::SmallSet<Subsystem*, 4> GetRequirements() const override;
|
||||
|
||||
protected:
|
||||
/// Command being wrapped.
|
||||
std::unique_ptr<Command> m_command;
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma warning(pop)
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
#include "wpi/commands2/button/Trigger.hpp"
|
||||
#include "wpi/driverstation/Gamepad.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* A version of {@link frc::Gamepad} with {@link Trigger} factories for
|
||||
* A version of {@link wpi::Gamepad} with {@link Trigger} factories for
|
||||
* command-based.
|
||||
*
|
||||
* @see frc::Gamepad
|
||||
* @see wpi::Gamepad
|
||||
*/
|
||||
class CommandGamepad : public CommandGenericHID {
|
||||
public:
|
||||
@@ -30,7 +30,7 @@ class CommandGamepad : public CommandGenericHID {
|
||||
*
|
||||
* @return the wrapped GenericHID object
|
||||
*/
|
||||
frc::Gamepad& GetHID();
|
||||
wpi::Gamepad& GetHID();
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the South Face button's
|
||||
@@ -41,7 +41,7 @@ class CommandGamepad : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the South Face button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger SouthFace(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger SouthFace(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -53,7 +53,7 @@ class CommandGamepad : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the East Face button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger EastFace(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger EastFace(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -65,7 +65,7 @@ class CommandGamepad : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the West Face button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger WestFace(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger WestFace(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -77,7 +77,7 @@ class CommandGamepad : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the North Face button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger NorthFace(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger NorthFace(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -89,7 +89,7 @@ class CommandGamepad : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the Back button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger Back(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger Back(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -101,7 +101,7 @@ class CommandGamepad : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the Guide button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger Guide(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger Guide(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -113,7 +113,7 @@ class CommandGamepad : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the Start button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger Start(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger Start(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -125,7 +125,7 @@ class CommandGamepad : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the left stick button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger LeftStick(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger LeftStick(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -137,7 +137,7 @@ class CommandGamepad : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the right stick button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger RightStick(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger RightStick(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -150,7 +150,7 @@ class CommandGamepad : public CommandGenericHID {
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger LeftShoulder(
|
||||
frc::EventLoop* loop =
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -163,7 +163,7 @@ class CommandGamepad : public CommandGenericHID {
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger RightShoulder(
|
||||
frc::EventLoop* loop =
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -175,7 +175,7 @@ class CommandGamepad : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the D-pad up button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger DpadUp(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger DpadUp(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -187,7 +187,7 @@ class CommandGamepad : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the D-pad down button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger DpadDown(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger DpadDown(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -199,7 +199,7 @@ class CommandGamepad : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the D-pad left button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger DpadLeft(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger DpadLeft(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -211,7 +211,7 @@ class CommandGamepad : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the D-pad right button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger DpadRight(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger DpadRight(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -223,7 +223,7 @@ class CommandGamepad : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the Miscellaneous 1 button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger Misc1(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger Misc1(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -236,7 +236,7 @@ class CommandGamepad : public CommandGenericHID {
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger RightPaddle1(
|
||||
frc::EventLoop* loop =
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -248,7 +248,7 @@ class CommandGamepad : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the Left Paddle 1 button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger LeftPaddle1(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger LeftPaddle1(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -261,7 +261,7 @@ class CommandGamepad : public CommandGenericHID {
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger RightPaddle2(
|
||||
frc::EventLoop* loop =
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -273,7 +273,7 @@ class CommandGamepad : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the Left Paddle 2 button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger LeftPaddle2(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger LeftPaddle2(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -285,7 +285,7 @@ class CommandGamepad : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the Touchpad button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger Touchpad(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger Touchpad(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -297,7 +297,7 @@ class CommandGamepad : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the Miscellaneous 2 button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger Misc2(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger Misc2(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -309,7 +309,7 @@ class CommandGamepad : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the Miscellaneous 3 button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger Misc3(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger Misc3(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -321,7 +321,7 @@ class CommandGamepad : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the Miscellaneous 4 button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger Misc4(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger Misc4(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -333,7 +333,7 @@ class CommandGamepad : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the Miscellaneous 5 button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger Misc5(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger Misc5(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -345,7 +345,7 @@ class CommandGamepad : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the Miscellaneous 6 button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger Misc6(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger Misc6(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -362,7 +362,7 @@ class CommandGamepad : public CommandGenericHID {
|
||||
* exceeds the provided threshold, attached to the given loop
|
||||
*/
|
||||
Trigger LeftTrigger(double threshold = 0.5,
|
||||
frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -380,7 +380,7 @@ class CommandGamepad : public CommandGenericHID {
|
||||
*/
|
||||
Trigger RightTrigger(
|
||||
double threshold = 0.5,
|
||||
frc::EventLoop* loop =
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -428,6 +428,6 @@ class CommandGamepad : public CommandGenericHID {
|
||||
double GetRightTriggerAxis() const;
|
||||
|
||||
private:
|
||||
frc::Gamepad m_hid;
|
||||
wpi::Gamepad m_hid;
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
#include "wpi/driverstation/DriverStation.hpp"
|
||||
#include "wpi/driverstation/GenericHID.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
|
||||
/**
|
||||
* A version of {@link frc::GenericHID} with {@link Trigger} factories for
|
||||
* A version of {@link wpi::GenericHID} with {@link Trigger} factories for
|
||||
* command-based.
|
||||
*
|
||||
* @see GenericHID
|
||||
@@ -32,7 +32,7 @@ class CommandGenericHID {
|
||||
*
|
||||
* @return the wrapped GenericHID object
|
||||
*/
|
||||
frc::GenericHID& GetHID();
|
||||
wpi::GenericHID& GetHID();
|
||||
|
||||
/**
|
||||
* Constructs an event instance around this button's digital signal.
|
||||
@@ -44,7 +44,7 @@ class CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
Trigger Button(int button,
|
||||
frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -56,8 +56,8 @@ class CommandGenericHID {
|
||||
* @param angle POV angle.
|
||||
* @return a Trigger instance based around this angle of a POV on the HID.
|
||||
*/
|
||||
Trigger POV(frc::DriverStation::POVDirection angle,
|
||||
frc::EventLoop* loop =
|
||||
Trigger POV(wpi::DriverStation::POVDirection angle,
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -70,8 +70,8 @@ class CommandGenericHID {
|
||||
* @param angle POV angle.
|
||||
* @return a Trigger instance based around this angle of a POV on the HID.
|
||||
*/
|
||||
Trigger POV(int pov, frc::DriverStation::POVDirection angle,
|
||||
frc::EventLoop* loop =
|
||||
Trigger POV(int pov, wpi::DriverStation::POVDirection angle,
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -84,7 +84,7 @@ class CommandGenericHID {
|
||||
* @return a Trigger instance based around the up direction of a POV on the
|
||||
* HID.
|
||||
*/
|
||||
Trigger POVUp(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger POVUp(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -97,7 +97,7 @@ class CommandGenericHID {
|
||||
* @return a Trigger instance based around the up right direction of a POV on
|
||||
* the HID.
|
||||
*/
|
||||
Trigger POVUpRight(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger POVUpRight(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -110,7 +110,7 @@ class CommandGenericHID {
|
||||
* @return a Trigger instance based around the right direction of a POV on the
|
||||
* HID.
|
||||
*/
|
||||
Trigger POVRight(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger POVRight(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -121,7 +121,7 @@ class CommandGenericHID {
|
||||
* on the HID.
|
||||
*/
|
||||
Trigger POVDownRight(
|
||||
frc::EventLoop* loop =
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -134,7 +134,7 @@ class CommandGenericHID {
|
||||
* @return a Trigger instance based around the down direction of a POV on
|
||||
* the HID.
|
||||
*/
|
||||
Trigger POVDown(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger POVDown(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -147,7 +147,7 @@ class CommandGenericHID {
|
||||
* @return a Trigger instance based around the down left direction of a POV on
|
||||
* the HID.
|
||||
*/
|
||||
Trigger POVDownLeft(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger POVDownLeft(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -160,7 +160,7 @@ class CommandGenericHID {
|
||||
* @return a Trigger instance based around the left direction of a POV on
|
||||
* the HID.
|
||||
*/
|
||||
Trigger POVLeft(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger POVLeft(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -173,7 +173,7 @@ class CommandGenericHID {
|
||||
* @return a Trigger instance based around the up left direction of a POV on
|
||||
* the HID.
|
||||
*/
|
||||
Trigger POVUpLeft(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger POVUpLeft(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -186,7 +186,7 @@ class CommandGenericHID {
|
||||
* @return a Trigger instance based around the center position of a POV on the
|
||||
* HID.
|
||||
*/
|
||||
Trigger POVCenter(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger POVCenter(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -204,7 +204,7 @@ class CommandGenericHID {
|
||||
*/
|
||||
Trigger AxisLessThan(
|
||||
int axis, double threshold,
|
||||
frc::EventLoop* loop =
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -222,7 +222,7 @@ class CommandGenericHID {
|
||||
*/
|
||||
Trigger AxisGreaterThan(
|
||||
int axis, double threshold,
|
||||
frc::EventLoop* loop =
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -237,7 +237,7 @@ class CommandGenericHID {
|
||||
*/
|
||||
Trigger AxisMagnitudeGreaterThan(
|
||||
int axis, double threshold,
|
||||
frc::EventLoop* loop =
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -248,7 +248,7 @@ class CommandGenericHID {
|
||||
* @param type Which rumble value to set
|
||||
* @param value The normalized value (0 to 1) to set the rumble to
|
||||
*/
|
||||
void SetRumble(frc::GenericHID::RumbleType type, double value);
|
||||
void SetRumble(wpi::GenericHID::RumbleType type, double value);
|
||||
|
||||
/**
|
||||
* Get if the HID is connected.
|
||||
@@ -258,6 +258,6 @@ class CommandGenericHID {
|
||||
bool IsConnected() const;
|
||||
|
||||
private:
|
||||
frc::GenericHID m_hid;
|
||||
wpi::GenericHID m_hid;
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
#include "wpi/commands2/button/Trigger.hpp"
|
||||
#include "wpi/driverstation/Joystick.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* A version of {@link frc::Joystick} with {@link Trigger} factories for
|
||||
* A version of {@link wpi::Joystick} with {@link Trigger} factories for
|
||||
* command-based.
|
||||
*
|
||||
* @see frc::Joystick
|
||||
* @see wpi::Joystick
|
||||
*/
|
||||
class CommandJoystick : public CommandGenericHID {
|
||||
public:
|
||||
@@ -30,7 +30,7 @@ class CommandJoystick : public CommandGenericHID {
|
||||
*
|
||||
* @return the wrapped GenericHID object
|
||||
*/
|
||||
frc::Joystick& GetHID();
|
||||
wpi::Joystick& GetHID();
|
||||
|
||||
/**
|
||||
* Constructs an event instance around the trigger button's digital signal.
|
||||
@@ -41,7 +41,7 @@ class CommandJoystick : public CommandGenericHID {
|
||||
* attached to the given loop.
|
||||
*/
|
||||
class Trigger Trigger(
|
||||
frc::EventLoop* loop =
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -52,7 +52,7 @@ class CommandJoystick : public CommandGenericHID {
|
||||
* @return an event instance representing the top button's digital signal
|
||||
* attached to the given loop.
|
||||
*/
|
||||
class Trigger Top(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
class Trigger Top(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
/**
|
||||
* Get the magnitude of the vector formed by the joystick's
|
||||
@@ -69,9 +69,9 @@ class CommandJoystick : public CommandGenericHID {
|
||||
*
|
||||
* @return The direction of the vector.
|
||||
*/
|
||||
units::radian_t GetDirection() const;
|
||||
wpi::units::radian_t GetDirection() const;
|
||||
|
||||
private:
|
||||
frc::Joystick m_hid;
|
||||
wpi::Joystick m_hid;
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "wpi/commands2/button/Trigger.hpp"
|
||||
#include "wpi/driverstation/GenericHID.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* A class used to bind command scheduling to joystick button presses. Can be
|
||||
* composed with other buttons with the operators in Trigger.
|
||||
@@ -23,9 +23,9 @@ class JoystickButton : public Trigger {
|
||||
* @param joystick The joystick on which the button is located.
|
||||
* @param buttonNumber The number of the button on the joystick.
|
||||
*/
|
||||
explicit JoystickButton(frc::GenericHID* joystick, int buttonNumber)
|
||||
explicit JoystickButton(wpi::GenericHID* joystick, int buttonNumber)
|
||||
: Trigger([joystick, buttonNumber] {
|
||||
return joystick->GetRawButton(buttonNumber);
|
||||
}) {}
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "wpi/nt/NetworkTable.hpp"
|
||||
#include "wpi/nt/NetworkTableInstance.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* A Button that uses a NetworkTable boolean field.
|
||||
*
|
||||
@@ -25,14 +25,14 @@ class NetworkButton : public Trigger {
|
||||
*
|
||||
* @param topic The boolean topic that contains the value.
|
||||
*/
|
||||
explicit NetworkButton(nt::BooleanTopic topic);
|
||||
explicit NetworkButton(wpi::nt::BooleanTopic topic);
|
||||
|
||||
/**
|
||||
* Creates a NetworkButton that commands can be bound to.
|
||||
*
|
||||
* @param sub The boolean subscriber that provides the value.
|
||||
*/
|
||||
explicit NetworkButton(nt::BooleanSubscriber sub);
|
||||
explicit NetworkButton(wpi::nt::BooleanSubscriber sub);
|
||||
|
||||
/**
|
||||
* Creates a NetworkButton that commands can be bound to.
|
||||
@@ -40,7 +40,7 @@ class NetworkButton : public Trigger {
|
||||
* @param table The table where the networktable value is located.
|
||||
* @param field The field that is the value.
|
||||
*/
|
||||
NetworkButton(std::shared_ptr<nt::NetworkTable> table,
|
||||
NetworkButton(std::shared_ptr<wpi::nt::NetworkTable> table,
|
||||
std::string_view field);
|
||||
|
||||
/**
|
||||
@@ -58,7 +58,7 @@ class NetworkButton : public Trigger {
|
||||
* @param table The table where the networktable value is located.
|
||||
* @param field The field that is the value.
|
||||
*/
|
||||
NetworkButton(nt::NetworkTableInstance inst, std::string_view table,
|
||||
NetworkButton(wpi::nt::NetworkTableInstance inst, std::string_view table,
|
||||
std::string_view field);
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "wpi/driverstation/DriverStation.hpp"
|
||||
#include "wpi/driverstation/GenericHID.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* A class used to bind command scheduling to joystick POV presses. Can be
|
||||
* composed with other buttons with the operators in Trigger.
|
||||
@@ -26,10 +26,10 @@ class POVButton : public Trigger {
|
||||
* @param angle The angle of the POV corresponding to a button press.
|
||||
* @param povNumber The number of the POV on the joystick.
|
||||
*/
|
||||
POVButton(frc::GenericHID* joystick, frc::DriverStation::POVDirection angle,
|
||||
POVButton(wpi::GenericHID* joystick, wpi::DriverStation::POVDirection angle,
|
||||
int povNumber = 0)
|
||||
: Trigger([joystick, angle, povNumber] {
|
||||
return joystick->GetPOV(povNumber) == angle;
|
||||
}) {}
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include "wpi/commands2/button/Trigger.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
|
||||
/**
|
||||
* A class containing static Trigger factories for running callbacks when robot
|
||||
@@ -47,4 +47,4 @@ class RobotModeTriggers {
|
||||
static Trigger Test();
|
||||
};
|
||||
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "wpi/units/time.hpp"
|
||||
#include "wpi/util/FunctionExtras.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
class Command;
|
||||
/**
|
||||
* This class provides an easy way to link commands to conditions.
|
||||
@@ -47,7 +47,7 @@ class Trigger {
|
||||
* @param loop The loop instance that polls this trigger.
|
||||
* @param condition the condition represented by this trigger
|
||||
*/
|
||||
Trigger(frc::EventLoop* loop, std::function<bool()> condition)
|
||||
Trigger(wpi::EventLoop* loop, std::function<bool()> condition)
|
||||
: m_loop{loop}, m_condition{std::move(condition)} {}
|
||||
|
||||
/**
|
||||
@@ -279,9 +279,9 @@ class Trigger {
|
||||
* @param type The debounce type.
|
||||
* @return The debounced trigger.
|
||||
*/
|
||||
Trigger Debounce(units::second_t debounceTime,
|
||||
frc::Debouncer::DebounceType type =
|
||||
frc::Debouncer::DebounceType::kRising);
|
||||
Trigger Debounce(wpi::units::second_t debounceTime,
|
||||
wpi::math::Debouncer::DebounceType type =
|
||||
wpi::math::Debouncer::DebounceType::kRising);
|
||||
|
||||
/**
|
||||
* Returns the current state of this trigger.
|
||||
@@ -296,9 +296,9 @@ class Trigger {
|
||||
*
|
||||
* @param body The body of the binding to add.
|
||||
*/
|
||||
void AddBinding(wpi::unique_function<void(bool, bool)>&& body);
|
||||
void AddBinding(wpi::util::unique_function<void(bool, bool)>&& body);
|
||||
|
||||
frc::EventLoop* m_loop;
|
||||
wpi::EventLoop* m_loop;
|
||||
std::function<bool()> m_condition;
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
#include "wpi/sysid/SysIdRoutineLog.hpp"
|
||||
#include "wpi/system/Timer.hpp"
|
||||
|
||||
namespace frc2::sysid {
|
||||
namespace wpi::cmd::sysid {
|
||||
|
||||
using ramp_rate_t = units::unit_t<
|
||||
units::compound_unit<units::volt, units::inverse<units::second>>>;
|
||||
using ramp_rate_t = wpi::units::unit_t<
|
||||
wpi::units::compound_unit<wpi::units::volt, wpi::units::inverse<wpi::units::second>>>;
|
||||
|
||||
/** Hardware-independent configuration for a SysId test routine. */
|
||||
class Config {
|
||||
@@ -26,14 +26,14 @@ class Config {
|
||||
ramp_rate_t m_rampRate{1_V / 1_s};
|
||||
|
||||
/// The step voltage output used for dynamic test routines.
|
||||
units::volt_t m_stepVoltage{7_V};
|
||||
wpi::units::volt_t m_stepVoltage{7_V};
|
||||
|
||||
/// Safety timeout for the test routine commands.
|
||||
units::second_t m_timeout{10_s};
|
||||
wpi::units::second_t m_timeout{10_s};
|
||||
|
||||
/// Optional handle for recording test state in a third-party logging
|
||||
/// solution.
|
||||
std::function<void(frc::sysid::State)> m_recordState;
|
||||
std::function<void(wpi::sysid::State)> m_recordState;
|
||||
|
||||
/**
|
||||
* Create a new configuration for a SysId test routine.
|
||||
@@ -49,9 +49,9 @@ class Config {
|
||||
* passed to this callback instead of logged in WPILog.
|
||||
*/
|
||||
Config(std::optional<ramp_rate_t> rampRate,
|
||||
std::optional<units::volt_t> stepVoltage,
|
||||
std::optional<units::second_t> timeout,
|
||||
std::function<void(frc::sysid::State)> recordState)
|
||||
std::optional<wpi::units::volt_t> stepVoltage,
|
||||
std::optional<wpi::units::second_t> timeout,
|
||||
std::function<void(wpi::sysid::State)> recordState)
|
||||
: m_recordState{std::move(recordState)} {
|
||||
if (rampRate) {
|
||||
m_rampRate = rampRate.value();
|
||||
@@ -69,15 +69,15 @@ class Mechanism {
|
||||
public:
|
||||
/// Sends the SysId-specified drive signal to the mechanism motors during test
|
||||
/// routines.
|
||||
std::function<void(units::volt_t)> m_drive;
|
||||
std::function<void(wpi::units::volt_t)> m_drive;
|
||||
|
||||
/// Returns measured data (voltages, positions, velocities) of the mechanism
|
||||
/// motors during test routines.
|
||||
std::function<void(frc::sysid::SysIdRoutineLog*)> m_log;
|
||||
std::function<void(wpi::sysid::SysIdRoutineLog*)> m_log;
|
||||
|
||||
/// The subsystem containing the motor(s) that is (or are) being
|
||||
/// characterized.
|
||||
frc2::Subsystem* m_subsystem;
|
||||
wpi::cmd::Subsystem* m_subsystem;
|
||||
|
||||
/// The name of the mechanism being tested. Will be appended to the log entry
|
||||
/// title for the routine's test state, e.g. "sysid-test-state-mechanism".
|
||||
@@ -102,11 +102,11 @@ class Mechanism {
|
||||
* "sysid-test-state-mechanism". Defaults to the name of the subsystem if
|
||||
* left null.
|
||||
*/
|
||||
Mechanism(std::function<void(units::volt_t)> drive,
|
||||
std::function<void(frc::sysid::SysIdRoutineLog*)> log,
|
||||
frc2::Subsystem* subsystem, std::string_view name)
|
||||
Mechanism(std::function<void(wpi::units::volt_t)> drive,
|
||||
std::function<void(wpi::sysid::SysIdRoutineLog*)> log,
|
||||
wpi::cmd::Subsystem* subsystem, std::string_view name)
|
||||
: m_drive{std::move(drive)},
|
||||
m_log{log ? std::move(log) : [](frc::sysid::SysIdRoutineLog* log) {}},
|
||||
m_log{log ? std::move(log) : [](wpi::sysid::SysIdRoutineLog* log) {}},
|
||||
m_subsystem{subsystem},
|
||||
m_name{name} {}
|
||||
|
||||
@@ -127,11 +127,11 @@ class Mechanism {
|
||||
* test commands. The subsystem's `name` will be appended to the log entry
|
||||
* title for the routine's test state, e.g. "sysid-test-state-subsystem".
|
||||
*/
|
||||
Mechanism(std::function<void(units::volt_t)> drive,
|
||||
std::function<void(frc::sysid::SysIdRoutineLog*)> log,
|
||||
frc2::Subsystem* subsystem)
|
||||
Mechanism(std::function<void(wpi::units::volt_t)> drive,
|
||||
std::function<void(wpi::sysid::SysIdRoutineLog*)> log,
|
||||
wpi::cmd::Subsystem* subsystem)
|
||||
: m_drive{std::move(drive)},
|
||||
m_log{log ? std::move(log) : [](frc::sysid::SysIdRoutineLog* log) {}},
|
||||
m_log{log ? std::move(log) : [](wpi::sysid::SysIdRoutineLog* log) {}},
|
||||
m_subsystem{subsystem},
|
||||
m_name{m_subsystem->GetName()} {}
|
||||
};
|
||||
@@ -167,7 +167,7 @@ enum Direction {
|
||||
* times in a single logfile, the user will need to select which of the tests to
|
||||
* use for the fit in the analysis tool.
|
||||
*/
|
||||
class SysIdRoutine : public frc::sysid::SysIdRoutineLog {
|
||||
class SysIdRoutine : public wpi::sysid::SysIdRoutineLog {
|
||||
public:
|
||||
/**
|
||||
* Create a new SysId characterization routine.
|
||||
@@ -180,18 +180,18 @@ class SysIdRoutine : public frc::sysid::SysIdRoutineLog {
|
||||
m_config(config),
|
||||
m_mechanism(mechanism),
|
||||
m_recordState(config.m_recordState ? config.m_recordState
|
||||
: [this](frc::sysid::State state) {
|
||||
: [this](wpi::sysid::State state) {
|
||||
this->RecordState(state);
|
||||
}) {}
|
||||
|
||||
frc2::CommandPtr Quasistatic(Direction direction);
|
||||
frc2::CommandPtr Dynamic(Direction direction);
|
||||
wpi::cmd::CommandPtr Quasistatic(Direction direction);
|
||||
wpi::cmd::CommandPtr Dynamic(Direction direction);
|
||||
|
||||
private:
|
||||
Config m_config;
|
||||
Mechanism m_mechanism;
|
||||
units::volt_t m_outputVolts{0};
|
||||
std::function<void(frc::sysid::State)> m_recordState;
|
||||
frc::Timer timer;
|
||||
wpi::units::volt_t m_outputVolts{0};
|
||||
std::function<void(wpi::sysid::State)> m_recordState;
|
||||
wpi::Timer timer;
|
||||
};
|
||||
} // namespace frc2::sysid
|
||||
} // namespace wpi::cmd::sysid
|
||||
|
||||
Reference in New Issue
Block a user