Package frclib.archive
Class FrcTankMotionProfileFollower
java.lang.Object
trclib.archive.TrcTankMotionProfileFollower
frclib.archive.FrcTankMotionProfileFollower
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
-
Field Summary
Fields inherited from class trclib.archive.TrcTankMotionProfileFollower
instanceName
-
Constructor Summary
ConstructorsConstructorDescriptionFrcTankMotionProfileFollower
(String instanceName, TrcPidController.PidCoefficients pidCoefficients, double worldUnitsPerEncoderTick) Create FrcTankMotionProfileFollower object.FrcTankMotionProfileFollower
(String instanceName, TrcPidController.PidCoefficients pidCoefficients, int pidSlot, double worldUnitsPerEncoderTick) Create FrcTankMotionProfileFollower object -
Method Summary
Modifier and TypeMethodDescriptionvoid
cancel()
Stop following the path and cancel the event.The motion profile currently being followed by the follower.boolean
isActive()
Is path currently being followed?boolean
Has this task been cancelled?double
Position of left motor.double
Velocity of left motor.int
How many trajectory points are in the bottom buffer of the left talon?double
Position target for left motor.double
Velocity target for left motor.int
How many trajectory points are in the top buffer of the left talon?double
Position of right motor.double
Velocity of right motor.int
How many trajectory points are in the bottom buffer of the right talon?double
Position target for right motor.double
Velocity target for right motor.int
How many trajectory points are in the top buffer of the right talon?void
setLeftMotors
(FrcCANTalonSRX... leftMotors) Sets the motors on the left side of the drive train.void
setRightMotors
(FrcCANTalonSRX... rightMotors) Sets the motors on the right side of the drive train.void
start
(TrcTankMotionProfile profile, TrcEvent event, double timeout) Start following the supplied motion profile.Methods inherited from class trclib.archive.TrcTankMotionProfileFollower
start, start, toString
-
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 constantsworldUnitsPerEncoderTick
- Number of word units per encoder tick. For example, inches per encoder tick.
-
-
Method Details
-
setLeftMotors
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
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
Start following the supplied motion profile.- Specified by:
start
in classTrcTankMotionProfileFollower
- Parameters:
profile
- TrcTankMotionProfile object representing the path to follow. Remember to match units with worldUnitsPerEncoderTick!event
- Event to signal when path has been followedtimeout
- Maximum number of seconds to spend following the path. 0.0 means no timeout.
-
getActiveProfile
The motion profile currently being followed by the follower.- Specified by:
getActiveProfile
in classTrcTankMotionProfileFollower
- 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 classTrcTankMotionProfileFollower
- Returns:
- True if yes, false otherwise
-
isCancelled
public boolean isCancelled()Has this task been cancelled?- Specified by:
isCancelled
in classTrcTankMotionProfileFollower
- 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 classTrcTankMotionProfileFollower
-
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
-
getRightMaster
-