SubZero Common
Common library components for an FRC CommandRobot
|
The ultimate solution for turrets, arms, and much more. This class allows for absolute, relative, and joystick control across both linear and rotational axes. Even better, it checks motion limits, outputs real-time stats via SmartDashboard, and allows for out-of-the-box simulations via Mechanism2d. More...
#include <BaseSingleAxisSubsystem.h>
Public Types | |
using | PidState = typename frc::TrapezoidProfile<TDistance>::State |
using | Distance_t = units::unit_t<TDistance> |
using | Velocity |
using | Velocity_t = units::unit_t<Velocity> |
using | Acceleration |
using | Acceleration_t = units::unit_t<Acceleration> |
Public Types inherited from subzero::ISingleAxisSubsystem< TDistance > | |
using | Distance_t |
using | Velocity |
using | Velocity_t |
using | Acceleration |
using | Acceleration_t |
Public Member Functions | |
BaseSingleAxisSubsystem (std::string name, TController &controller, ISingleAxisSubsystem< TDistance >::SingleAxisConfig config, frc::MechanismObject2d *mechanismNode=nullptr) | |
void | Periodic () override |
Runs the absolute positioning task and updates relevant info on SmartDashboard. | |
virtual void | RunMotorVelocity (Velocity_t speed, bool ignoreEncoder=false)=0 |
Run at the given velocity; disables any in-progress absolute movements. | |
void | UseState (PidState setpoint) override |
void | RunMotorSpeedDefault (bool ignoreEncoder=false) override |
Run at the default motor speed. | |
void | RunMotorPercentage (double percentSpeed, bool ignoreEncoder=false) override |
Run at the given velocity percentage; disables any in-progress absolute movements. | |
Distance_t | GetCurrentPosition () override |
Get the current position in terms of converted distance. | |
void | Stop () override |
Stop the axis. | |
void | ResetEncoder () override |
Reset encoder back to 0 ticks. | |
bool | AtHome () override |
Check if axis is at the mimimum extent of motion. | |
bool | AtMax () override |
Check if axis is at the maximum extent of motion. | |
bool | AtLimitSwitchMin () override |
Only check the limit switch for mimimum extent. | |
bool | AtLimitSwitchMax () override |
Only check the limit switch for maximum extent. | |
frc2::CommandPtr | MoveToPositionAbsolute (Distance_t position) override |
Start moving to the absolute position. | |
frc2::CommandPtr | MoveToPositionRelative (Distance_t position) override |
Start moving to the position given the current distance and relative position. | |
frc2::CommandPtr | Home () override |
Start the homing sequence. | |
frc2::CommandPtr | ResetRelativeEncoder () |
frc::MechanismLigament2d * | GetLigament () |
bool | IsEnabled () override |
Check if absolute positioning is active. | |
void | DisablePid () override |
Stop and disable any in-progress absolute movements. | |
void | EnablePid () override |
Enable absolute movements. | |
void | OnInit () |
This must be called once upon robot startup. | |
Protected Member Functions | |
bool | IsMovementAllowed (double speed, bool ignoreEncoder=false) |
bool | IsMovementAllowed (bool ignoreEncoder=false) |
Protected Attributes | |
std::optional< frc::DigitalInput * > | m_minLimitSwitch |
std::optional< frc::DigitalInput * > | m_maxLimitSwitch |
TController & | m_controller |
ISingleAxisSubsystem< TDistance >::SingleAxisConfig | m_config |
std::string | m_name |
Distance_t | m_goalPosition |
bool | m_pidEnabled |
bool | m_home |
bool | resetOccurred = false |
double | m_latestSpeed |
frc2::CommandPtr | m_resetEncCmd = EmptyCommand().ToPtr() |
frc::MechanismLigament2d * | m_ligament2d |
The ultimate solution for turrets, arms, and much more. This class allows for absolute, relative, and joystick control across both linear and rotational axes. Even better, it checks motion limits, outputs real-time stats via SmartDashboard, and allows for out-of-the-box simulations via Mechanism2d.
TController | PidMotorController |
TDistance | Distance unit |
Definition at line 44 of file BaseSingleAxisSubsystem.h.
using subzero::BaseSingleAxisSubsystem< TController, TDistance >::Acceleration |
Definition at line 53 of file BaseSingleAxisSubsystem.h.
using subzero::BaseSingleAxisSubsystem< TController, TDistance >::Acceleration_t = units::unit_t<Acceleration> |
Definition at line 55 of file BaseSingleAxisSubsystem.h.
using subzero::BaseSingleAxisSubsystem< TController, TDistance >::Distance_t = units::unit_t<TDistance> |
Definition at line 49 of file BaseSingleAxisSubsystem.h.
using subzero::BaseSingleAxisSubsystem< TController, TDistance >::PidState = typename frc::TrapezoidProfile<TDistance>::State |
Definition at line 48 of file BaseSingleAxisSubsystem.h.
using subzero::BaseSingleAxisSubsystem< TController, TDistance >::Velocity |
Definition at line 50 of file BaseSingleAxisSubsystem.h.
using subzero::BaseSingleAxisSubsystem< TController, TDistance >::Velocity_t = units::unit_t<Velocity> |
Definition at line 52 of file BaseSingleAxisSubsystem.h.
subzero::BaseSingleAxisSubsystem< TController, TDistance >::BaseSingleAxisSubsystem | ( | std::string | name, |
TController & | controller, | ||
ISingleAxisSubsystem< TDistance >::SingleAxisConfig | config, | ||
frc::MechanismObject2d * | mechanismNode = nullptr ) |
|
inlineoverridevirtual |
Check if axis is at the mimimum extent of motion.
Implements subzero::ISingleAxisSubsystem< TDistance >.
Definition at line 97 of file BaseSingleAxisSubsystem.h.
|
overridevirtual |
Only check the limit switch for maximum extent.
Implements subzero::ISingleAxisSubsystem< TDistance >.
|
overridevirtual |
Only check the limit switch for mimimum extent.
Implements subzero::ISingleAxisSubsystem< TDistance >.
|
inlineoverridevirtual |
Check if axis is at the maximum extent of motion.
Implements subzero::ISingleAxisSubsystem< TDistance >.
Definition at line 101 of file BaseSingleAxisSubsystem.h.
|
overridevirtual |
Stop and disable any in-progress absolute movements.
Implements subzero::ISingleAxisSubsystem< TDistance >.
|
overridevirtual |
Enable absolute movements.
Implements subzero::ISingleAxisSubsystem< TDistance >.
|
inlineoverridevirtual |
Get the current position in terms of converted distance.
Implements subzero::ISingleAxisSubsystem< TDistance >.
Definition at line 89 of file BaseSingleAxisSubsystem.h.
|
inline |
Definition at line 121 of file BaseSingleAxisSubsystem.h.
|
overridevirtual |
Start the homing sequence.
Implements subzero::ISingleAxisSubsystem< TDistance >.
|
inlineoverridevirtual |
Check if absolute positioning is active.
Implements subzero::ISingleAxisSubsystem< TDistance >.
Definition at line 123 of file BaseSingleAxisSubsystem.h.
|
protected |
|
protected |
|
overridevirtual |
Start moving to the absolute position.
position |
Implements subzero::ISingleAxisSubsystem< TDistance >.
|
inlineoverridevirtual |
Start moving to the position given the current distance and relative position.
position |
Implements subzero::ISingleAxisSubsystem< TDistance >.
Definition at line 111 of file BaseSingleAxisSubsystem.h.
void subzero::BaseSingleAxisSubsystem< TController, TDistance >::OnInit | ( | ) |
This must be called once upon robot startup.
|
override |
Runs the absolute positioning task and updates relevant info on SmartDashboard.
|
overridevirtual |
Reset encoder back to 0 ticks.
Implements subzero::ISingleAxisSubsystem< TDistance >.
|
inline |
Definition at line 117 of file BaseSingleAxisSubsystem.h.
|
overridevirtual |
Run at the given velocity percentage; disables any in-progress absolute movements.
speed | |
ignoreEncoder |
Implements subzero::ISingleAxisSubsystem< TDistance >.
|
inlineoverridevirtual |
Run at the default motor speed.
ignoreEncoder |
Implements subzero::ISingleAxisSubsystem< TDistance >.
Definition at line 82 of file BaseSingleAxisSubsystem.h.
|
pure virtual |
Run at the given velocity; disables any in-progress absolute movements.
speed | |
ignoreEncoder |
Implements subzero::ISingleAxisSubsystem< TDistance >.
|
overridevirtual |
Stop the axis.
Implements subzero::ISingleAxisSubsystem< TDistance >.
|
inlineoverride |
Definition at line 78 of file BaseSingleAxisSubsystem.h.
|
protected |
Definition at line 139 of file BaseSingleAxisSubsystem.h.
|
protected |
Definition at line 138 of file BaseSingleAxisSubsystem.h.
|
protected |
Definition at line 141 of file BaseSingleAxisSubsystem.h.
|
protected |
Definition at line 143 of file BaseSingleAxisSubsystem.h.
|
protected |
Definition at line 145 of file BaseSingleAxisSubsystem.h.
|
protected |
Definition at line 147 of file BaseSingleAxisSubsystem.h.
|
protected |
Definition at line 137 of file BaseSingleAxisSubsystem.h.
|
protected |
Definition at line 136 of file BaseSingleAxisSubsystem.h.
|
protected |
Definition at line 140 of file BaseSingleAxisSubsystem.h.
|
protected |
Definition at line 142 of file BaseSingleAxisSubsystem.h.
|
protected |
Definition at line 146 of file BaseSingleAxisSubsystem.h.
|
protected |
Definition at line 144 of file BaseSingleAxisSubsystem.h.