X-Git-Url: http://challenge-bot.com/repos/?p=3501%2F2017steamworks;a=blobdiff_plain;f=src%2Forg%2Fusfirst%2Ffrc%2Fteam3501%2Frobot%2Fcommandgroups%2FAutonGearThenBaselinePegCloseToBoiler.java;fp=src%2Forg%2Fusfirst%2Ffrc%2Fteam3501%2Frobot%2Fcommandgroups%2FAutonGearThenBaselinePegCloseToBoiler.java;h=6af22a452c7bfa5bc65162c5967467b0b4953776;hp=0000000000000000000000000000000000000000;hb=fca066b62b8397aed068671c3ac90e7139177467;hpb=ac77a7b890c794f807b764221ff72d9044791fab diff --git a/src/org/usfirst/frc/team3501/robot/commandgroups/AutonGearThenBaselinePegCloseToBoiler.java b/src/org/usfirst/frc/team3501/robot/commandgroups/AutonGearThenBaselinePegCloseToBoiler.java new file mode 100644 index 0000000..6af22a4 --- /dev/null +++ b/src/org/usfirst/frc/team3501/robot/commandgroups/AutonGearThenBaselinePegCloseToBoiler.java @@ -0,0 +1,101 @@ +package org.usfirst.frc.team3501.robot.commandgroups; + +import org.usfirst.frc.team3501.robot.Constants.Direction; +import org.usfirst.frc.team3501.robot.Robot; +import org.usfirst.frc.team3501.robot.commands.driving.DriveDistance; +import org.usfirst.frc.team3501.robot.commands.driving.TurnForAngle; + +import edu.wpi.first.wpilibj.command.CommandGroup; + +/** + * this is an auton strategy to cross the baseline and put a gear on a peg + * requires predetermined starting point anywhere except between 109.1767 inches + * and 205.7286 inches from the right side of the arena this program chooses + * which peg to go for based on the starting point + */ +public class AutonGearThenBaselinePegCloseToBoiler extends CommandGroup + +{ + + private static final double ROBOT_LENGTH = 40.0; + private static final double ROBOT_WIDTH = 36.0; + + private static final double DISTANCE_TO_PEG_EXTENDED_BOILER = 73.1657; + private static final double DISTANCE_TO_PEG_EXTENDED_RETRIEVAL_ZONE = 114.3 + + 17.625 - ((162 - (17.625 + 35.25) - 38.625) / Math.sqrt(3)); + private static final double FIRST_LIMIT_LENGTH = 75.649; + private static final double SECOND_LIMIT_LENGTH = 162.8289106736; + private static final double LENGTH_OF_PEG = 10.5; + private static final double PEG_EXTENDED_BOILER = 117.518; + private static final double PEG_EXTENDED_RETRIEVAL_ZONE = (DISTANCE_TO_PEG_EXTENDED_RETRIEVAL_ZONE + * 2) / Math.sqrt(3); + private static final double DISTANCE_BETWEEN_BOILER_AND_RETRIEVAL_ZONE = 255.6765151902; + private static final double MOTOR_VALUE_TURN = 0.5;// this is probably not + // correct + private static final double MOTOR_VALUE_FORWARD = 0.5;// random + double distanceFromCorner; // This is the starting point + // from the right side of the + // arena in inches (can change) + + /*** + * + * @param team + * which side to start on: "BLUE" for blue side and "RED" for red + * side + * @param distanceFromBoilerCorner + * distance from the corner of the boiler + */ + public AutonGearThenBaselinePegCloseToBoiler(String team, + int distanceFromBoilerCorner) { + + this.distanceFromCorner = distanceFromBoilerCorner; + requires(Robot.getDriveTrain()); + if (distanceFromBoilerCorner >= 0 + && distanceFromBoilerCorner < FIRST_LIMIT_LENGTH) { + // boiler peg path + + // drive straight into extended line of peg + addSequential( + new DriveDistance( + ((distanceFromCorner + (ROBOT_WIDTH / 2.0)) / Math.sqrt(3)) + + DISTANCE_TO_PEG_EXTENDED_BOILER - (ROBOT_LENGTH / 2.0), + MOTOR_VALUE_FORWARD)); + // position robot for optimal gear placement + addSequential(new TurnForAngle(60, Direction.LEFT, MOTOR_VALUE_TURN)); + // put gear on peg + addSequential(new DriveDistance(PEG_EXTENDED_BOILER + - (((distanceFromCorner + (ROBOT_WIDTH / 2.0)) * 2) + / Math.sqrt(3)) + - LENGTH_OF_PEG - (ROBOT_LENGTH / 2.0), + MOTOR_VALUE_FORWARD)); + + // does not include drift distance + } else if (distanceFromBoilerCorner > SECOND_LIMIT_LENGTH + && distanceFromBoilerCorner <= DISTANCE_BETWEEN_BOILER_AND_RETRIEVAL_ZONE) // mirror + // of + // right + // peg + // path + { + this.distanceFromCorner = DISTANCE_BETWEEN_BOILER_AND_RETRIEVAL_ZONE + - distanceFromBoilerCorner; + // Turning DISTANCE_FROM_BOILER_WALL into starting point from left side by + // reversing it + addSequential( + new DriveDistance( + ((distanceFromCorner + (ROBOT_WIDTH / 2.0)) / Math.sqrt(3)) + + DISTANCE_TO_PEG_EXTENDED_RETRIEVAL_ZONE + - (ROBOT_LENGTH / 2.0), + MOTOR_VALUE_FORWARD)); + addSequential(new TurnForAngle(60, Direction.RIGHT, MOTOR_VALUE_TURN)); + addSequential(new DriveDistance(PEG_EXTENDED_RETRIEVAL_ZONE + - (((distanceFromCorner + (ROBOT_LENGTH / 2.0)) / Math.sqrt(3)) * 2) + - LENGTH_OF_PEG - (ROBOT_LENGTH / 2.0), + MOTOR_VALUE_FORWARD)); + // does not include drift distance + } else { + System.out.println( + "DO NOT START HERE!!! MOVE CLOSER TO A WALL OR LOSE ALL AUTON POINTS!!"); + } + } +}