2022-Robot
Robot code for 2022 FRC Season by Argos, FRC team #1756
Loading...
Searching...
No Matches
argos_lib::swerve Namespace Reference

Classes

class  NetworkTablesHomingStorage
 Saves and loads swerve module homes to networkTables. More...
 
class  SwerveHomeStorageInterface
 Interface capable of saving and loading module home positions from persistent storage. More...
 
struct  SwerveModulePositions
 Representation of the absolute encoder position of each module at home position. More...
 
struct  TranslationSpeeds
 Translation speeds as percent max output. More...
 

Functions

units::degree_t NearestAngle (units::degree_t desiredAngle, units::degree_t referenceAngle)
 Finds closest angle alias of desiredAngle relative to referencedAngle. All inputs are normalized so ranges are unbounded. More...
 
units::degree_t InvertedAngle (units::degree_t desiredAngle, units::degree_t referenceAngle)
 Finds closest angle alias of a vector 180-degrees offset from desiredAngle relative to referencedAngle. All inputs are normalized so ranges are unbounded. More...
 
units::degree_t ConstrainAngle (units::degree_t inVal, units::degree_t minVal, units::degree_t maxVal)
 Normalize angle to specified range. More...
 
double ConstrainAngle (double inVal, double minVal, double maxVal)
 Normalize angle to specified range. More...
 
frc::SwerveModuleState Optimize (frc::SwerveModuleState desiredState, units::degree_t currentModuleAngle, units::degrees_per_second_t currentModuleAngularRate, units::feet_per_second_t currentModuleDriveVel, units::feet_per_second_t maxVelocity)
 Optimize swerve module to minimize rotations and drive direction changes. More...
 
template<class T , int size, class V >
constexpr TranslationSpeeds CircularInterpolate (const TranslationSpeeds rawSpeeds, const argos_lib::InterpolationMap< T, size, V > interpMap)
 Use argos_lib::InterpolationMap to apply mapping according to joystick vector magnitude. More...
 

Function Documentation

◆ CircularInterpolate()

template<class T , int size, class V >
constexpr TranslationSpeeds argos_lib::swerve::CircularInterpolate ( const TranslationSpeeds  rawSpeeds,
const argos_lib::InterpolationMap< T, size, V >  interpMap 
)
constexpr

Use argos_lib::InterpolationMap to apply mapping according to joystick vector magnitude.

Template Parameters
TType of interpolated input
sizeNumber of elements in interpolation map
VType of interpolated output
Parameters
rawSpeedsJoystick inputs as percentages
interpMapInterpolation map to apply to magnitudes
Returns
Remapped joystick percentages. Angle of vector will match rawSpeeds, but magnitude will scale according to interpMap. This results in circular deadband and other mapping results.

◆ ConstrainAngle() [1/2]

double argos_lib::swerve::ConstrainAngle ( double  inVal,
double  minVal,
double  maxVal 
)

Normalize angle to specified range.

Parameters
inValAngle to constrain (degrees)
minValNormalization lower bound (degrees)
maxValNormalization upper bound (degrees)
Returns
Normalized value in range [minVal, maxVal] (degrees)

◆ ConstrainAngle() [2/2]

units::degree_t argos_lib::swerve::ConstrainAngle ( units::degree_t  inVal,
units::degree_t  minVal,
units::degree_t  maxVal 
)

Normalize angle to specified range.

Parameters
inValAngle to constrain
minValNormalization lower bound
maxValNormalization upper bound
Returns
Normalized value in range [minVal, maxVal]

◆ InvertedAngle()

units::degree_t argos_lib::swerve::InvertedAngle ( units::degree_t  desiredAngle,
units::degree_t  referenceAngle 
)

Finds closest angle alias of a vector 180-degrees offset from desiredAngle relative to referencedAngle. All inputs are normalized so ranges are unbounded.

Parameters
desiredAngleAngle to find 180-degree offset alias for
referenceAngleDefines desired alias range
Returns
Offset angle alias of desiredAngle in range (referencedAngle - 180_deg, referencedAngle + 180_deg]

◆ NearestAngle()

units::degree_t argos_lib::swerve::NearestAngle ( units::degree_t  desiredAngle,
units::degree_t  referenceAngle 
)

Finds closest angle alias of desiredAngle relative to referencedAngle. All inputs are normalized so ranges are unbounded.

Parameters
desiredAngleAngle to find alias for
referenceAngleDefines desired alias range
Returns
Angle alias of desiredAngle in range (referencedAngle - 180_deg, referencedAngle + 180_deg]

◆ Optimize()

frc::SwerveModuleState argos_lib::swerve::Optimize ( frc::SwerveModuleState  desiredState,
units::degree_t  currentModuleAngle,
units::degrees_per_second_t  currentModuleAngularRate,
units::feet_per_second_t  currentModuleDriveVel,
units::feet_per_second_t  maxVelocity 
)

Optimize swerve module to minimize rotations and drive direction changes.

Parameters
desiredStateRequested state. Output must result in same motion
currentModuleAngleModule rotation angle in relative or absolute position
currentModuleAngularRateCurrent module rotation speed. To prevent rapid changes in rotation direction.
currentModuleDriveVelCurrent module drive velocity. To prevent rapid changes in drive motor velocity.
maxVelocityMax velocity for determining max transition change thresholds
Returns
Optimized swerve module state that results in same motion as desiredState