Class FrcTankMotionProfileFollower

java.lang.Object
trclib.archive.TrcTankMotionProfileFollower
frclib.archive.FrcTankMotionProfileFollower

public class FrcTankMotionProfileFollower extends TrcTankMotionProfileFollower
This class implements the platform dependent motion profiling. It streams the profiles to the buffer of the CAN Talon, and then executes it. Also, the profiles are processed 2x as fast as the first point. This code is based on the following references: https://github.com/CrossTheRoadElec/Phoenix-Examples-Languages/tree/master/Java/MotionProfile/src/org/usfirst/frc/team217/robot https://github.com/CrossTheRoadElec/Phoenix-Documentation/blob/master/Talon%20SRX%20Motion%20Profile%20Reference%20Manual.pdf
  • Constructor Details

    • FrcTankMotionProfileFollower

      public FrcTankMotionProfileFollower(String instanceName, TrcPidController.PidCoefficients pidCoefficients, double worldUnitsPerEncoderTick)
      Create FrcTankMotionProfileFollower object. Uses default pid slot 0.
      Parameters:
      instanceName - Name of the instance, duh.
      pidCoefficients - PidCoefficients object storing the PIDF constants.
      worldUnitsPerEncoderTick - Number of word units per encoder tick. For example, inches per encoder tick.
    • FrcTankMotionProfileFollower

      public FrcTankMotionProfileFollower(String instanceName, TrcPidController.PidCoefficients pidCoefficients, int pidSlot, double worldUnitsPerEncoderTick)
      Create FrcTankMotionProfileFollower object
      Parameters:
      instanceName - Name of the instance, duh.
      pidCoefficients - PidCoefficients object storing the PIDF constants.
      pidSlot - Index of the pid slot to store the pid constants
      worldUnitsPerEncoderTick - Number of word units per encoder tick. For example, inches per encoder tick.
  • Method Details

    • setLeftMotors

      public void setLeftMotors(FrcCANTalonSRX... leftMotors)
      Sets the motors on the left side of the drive train.
      Parameters:
      leftMotors - List of motors on the left side of the drive train. The first motor in the list will be used as the master motor, and all others will be set as slaves.
    • setRightMotors

      public void setRightMotors(FrcCANTalonSRX... rightMotors)
      Sets the motors on the right side of the drive train.
      Parameters:
      rightMotors - List of motors on the right side of the drive train. The first motor in the list will be used as the master motor, and all others will be set as slaves.
    • start

      public void start(TrcTankMotionProfile profile, TrcEvent event, double timeout)
      Start following the supplied motion profile.
      Specified by:
      start in class TrcTankMotionProfileFollower
      Parameters:
      profile - TrcTankMotionProfile object representing the path to follow. Remember to match units with worldUnitsPerEncoderTick!
      event - Event to signal when path has been followed
      timeout - Maximum number of seconds to spend following the path. 0.0 means no timeout.
    • getActiveProfile

      public TrcTankMotionProfile getActiveProfile()
      The motion profile currently being followed by the follower.
      Specified by:
      getActiveProfile in class TrcTankMotionProfileFollower
      Returns:
      The profile object currently being followed. null if not following any profile.
    • isActive

      public boolean isActive()
      Is path currently being followed?
      Specified by:
      isActive in class TrcTankMotionProfileFollower
      Returns:
      True if yes, false otherwise
    • isCancelled

      public boolean isCancelled()
      Has this task been cancelled?
      Specified by:
      isCancelled in class TrcTankMotionProfileFollower
      Returns:
      True if someone has called the cancel() method while it was running, false otherwise
    • cancel

      public void cancel()
      Stop following the path and cancel the event.
      Specified by:
      cancel in class TrcTankMotionProfileFollower
    • leftBottomBufferCount

      public int leftBottomBufferCount()
      How many trajectory points are in the bottom buffer of the left talon?
      Returns:
      Number of trajectory points in bottom buffer of left talon. -1 if MP hasn't started.
    • rightBottomBufferCount

      public int rightBottomBufferCount()
      How many trajectory points are in the bottom buffer of the right talon?
      Returns:
      Number of trajectory points in bottom buffer of right talon. -1 if MP hasn't started.
    • leftTopBufferCount

      public int leftTopBufferCount()
      How many trajectory points are in the top buffer of the left talon?
      Returns:
      Number of trajectory points in top buffer of left talon. -1 if MP hasn't started.
    • rightTopBufferCount

      public int rightTopBufferCount()
      How many trajectory points are in the top buffer of the right talon?
      Returns:
      Number of trajectory points in top buffer of right talon. -1 if MP hasn't started.
    • leftTargetPosition

      public double leftTargetPosition()
      Position target for left motor.
      Returns:
      Position target, in world units, for left motor. 0 if MP hasn't started.
    • leftActualPosition

      public double leftActualPosition()
      Position of left motor.
      Returns:
      Current position of left motor, in world units. 0 if motor isn't set.
    • rightTargetPosition

      public double rightTargetPosition()
      Position target for right motor.
      Returns:
      Position target, in world units, for right motor. 0 if MP hasn't started.
    • rightActualPosition

      public double rightActualPosition()
      Position of right motor.
      Returns:
      Current position of right motor, in world units. 0 if motor isn't set.
    • leftTargetVelocity

      public double leftTargetVelocity()
      Velocity target for left motor.
      Returns:
      Velocity target, in world units per second, for left motor. 0 if motor isn't set.
    • leftActualVelocity

      public double leftActualVelocity()
      Velocity of left motor.
      Returns:
      Current velocity of left motor, in world units per second. 0 if motor isn't set.
    • rightTargetVelocity

      public double rightTargetVelocity()
      Velocity target for right motor.
      Returns:
      Velocity target, in world units per second, for right motor. 0 if motor isn't set.
    • rightActualVelocity

      public double rightActualVelocity()
      Velocity of right motor.
      Returns:
      Current velocity of right motor, in world units per seconds. 0 if motor isn't set.
    • getLeftMaster

      public FrcCANTalonSRX getLeftMaster()
    • getRightMaster

      public FrcCANTalonSRX getRightMaster()