8#include <initializer_list>
26template <
class Distance>
28 :
public CommandHelper<CommandBase, TrapezoidProfileCommand<Distance>> {
45 std::function<
void(State)> output,
46 std::initializer_list<Subsystem*> requirements)
47 : m_profile(profile), m_output(output) {
60 std::function<
void(State)> output,
61 std::span<Subsystem* const> requirements = {})
62 : m_profile(profile), m_output(output) {
68 void Execute()
override { m_output(m_profile.Calculate(m_timer.
Get())); }
70 void End(
bool interrupted)
override { m_timer.
Stop(); }
73 return m_timer.
HasElapsed(m_profile.TotalTime());
78 std::function<void(State)> m_output;
void AddRequirements(std::initializer_list< Subsystem * > requirements)
Adds the specified Subsystem requirements to the command.
CRTP implementation to allow polymorphic decorator functions in Command.
Definition: CommandHelper.h:26
A command that runs a TrapezoidProfile.
Definition: TrapezoidProfileCommand.h:28
void Initialize() override
The initial subroutine of a command.
Definition: TrapezoidProfileCommand.h:66
TrapezoidProfileCommand(frc::TrapezoidProfile< Distance > profile, std::function< void(State)> output, std::initializer_list< Subsystem * > requirements)
Creates a new TrapezoidProfileCommand that will execute the given TrapezoidalProfile.
Definition: TrapezoidProfileCommand.h:44
TrapezoidProfileCommand(frc::TrapezoidProfile< Distance > profile, std::function< void(State)> output, std::span< Subsystem *const > requirements={})
Creates a new TrapezoidProfileCommand that will execute the given TrapezoidalProfile.
Definition: TrapezoidProfileCommand.h:59
void Execute() override
The main body of a command.
Definition: TrapezoidProfileCommand.h:68
void End(bool interrupted) override
The action to take when the command ends.
Definition: TrapezoidProfileCommand.h:70
bool IsFinished() override
Whether the command has finished.
Definition: TrapezoidProfileCommand.h:72
A timer class.
Definition: Timer.h:36
void Restart()
Restart the timer by stopping the timer, if it is not already stopped, resetting the accumulated time...
units::second_t Get() const
Get the current time from the timer.
bool HasElapsed(units::second_t period) const
Check if the period specified has passed.
void Stop()
Stop the timer.
Definition: TrapezoidProfile.h:67
A trapezoid-shaped velocity profile.
Definition: TrapezoidProfile.h:42
typename units::detail::compound_impl< U, Us... >::type compound_unit
Represents a unit type made up from other units.
Definition: base.h:1434
Definition: InstantCommand.h:14