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);
69 "The new constructor allows you to pass in a supplier for desired and "
70 "current state. This allows you to change goals at runtime.")
72 std::function<
void(State)> output,
74 : m_profile(profile), m_output(output) {
75 this->AddRequirements(requirements);
82 m_output(m_profile.Calculate(m_timer.
Get(), m_currentState(), m_goal()));
85 void End(
bool interrupted)
override { m_timer.
Stop(); }
88 return m_timer.
HasElapsed(m_profile.TotalTime());
93 std::function<void(State)> m_output;
94 std::function<State()> m_goal;
95 std::function<State()> m_currentState;
CRTP implementation to allow polymorphic decorator functions in Command.
Definition: CommandHelper.h:27
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:79
void Execute() override
Definition: TrapezoidProfileCommand.h:81
void End(bool interrupted) override
Definition: TrapezoidProfileCommand.h:85
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:87
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:90
A trapezoid-shaped velocity profile.
Definition: TrapezoidProfile.h:45
typename units::detail::compound_impl< U, Us... >::type compound_unit
Represents a unit type made up from other units.
Definition: base.h:1434
Definition: TrapezoidProfileSubsystem.h:12
Definition: AprilTagPoseEstimator.h:15