25template <
class Distance>
27 :
public CommandHelper<Command, TrapezoidProfileCommand<Distance>> {
46 std::function<
void(State)> output,
47 std::function<State()> goal,
48 std::function<State()> currentState,
53 m_currentState(currentState) {
54 this->AddRequirements(requirements);
60 m_output(m_profile.Calculate(m_timer.
Get(), m_currentState(), m_goal()));
63 void End(
bool interrupted)
override { m_timer.
Stop(); }
66 return m_timer.
HasElapsed(m_profile.TotalTime());
71 std::function<void(State)> m_output;
72 std::function<State()> m_goal;
73 std::function<State()> m_currentState;
CRTP implementation to allow polymorphic decorator functions in Command.
Definition: CommandHelper.h:25
Represents requirements for a command, which is a set of (pointers to) subsystems.
Definition: Requirements.h:20
A command that runs a TrapezoidProfile.
Definition: TrapezoidProfileCommand.h:27
void Initialize() override
Definition: TrapezoidProfileCommand.h:57
void Execute() override
Definition: TrapezoidProfileCommand.h:59
void End(bool interrupted) override
Definition: TrapezoidProfileCommand.h:63
TrapezoidProfileCommand(frc::TrapezoidProfile< Distance > profile, std::function< void(State)> output, std::function< State()> goal, std::function< State()> currentState, Requirements requirements={})
Creates a new TrapezoidProfileCommand that will execute the given TrapezoidalProfile.
Definition: TrapezoidProfileCommand.h:45
bool IsFinished() override
Definition: TrapezoidProfileCommand.h:65
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.
Profile state.
Definition: TrapezoidProfile.h:88
A trapezoid-shaped velocity profile.
Definition: TrapezoidProfile.h:43
typename units::detail::compound_impl< U, Us... >::type compound_unit
Represents a unit type made up from other units.
Definition: base.h:1436
Definition: NotifierCommand.h:16