Class SN_Math

java.lang.Object
com.frcteam3255.utils.SN_Math

public class SN_Math extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
    static final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    degreesToFalcon(double degrees, double gearRatio)
    Deprecated.
    Only for use with Phoenix v5 devices
    static double
    falconToDegrees(double counts, double gearRatio)
    Deprecated.
    Only for use with Phoenix v5 devices
    static double
    falconToMeters(double position, double circumference, double gearRatio)
    Deprecated.
    Only for use with Phoenix v5 devices
    static double
    falconToMPS(double velocitycounts, double circumference, double gearRatio)
    Deprecated.
    Only for use with Phoenix v5 devices
    static double
    falconToRPM(double velocityCounts, double gearRatio)
    Deprecated.
    Only for use with Phoenix v5 devices
    static double
    interpolate(double input, double minInput, double maxInput, double outputAtMin, double outputAtMax)
     
    static double
    metersToFalcon(double meters, double circumference, double gearRatio)
    Deprecated.
    Only for use with Phoenix v5 devices
    static double
    metersToRotations(double meters, double circumference, double gearRatio)
    Converts meters to motor rotations
    static double
    MPSToFalcon(double velocity, double circumference, double gearRatio)
    Deprecated.
    Only for use with Phoenix v5 devices
    static double
    rotationsToMeters(double rotations, double circumference, double gearRatio)
    Converts motor rotations to meters.
    static double
    RPMToFalcon(double RPM, double gearRatio)
    Deprecated.
    Only for use with Phoenix v5 devices
    static double
    RPMToVelocity(double a_rpm, int a_pulsesPerCount)
    Converts RPM to velocity
    static double
    signedPow(double base, double exponent)
    Returns signed power
    static double
    velocityToRPM(double a_velocity, int a_pulsesPerCount)
    Converts Velocity to RPM

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 value
      minInput - - the input value that should map to the outputAtMin value
      maxInput - - the input value that should map to the outputAtMax value
      outputAtMin - - the output value when input = minInput
      outputAtMax - - the output value when input = maxInput
      Returns:
      - interpolated value
    • signedPow

      public static double signedPow(double base, double exponent)
      Returns signed power
      Parameters:
      base - base number
      exponent - 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 100ms
      a_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 RPM
      a_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 devices
      Converts Falcon integrated encoder counts (falcon) to degrees From 364's BaseFalconSwerve
      Parameters:
      counts - Falcon Integrated Encoder Counts
      gearRatio - 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 devices
      Converts degrees to Falcon integrated encoder counts (falcon) From 364's BaseFalconSwerve
      Parameters:
      degrees - Degrees of rotation of Mechanism
      gearRatio - 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 devices
      Converts Falcon integrated encoder counts per 100 milliseconds (falcon) to RPM From 364's BaseFalconSwerve
      Parameters:
      velocityCounts - Falcon Integrated Encoder Counts per 100 milliseconds
      gearRatio - 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 devices
      Converts RPM to Falcon integrated encoder counts per 100 milliseconds (falcon) From 364's BaseFalconSwerve
      Parameters:
      RPM - RPM of mechanism
      gearRatio - 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 devices
      Converts 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 milliseconds
      circumference - Circumference of Wheel in Meters
      gearRatio - 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 devices
      Converts Meters per Second (MPS) to Falcon integrated encoder counts per 100 milliseconds (falcon) From 364's BaseFalconSwerve
      Parameters:
      velocity - Velocity in Meters per Second
      circumference - Circumference of Wheel in Meters
      gearRatio - 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 devices
      Converts Falcon integrated encoder counts to meters
      Parameters:
      position - Falcon integrated encoder counts
      circumference - Circumference of Wheel in Meters
      gearRatio - 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 devices
      Converts meters to Falcon integrated encoder counts
      Parameters:
      meters - Meters Traveled
      circumference - Circumference of Wheel in Meters
      gearRatio - 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 Rotations
      circumference - Circumference of Wheel in Meters
      gearRatio - 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 Traveled
      circumference - Circumference of Wheel in Meters
      gearRatio - 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