mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-04 03:11:43 +00:00
SCRIPT namespace replacements
This commit is contained in:
committed by
Peter Johnson
parent
ae6c043632
commit
9aca8e0fd6
@@ -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