|
| 1 | +package com.team4099.robot2023.auto.mode |
| 2 | + |
| 3 | +import com.team4099.lib.trajectory.FieldWaypoint |
| 4 | +import com.team4099.robot2023.commands.drivetrain.DrivePathCommand |
| 5 | +import com.team4099.robot2023.config.constants.FlywheelConstants |
| 6 | +import com.team4099.robot2023.subsystems.drivetrain.drive.Drivetrain |
| 7 | +import com.team4099.robot2023.subsystems.superstructure.Superstructure |
| 8 | +import edu.wpi.first.wpilibj2.command.ParallelCommandGroup |
| 9 | +import edu.wpi.first.wpilibj2.command.SequentialCommandGroup |
| 10 | +import edu.wpi.first.wpilibj2.command.WaitCommand |
| 11 | +import org.team4099.lib.geometry.Pose2d |
| 12 | +import org.team4099.lib.geometry.Translation2d |
| 13 | +import org.team4099.lib.units.base.inSeconds |
| 14 | +import org.team4099.lib.units.base.inches |
| 15 | +import org.team4099.lib.units.base.meters |
| 16 | +import org.team4099.lib.units.derived.degrees |
| 17 | +import org.team4099.lib.units.derived.inRotation2ds |
| 18 | + |
| 19 | +class FourNoteAutoPathWithFirstCenterSide(val drivetrain: Drivetrain, val superstructure: Superstructure) : |
| 20 | + SequentialCommandGroup() { |
| 21 | + init { |
| 22 | + addRequirements(drivetrain, superstructure) |
| 23 | + |
| 24 | + addCommands( |
| 25 | + superstructure.prepSpeakerLowCommand(), |
| 26 | + superstructure.scoreCommand().withTimeout(0.5), |
| 27 | + WaitCommand(0.5), |
| 28 | + ParallelCommandGroup( |
| 29 | + DrivePathCommand.createPathInFieldFrame( |
| 30 | + drivetrain, |
| 31 | + { |
| 32 | + listOf( |
| 33 | + FieldWaypoint( |
| 34 | + startingPose.translation.translation2d, |
| 35 | + null, |
| 36 | + 180.degrees.inRotation2ds |
| 37 | + ), |
| 38 | + FieldWaypoint( |
| 39 | + Translation2d( |
| 40 | + ((1.43.meters) + (2.34.meters + 0.3.meters)) / 2 + |
| 41 | + 0.25.meters, |
| 42 | + 5.55.meters |
| 43 | + ) |
| 44 | + .translation2d, |
| 45 | + null, |
| 46 | + 180.degrees.inRotation2ds |
| 47 | + ), |
| 48 | + FieldWaypoint( |
| 49 | + Translation2d(2.34.meters + 0.3.meters + 0.25.meters, 5.535.meters) |
| 50 | + .translation2d, |
| 51 | + null, |
| 52 | + 180.degrees.inRotation2ds |
| 53 | + ), |
| 54 | + FieldWaypoint( |
| 55 | + Translation2d( |
| 56 | + ((1.43.meters) + (2.34.meters + 0.3.meters)) / 2 + |
| 57 | + 0.25.meters, |
| 58 | + 5.45.meters |
| 59 | + ) |
| 60 | + .translation2d, |
| 61 | + null, |
| 62 | + 180.degrees.inRotation2ds |
| 63 | + ), |
| 64 | + FieldWaypoint( |
| 65 | + startingPose.translation.translation2d, |
| 66 | + null, |
| 67 | + 180.degrees.inRotation2ds |
| 68 | + ) // Subwoofer |
| 69 | + ) |
| 70 | + } |
| 71 | + ) |
| 72 | + .withTimeout(3.235 + 0.5), |
| 73 | + WaitCommand(0.3).andThen(superstructure.groundIntakeCommand()) |
| 74 | + ), |
| 75 | + superstructure.prepSpeakerLowCommand(), |
| 76 | + superstructure |
| 77 | + .scoreCommand() |
| 78 | + .withTimeout(FlywheelConstants.SPEAKER_SCORE_TIME.inSeconds + 0.5), |
| 79 | + WaitCommand(FlywheelConstants.SPEAKER_SCORE_TIME.inSeconds), |
| 80 | + ParallelCommandGroup( |
| 81 | + DrivePathCommand.createPathInFieldFrame( |
| 82 | + drivetrain, |
| 83 | + { |
| 84 | + listOf( |
| 85 | + FieldWaypoint( |
| 86 | + startingPose.translation.translation2d, |
| 87 | + null, |
| 88 | + 180.degrees.inRotation2ds |
| 89 | + ), // Subwoofer |
| 90 | + FieldWaypoint( |
| 91 | + Translation2d(2.41.meters - 0.4.meters, 4.4.meters).translation2d, |
| 92 | + null, |
| 93 | + 180.degrees.inRotation2ds |
| 94 | + ), |
| 95 | + FieldWaypoint( |
| 96 | + Translation2d(2.41.meters, 4.1.meters).translation2d, |
| 97 | + 0.degrees.inRotation2ds, |
| 98 | + 180.degrees.inRotation2ds |
| 99 | + ), |
| 100 | + FieldWaypoint( |
| 101 | + startingPose.translation.translation2d, |
| 102 | + null, |
| 103 | + 180.degrees.inRotation2ds |
| 104 | + ) |
| 105 | + ) |
| 106 | + } |
| 107 | + ) |
| 108 | + .withTimeout(3.235 + 0.5), |
| 109 | + WaitCommand(0.5).andThen(superstructure.groundIntakeCommand()) |
| 110 | + ), |
| 111 | + superstructure.prepSpeakerLowCommand(), |
| 112 | + superstructure |
| 113 | + .scoreCommand() |
| 114 | + .withTimeout(FlywheelConstants.SPEAKER_SCORE_TIME.inSeconds + 0.5), |
| 115 | + WaitCommand(FlywheelConstants.SPEAKER_SCORE_TIME.inSeconds), |
| 116 | + ParallelCommandGroup( |
| 117 | + DrivePathCommand.createPathInFieldFrame( |
| 118 | + drivetrain, |
| 119 | + { |
| 120 | + listOf( |
| 121 | + FieldWaypoint( |
| 122 | + startingPose.translation.translation2d, |
| 123 | + null, |
| 124 | + startingPose.rotation.inRotation2ds |
| 125 | + ), |
| 126 | + FieldWaypoint( |
| 127 | + Translation2d(2.91.meters - 0.75.meters, 6.9.meters) |
| 128 | + .translation2d, |
| 129 | + null, |
| 130 | + 180.degrees.inRotation2ds, |
| 131 | + ), |
| 132 | + FieldWaypoint( |
| 133 | + Translation2d(2.91.meters - 0.25.meters, 7.1.meters).translation2d, |
| 134 | + 0.degrees.inRotation2ds, |
| 135 | + 180.degrees.inRotation2ds, |
| 136 | + ), |
| 137 | + FieldWaypoint( |
| 138 | + startingPose.translation.translation2d, |
| 139 | + null, |
| 140 | + 180.degrees.inRotation2ds |
| 141 | + ) |
| 142 | + ) |
| 143 | + } |
| 144 | + ) |
| 145 | + .withTimeout(3.235 + 0.5), |
| 146 | + WaitCommand(0.5).andThen(superstructure.groundIntakeCommand()) |
| 147 | + ), |
| 148 | + superstructure.prepSpeakerLowCommand(), |
| 149 | + superstructure |
| 150 | + .scoreCommand() |
| 151 | + .withTimeout(FlywheelConstants.SPEAKER_SCORE_TIME.inSeconds + 0.5), |
| 152 | + ParallelCommandGroup( |
| 153 | + DrivePathCommand.createPathInFieldFrame( |
| 154 | + drivetrain, |
| 155 | + { |
| 156 | + listOf( |
| 157 | + FieldWaypoint( |
| 158 | + startingPose.translation.translation2d, null, 180.degrees.inRotation2ds |
| 159 | + ), |
| 160 | + FieldWaypoint( |
| 161 | + Translation2d(4.35.meters, 4.85.meters).translation2d, |
| 162 | + null, |
| 163 | + 180.degrees.inRotation2ds |
| 164 | + ), |
| 165 | + FieldWaypoint( |
| 166 | + Translation2d(5.92.meters, 3.9.meters).translation2d, |
| 167 | + null, |
| 168 | + 180.degrees.inRotation2ds |
| 169 | + ), |
| 170 | + FieldWaypoint( |
| 171 | + Translation2d(8.29.meters, 4.09.meters).translation2d, |
| 172 | + null, |
| 173 | + 180.degrees.inRotation2ds |
| 174 | + ) |
| 175 | + ) |
| 176 | + } |
| 177 | + ), |
| 178 | + WaitCommand(1.0).andThen(superstructure.groundIntakeCommand()) |
| 179 | + ) |
| 180 | + ) |
| 181 | + } |
| 182 | + |
| 183 | + companion object { |
| 184 | + val startingPose = Pose2d(Translation2d(1.42.meters + 1.inches, 5.535.meters), 180.degrees) |
| 185 | + } |
| 186 | +} |
0 commit comments