21template <
class Distance>
24 using Distance_t = units::unit_t<Distance>;
26 units::compound_unit<Distance, units::inverse<units::seconds>>;
27 using Velocity_t = units::unit_t<Velocity>;
42 Distance_t initialPosition = Distance_t{0},
43 units::second_t period = 20_ms)
44 : m_profile(constraints),
45 m_state{initialPosition, Velocity_t(0)},
46 m_goal{initialPosition, Velocity_t{0}},
50 m_state = m_profile.Calculate(m_period, m_state, m_goal);
61 void SetGoal(State goal) { m_goal = goal; }
68 void SetGoal(Distance_t goal) { m_goal = State{goal, Velocity_t(0)}; }
93 units::second_t m_period;
94 bool m_enabled{
false};
A base for subsystems that handles registration in the constructor, and provides a more intuitive met...
Definition SubsystemBase.h:24
A subsystem that generates and runs trapezoidal motion profiles automatically.
Definition TrapezoidProfileSubsystem.h:23
void SetGoal(State goal)
Sets the goal state for the subsystem.
Definition TrapezoidProfileSubsystem.h:61
void Disable()
Disable the TrapezoidProfileSubsystem's output.
Definition TrapezoidProfileSubsystem.h:87
void SetGoal(Distance_t goal)
Sets the goal state for the subsystem.
Definition TrapezoidProfileSubsystem.h:68
TrapezoidProfileSubsystem(Constraints constraints, Distance_t initialPosition=Distance_t{0}, units::second_t period=20_ms)
Creates a new TrapezoidProfileSubsystem.
Definition TrapezoidProfileSubsystem.h:41
void Periodic() override
This method is called periodically by the CommandScheduler.
Definition TrapezoidProfileSubsystem.h:49
void Enable()
Enable the TrapezoidProfileSubsystem's output.
Definition TrapezoidProfileSubsystem.h:82
virtual void UseState(State state)=0
Users should override this to consume the current state of the motion profile.
Profile constraints.
Definition TrapezoidProfile.h:59
Profile state.
Definition TrapezoidProfile.h:100
A trapezoid-shaped velocity profile.
Definition TrapezoidProfile.h:46
Definition FunctionalCommand.h:13