Package frc.robot
Class SwervePIDController
java.lang.Object
frc.robot.SwervePIDController
Controls automatic alignment for driver assistance.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classStores the poses of alignment targets on the field. -
Field Summary
FieldsModifier and TypeFieldDescriptionbooleanbooleanstatic SwervePIDControllerbooleanedu.wpi.first.math.geometry.Rotation2ddoubleedu.wpi.first.math.geometry.Pose2d -
Method Summary
Modifier and TypeMethodDescriptionedu.wpi.first.math.kinematics.ChassisSpeedsapplyMovementConstraints(edu.wpi.first.math.kinematics.ChassisSpeeds target_speeds) Applies velocity and acceleration constraints to desired speeds.edu.wpi.first.math.kinematics.ChassisSpeedsCalculate the chassis speeds to position PID to the target pose.edu.wpi.first.math.kinematics.ChassisSpeedscalculate(boolean useTargetAngle) Calculate the chassis speeds to position PID to the target pose.voidconfigure(edu.wpi.first.math.geometry.Pose2d target_pose, Double target_distance, edu.wpi.first.math.geometry.Rotation2d rotation_offset) intReturns the closest reef face to the robot.edu.wpi.first.math.geometry.Pose2dedu.wpi.first.math.geometry.Pose2dgetNearestReefPose(int offset) edu.wpi.first.math.geometry.Pose2dedu.wpi.first.math.geometry.Pose2dedu.wpi.first.math.geometry.Pose2dgetReefPose(int index)
-
Field Details
-
instance
-
target_pose
public edu.wpi.first.math.geometry.Pose2d target_pose -
target_distance
public double target_distance -
rotation_offset
public edu.wpi.first.math.geometry.Rotation2d rotation_offset -
reset_speeds
public boolean reset_speeds -
done
public boolean done -
align_right
public boolean align_right
-
-
Method Details
-
getNearestReefFace
public int getNearestReefFace()Returns the closest reef face to the robot. The driverstation-oriented face is 0, and the rest are numbered CCW increasing.- Returns:
- The number corresponding the closest reef face.
-
getReefPose
public edu.wpi.first.math.geometry.Pose2d getReefPose(int index) -
getNearestReefPose
public edu.wpi.first.math.geometry.Pose2d getNearestReefPose(int offset) -
getNearestReefPose
public edu.wpi.first.math.geometry.Pose2d getNearestReefPose() -
getProcessorPose
public edu.wpi.first.math.geometry.Pose2d getProcessorPose() -
getNearestSourcePose
public edu.wpi.first.math.geometry.Pose2d getNearestSourcePose() -
configure
public void configure(edu.wpi.first.math.geometry.Pose2d target_pose, Double target_distance, edu.wpi.first.math.geometry.Rotation2d rotation_offset) -
applyMovementConstraints
public edu.wpi.first.math.kinematics.ChassisSpeeds applyMovementConstraints(edu.wpi.first.math.kinematics.ChassisSpeeds target_speeds) Applies velocity and acceleration constraints to desired speeds.- Parameters:
target_speeds- The desired robot-relative chassis speeds.- Returns:
- The constrained robot-relative chassis speeds.
-
calculate
public edu.wpi.first.math.kinematics.ChassisSpeeds calculate()Calculate the chassis speeds to position PID to the target pose. Points towards the target.- Returns:
- The calculated chassis speeds.
-
calculate
public edu.wpi.first.math.kinematics.ChassisSpeeds calculate(boolean useTargetAngle) Calculate the chassis speeds to position PID to the target pose.- Parameters:
useTargetAngle- Whether or not to use the rotation value from the stored target pose.- Returns:
- The calculated chassis speeds.
-