11package frc.robot.commands
22
33import cshcyberhawks.lib.math.MiscCalculations
4+ import edu.wpi.first.math.geometry.Rotation2d
45import edu.wpi.first.wpilibj2.command.Command
56import frc.robot.RobotContainer
67import frc.robot.constants.AutoScoringConstants
@@ -36,14 +37,18 @@ object TeleopAutoAlign {
3637 if (OperatorControls .noWalk) {
3738 AllianceFlipUtil .apply (AutoScoringConstants .getReefPoseAtOffset(position.ordinal, side, 0.0 ))
3839 } else {
39- val goalPose = AllianceFlipUtil .apply (AutoScoringConstants .getReefPoseAtOffset(position.ordinal, side, 0.0 ))
40+ val goalPose =
41+ AllianceFlipUtil .apply (AutoScoringConstants .getReefPoseAtOffset(position.ordinal, side, 0.0 ))
4042 // Make the position get closer as it gets closer to the final goal
4143// val adjustX: Double = 0.3
42- var adjustX: Double = min(1.0 , RobotContainer .drivetrain.getSwervePose().translation.getDistance(goalPose.translation) * 0.75 )
44+ var adjustX: Double = min(
45+ 1.0 ,
46+ RobotContainer .drivetrain.getSwervePose().translation.getDistance(goalPose.translation) * 0.5
47+ )
4348// val adjustX = 1.0
4449
4550 // Once we're close enough we can just jump to the goal
46- if (adjustX < 0.25 ) {
51+ if (adjustX < 0.2 ) {
4752 adjustX = 0.0
4853 }
4954
@@ -62,11 +67,14 @@ object TeleopAutoAlign {
6267 val goalPose = AllianceFlipUtil .apply (AutoScoringConstants .getAlgaePoseAtOffset(position.ordinal, 0.0 ))
6368 // Make the position get closer as it gets closer to the final goal
6469// val adjustX: Double = 0.3
65- var adjustX: Double = min(1.0 , RobotContainer .drivetrain.getSwervePose().translation.getDistance(goalPose.translation) * 0.75 )
70+ var adjustX: Double = min(
71+ 1.0 ,
72+ RobotContainer .drivetrain.getSwervePose().translation.getDistance(goalPose.translation) * .5
73+ )
6674// val adjustX = 1.0
6775
6876 // Once we're close enough we can just jump to the goal
69- if (adjustX < 0.25 ) {
77+ if (adjustX < 0.2 ) {
7078 adjustX = 0.0
7179 }
7280
@@ -75,18 +83,48 @@ object TeleopAutoAlign {
7583 })
7684 }
7785
78- fun processorAlign (): Command = GoToPose ( {
79- AllianceFlipUtil . apply ( FieldConstants .processorPosition)
80- }, { false })
86+ fun l1ReefAlign (): Command {
87+ return GoToPose ({
88+ val position = OperatorControls .reefPosition
8189
82- fun feederAlign (): Command = GoToPose ({
83- val leftPos = AllianceFlipUtil .apply (FieldConstants .leftFeederPosition)
84- val rightPos = AllianceFlipUtil .apply (FieldConstants .rightFeederPosition)
90+ if (OperatorControls .noWalk) {
91+ AllianceFlipUtil .apply (AutoScoringConstants .getL1PoseAtOffset(position.ordinal, 0.0 ))
92+ } else {
93+ val goalPose =
94+ AllianceFlipUtil .apply (AutoScoringConstants .getL1PoseAtOffset(position.ordinal, 0.0 ))
95+ // Make the position get closer as it gets closer to the final goal
96+ // val adjustX: Double = 0.3
97+ var adjustX: Double = min(
98+ 1.0 ,
99+ RobotContainer .drivetrain.getSwervePose().translation.getDistance(goalPose.translation) * 0.5
100+ )
101+ // val adjustX = 1.0
102+
103+ // Once we're close enough we can just jump to the goal
104+ if (adjustX < 0.2 ) {
105+ adjustX = 0.0
106+ }
85107
86- if (RobotContainer .drivetrain.getSwervePose().translation.getDistance(leftPos.translation) < RobotContainer .drivetrain.getSwervePose().translation.getDistance(rightPos.translation)) {
87- leftPos
88- } else {
89- rightPos
108+ AllianceFlipUtil .apply (AutoScoringConstants .getL1PoseAtOffset(position.ordinal, adjustX))
109+ }
110+ })
90111 }
91- }, { false })
92- }
112+
113+ fun processorAlign (): Command = GoToPose ({
114+ AllianceFlipUtil .apply (FieldConstants .processorPosition)
115+ }, { false })
116+
117+ fun feederAlign (): Command = GoToPose ({
118+ val leftPos = AllianceFlipUtil .apply (FieldConstants .leftFeederPosition)
119+ val rightPos = AllianceFlipUtil .apply (FieldConstants .rightFeederPosition)
120+
121+ if (RobotContainer .drivetrain.getSwervePose().translation.getDistance(leftPos.translation) < RobotContainer .drivetrain.getSwervePose().translation.getDistance(
122+ rightPos.translation
123+ )
124+ ) {
125+ leftPos
126+ } else {
127+ rightPos
128+ }
129+ }, { false })
130+ }
0 commit comments