Class TelescopingArmPivotFeedForward

java.lang.Object
lib.subsystems.motor.TelescopingArmPivotFeedForward

public class TelescopingArmPivotFeedForward extends Object
Computes feed-forward values for an arm rotation motor, with a varying cg. Internally composes a wpilib ArmFeedForward.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final double
     
    final double
     
    final double
     
    final double
     
    final double
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    TelescopingArmPivotFeedForward(double retracted_kg, double extended_kg, double ks, double kv, double ka)
    Computes feed-forward values for an arm rotation motor, with a varying cg.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    calculate(double armExtensionRatio, double posRads, double velRadPerSec)
     
    double
    maxAchievableAcceleration(double maxVoltage, double extension, double angle, double velocity)
    Calculates the maximum achievable acceleration given a maximum voltage supply, a position, and a velocity.
    double
    maxAchievableVelocity(double maxVoltage, double extension, double angle, double acceleration)
    Calculates the maximum achievable velocity given a maximum voltage supply, a position, and an acceleration.
    double
    minAchievableAcceleration(double maxVoltage, double extension, double angle, double velocity)
    Calculates the minimum achievable acceleration given a maximum voltage supply, a position, and a velocity.
    double
    minAchievableVelocity(double maxVoltage, double extension, double angle, double acceleration)
    Calculates the minimum achievable velocity given a maximum voltage supply, a position, and an acceleration.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • ks

      public final double ks
    • kv

      public final double kv
    • ka

      public final double ka
    • retracted_kg

      public final double retracted_kg
    • extended_kg

      public final double extended_kg
  • Constructor Details

    • TelescopingArmPivotFeedForward

      public TelescopingArmPivotFeedForward(double retracted_kg, double extended_kg, double ks, double kv, double ka)
      Computes feed-forward values for an arm rotation motor, with a varying cg. cg is calculated by linearly interpolating between retracted and extended cgs. Internally composes a wpilib ArmFeedForward. Gain units (eg. voltage) will dictate feed-forward units. Use the recalc arm calculator or characterization to estimate the kg (gravitational gain) on the arm for both the retracted and extended positions.
      Parameters:
      retracted_kg - Gravity gain when the arm is not (0.0) extended.
      extended_kg - Gravity gain when the arm is fully (1.0) extended.
      ks - Static gain, eg. from recalc or sysID. The voltage required to hold the arm parallel.
      kv - Velocity gain, eg. from recalc or sysID.
      ka - Acceleration gain. Makes little difference, 0 is often an okay default.
  • Method Details

    • calculate

      public double calculate(double armExtensionRatio, double posRads, double velRadPerSec)
      Parameters:
      armExtensionRatio - The extension of the arm, relative to it's full extension. Should be between 0 and 1. Used as cg linear interpolation parameter.
      posRads - Current angle, in radians, measured from horizontal (0 = parallel with floor).
      velRadPerSec - Velocity setpoint.
      Returns:
      The computed feedforward.
    • maxAchievableVelocity

      public double maxAchievableVelocity(double maxVoltage, double extension, double angle, double acceleration)
      Calculates the maximum achievable velocity given a maximum voltage supply, a position, and an acceleration. Useful for ensuring that velocity and acceleration constraints for a trapezoidal profile are simultaneously achievable - enter the acceleration constraint, and this will give you a simultaneously-achievable velocity constraint.
      Parameters:
      maxVoltage - The maximum voltage that can be supplied to the arm.
      extension - The extension of the arm, relative to the full extension. Should be between 0 and 1.
      angle - The angle of the arm. This angle should be measured from the horizontal (i.e. if the provided angle is 0, the arm should be parallel with the floor). If your encoder does not follow this convention, an offset should be added.
      acceleration - The acceleration of the arm.
      Returns:
      The maximum possible velocity at the given acceleration and angle.
    • minAchievableVelocity

      public double minAchievableVelocity(double maxVoltage, double extension, double angle, double acceleration)
      Calculates the minimum achievable velocity given a maximum voltage supply, a position, and an acceleration. Useful for ensuring that velocity and acceleration constraints for a trapezoidal profile are simultaneously achievable - enter the acceleration constraint, and this will give you a simultaneously-achievable velocity constraint.
      Parameters:
      maxVoltage - The maximum voltage that can be supplied to the arm.
      extension - The extension of the arm, relative to the full extension. Should be between 0 and 1.
      angle - The angle of the arm. This angle should be measured from the horizontal (i.e. if the provided angle is 0, the arm should be parallel with the floor). If your encoder does not follow this convention, an offset should be added.
      acceleration - The acceleration of the arm.
      Returns:
      The minimum possible velocity at the given acceleration and angle.
    • maxAchievableAcceleration

      public double maxAchievableAcceleration(double maxVoltage, double extension, double angle, double velocity)
      Calculates the maximum achievable acceleration given a maximum voltage supply, a position, and a velocity. Useful for ensuring that velocity and acceleration constraints for a trapezoidal profile are simultaneously achievable - enter the velocity constraint, and this will give you a simultaneously-achievable acceleration constraint.
      Parameters:
      maxVoltage - The maximum voltage that can be supplied to the arm.
      extension - The extension of the arm, relative to the full extension. Should be between 0 and 1.
      angle - The angle of the arm. This angle should be measured from the horizontal (i.e. if the provided angle is 0, the arm should be parallel with the floor). If your encoder does not follow this convention, an offset should be added.
      velocity - The velocity of the arm.
      Returns:
      The maximum possible acceleration at the given velocity.
    • minAchievableAcceleration

      public double minAchievableAcceleration(double maxVoltage, double extension, double angle, double velocity)
      Calculates the minimum achievable acceleration given a maximum voltage supply, a position, and a velocity. Useful for ensuring that velocity and acceleration constraints for a trapezoidal profile are simultaneously achievable - enter the velocity constraint, and this will give you a simultaneously-achievable acceleration constraint.
      Parameters:
      maxVoltage - The maximum voltage that can be supplied to the arm.
      extension - The extension of the arm, relative to the full extension. Should be between 0 and 1.
      angle - The angle of the arm. This angle should be measured from the horizontal (i.e. if the provided angle is 0, the arm should be parallel with the floor). If your encoder does not follow this convention, an offset should be added.
      velocity - The velocity of the arm.
      Returns:
      The minimum possible acceleration at the given velocity.