Package com.frcteam3255.utils
Class SN_Math
java.lang.Object
com.frcteam3255.utils.SN_Math
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic doubledegreesToFalcon(double degrees, double gearRatio) Deprecated.Only for use with Phoenix v5 devicesstatic doublefalconToDegrees(double counts, double gearRatio) Deprecated.Only for use with Phoenix v5 devicesstatic doublefalconToMeters(double position, double circumference, double gearRatio) Deprecated.Only for use with Phoenix v5 devicesstatic doublefalconToMPS(double velocitycounts, double circumference, double gearRatio) Deprecated.Only for use with Phoenix v5 devicesstatic doublefalconToRPM(double velocityCounts, double gearRatio) Deprecated.Only for use with Phoenix v5 devicesstatic doubleinterpolate(double input, double minInput, double maxInput, double outputAtMin, double outputAtMax) static doublemetersToFalcon(double meters, double circumference, double gearRatio) Deprecated.Only for use with Phoenix v5 devicesstatic doublemetersToRotations(double meters, double circumference, double gearRatio) Converts meters to motor rotationsstatic doubleMPSToFalcon(double velocity, double circumference, double gearRatio) Deprecated.Only for use with Phoenix v5 devicesstatic doublerotationsToMeters(double rotations, double circumference, double gearRatio) Converts motor rotations to meters.static doubleRPMToFalcon(double RPM, double gearRatio) Deprecated.Only for use with Phoenix v5 devicesstatic doubleRPMToVelocity(double a_rpm, int a_pulsesPerCount) Converts RPM to velocitystatic doublesignedPow(double base, double exponent) Returns signed powerstatic doublevelocityToRPM(double a_velocity, int a_pulsesPerCount) Converts Velocity to RPM
-
Field Details
-
TALONFX_ENCODER_PULSES_PER_COUNT
public static final int TALONFX_ENCODER_PULSES_PER_COUNT- See Also:
-
QUAD_ENCODER_PULSES_PER_COUNT
public static final int QUAD_ENCODER_PULSES_PER_COUNT- See Also:
-
-
Constructor Details
-
SN_Math
public SN_Math()
-
-
Method Details
-
interpolate
public static double interpolate(double input, double minInput, double maxInput, double outputAtMin, double outputAtMax) - Parameters:
input- - the input value used to determine the output valueminInput- - the input value that should map to the outputAtMin valuemaxInput- - the input value that should map to the outputAtMax valueoutputAtMin- - the output value when input = minInputoutputAtMax- - the output value when input = maxInput- Returns:
- - interpolated value
-
signedPow
public static double signedPow(double base, double exponent) Returns signed power- Parameters:
base- base numberexponent- exponent number- Returns:
- base to the power of the exponent with the original sign of the base.
-
velocityToRPM
public static double velocityToRPM(double a_velocity, int a_pulsesPerCount) Converts Velocity to RPM- Parameters:
a_velocity- Motor encoder counts per 100msa_pulsesPerCount- Encoder counts per revolution- Returns:
- Motor RPM
-
RPMToVelocity
public static double RPMToVelocity(double a_rpm, int a_pulsesPerCount) Converts RPM to velocity- Parameters:
a_rpm- Motor RPMa_pulsesPerCount- Encoder counts per revolution- Returns:
- Motor encoder counts per 100ms
-
falconToDegrees
public static double falconToDegrees(double counts, double gearRatio) Deprecated.Only for use with Phoenix v5 devicesConverts Falcon integrated encoder counts (falcon) to degrees From 364's BaseFalconSwerve- Parameters:
counts- Falcon Integrated Encoder CountsgearRatio- Gear Ratio between Falcon and Mechanism- Returns:
- Degrees of Rotation of Mechanism
-
degreesToFalcon
public static double degreesToFalcon(double degrees, double gearRatio) Deprecated.Only for use with Phoenix v5 devicesConverts degrees to Falcon integrated encoder counts (falcon) From 364's BaseFalconSwerve- Parameters:
degrees- Degrees of rotation of MechanismgearRatio- Gear Ratio between Falcon and Mechanism- Returns:
- Falcon Integrated Encoder Counts
-
falconToRPM
public static double falconToRPM(double velocityCounts, double gearRatio) Deprecated.Only for use with Phoenix v5 devicesConverts Falcon integrated encoder counts per 100 milliseconds (falcon) to RPM From 364's BaseFalconSwerve- Parameters:
velocityCounts- Falcon Integrated Encoder Counts per 100 millisecondsgearRatio- Gear Ratio between Falcon and Mechanism (set to 1 for Falcon RPM)- Returns:
- RPM of Mechanism
-
RPMToFalcon
public static double RPMToFalcon(double RPM, double gearRatio) Deprecated.Only for use with Phoenix v5 devicesConverts RPM to Falcon integrated encoder counts per 100 milliseconds (falcon) From 364's BaseFalconSwerve- Parameters:
RPM- RPM of mechanismgearRatio- Gear Ratio between Falcon and Mechanism (set to 1 for Falcon RPM)- Returns:
- Falcon Integrated Encoder Counts per 100 milliseconds
-
falconToMPS
public static double falconToMPS(double velocitycounts, double circumference, double gearRatio) Deprecated.Only for use with Phoenix v5 devicesConverts Falcon integrated encoder counts per 100 milliseconds (falcon) to Meters per Second (MPS) From 364's BaseFalconSwerve- Parameters:
velocitycounts- Falcon Integrated Encoder Counts per 100 millisecondscircumference- Circumference of Wheel in MetersgearRatio- Gear Ratio between Falcon and Mechanism (set to 1 for Falcon RPM)- Returns:
- Mechanism Meters per Second
-
MPSToFalcon
public static double MPSToFalcon(double velocity, double circumference, double gearRatio) Deprecated.Only for use with Phoenix v5 devicesConverts Meters per Second (MPS) to Falcon integrated encoder counts per 100 milliseconds (falcon) From 364's BaseFalconSwerve- Parameters:
velocity- Velocity in Meters per Secondcircumference- Circumference of Wheel in MetersgearRatio- Gear Ratio between Falcon and Mechanism (set to 1 for Falcon RPM)- Returns:
- Falcon Integrated Encoder Counts per 100 milliseconds
-
falconToMeters
public static double falconToMeters(double position, double circumference, double gearRatio) Deprecated.Only for use with Phoenix v5 devicesConverts Falcon integrated encoder counts to meters- Parameters:
position- Falcon integrated encoder countscircumference- Circumference of Wheel in MetersgearRatio- Gear Ratio between Falcon and Mechanism- Returns:
- Meters Traveled
-
metersToFalcon
public static double metersToFalcon(double meters, double circumference, double gearRatio) Deprecated.Only for use with Phoenix v5 devicesConverts meters to Falcon integrated encoder counts- Parameters:
meters- Meters Traveledcircumference- Circumference of Wheel in MetersgearRatio- Gear Ratio between Falcon and Mechanism- Returns:
- Falcon integrated encoder counts
-
rotationsToMeters
public static double rotationsToMeters(double rotations, double circumference, double gearRatio) Converts motor rotations to meters. Based off of 364's BaseFalconSwerve- Parameters:
rotations- Motor Rotationscircumference- Circumference of Wheel in MetersgearRatio- Gear Ratio between the motor and Mechanism. If you can, the best approach is to configure the gear ratio to the motor itself and set this parameter to 1.- Returns:
- Mechanism Meters per Second
-
metersToRotations
public static double metersToRotations(double meters, double circumference, double gearRatio) Converts meters to motor rotations- Parameters:
meters- Meters Traveledcircumference- Circumference of Wheel in MetersgearRatio- Gear Ratio between the motor and Mechanism. If you can, the best approach is to configure the gear ratio to the motor itself and set this parameter to 1.- Returns:
- Motor rotations
-