Skip to content

Commit

Permalink
Changed up auto trajectories slightly to account for the fact that th…
Browse files Browse the repository at this point in the history
…e robot is not a point mass, changed generation so that saving does NOT occur on the bot, now we just load csv files
  • Loading branch information
Team Computer committed Mar 22, 2018
1 parent f0ebf07 commit d631b73
Show file tree
Hide file tree
Showing 12 changed files with 86 additions and 49 deletions.
Binary file removed build/jars/CTRLib.jar
Binary file not shown.
Binary file added build/jars/Pathfinder-Java-1.8.jar
Binary file not shown.
Binary file modified build/org/usfirst/frc/team1160/robot/OI.class
Binary file not shown.
Binary file modified build/org/usfirst/frc/team1160/robot/Robot.class
Binary file not shown.
Binary file modified build/org/usfirst/frc/team1160/robot/RobotMap.class
Binary file not shown.
Binary file modified build/org/usfirst/frc/team1160/robot/TrajectoryWaypoints.class
Binary file not shown.
Binary file not shown.
Binary file modified build/org/usfirst/frc/team1160/robot/subsystems/DriveTrain.class
Binary file not shown.
4 changes: 2 additions & 2 deletions src/org/usfirst/frc/team1160/robot/OI.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ private void tieButtons() {
highGear.whenPressed(new HighGear());
lowGear.whenPressed(new LowGear());

intakeEat.whileHeld(new IntakeRotate(1));
intakeSpit.whileHeld(new IntakeRotate(-1));
intakeEat.whileHeld(new IntakeRotate(0.7));
intakeSpit.whileHeld(new IntakeRotate(-0.7));

extendClimber.whenPressed(new LatchExtend());
retractClimber.whenPressed(new LatchRetract());
Expand Down
104 changes: 62 additions & 42 deletions src/org/usfirst/frc/team1160/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ public void robotInit() {
* Center to Left Switch Backwards: 4
* Center to Right Switch: 5
*/
saveTrajectoriesAll();
//saveTrajectoriesAll();
autonomousCommand = new TurnAngle(90);

}

Expand Down Expand Up @@ -119,7 +120,9 @@ public void generateSegments(int choice) { //let's be even more honest, you shou
//autonomousCommand = new Center_LeftSwitchBW();
break;
case 5: //Center to Right Switch
segment_one = dt.generateTrajectorySetup(CENTER_RIGHT_SWITCH);
segment_one = dt.generateTrajectorySetup(CENTER_RIGHT_SWITCH_1);
segment_two = dt.generateTrajectorySetup(CENTER_RIGHT_SWITCH_2);
segment_three = dt.generateTrajectorySetup(CENTER_RIGHT_SWITCH_3);
autonomousCommand = new Center_RightSwitch();
break;
case 6: //Custom
Expand All @@ -139,25 +142,29 @@ public void saveTrajectories(int choice) { //let's be honest, you should only ha
switch (choice) {
case 1:
generateSegments(1);
file_one = new File("CENTER_LEFT_SWITCH_1.csv");
Pathfinder.writeToCSV(file_one, segment_one);
file_one = new File("CENTER_LEFT_SWITCH_2.csv");
Pathfinder.writeToCSV(file_one, segment_two);
file_one = new File("CENTER_LEFT_SWITCH_3.csv");
Pathfinder.writeToCSV(file_one, segment_three);
file_one = new File("CENTER_LEFT_SWITCH_1.traj");
Pathfinder.writeToFile(file_one, segment_one);
file_one = new File("CENTER_LEFT_SWITCH_2.traj");
Pathfinder.writeToFile(file_one, segment_two);
file_one = new File("CENTER_LEFT_SWITCH_3.traj");
Pathfinder.writeToFile(file_one, segment_three);
break;
case 2:
case 3:
generateSegments(2);
file_one = new File("X_X_SWITCH_1.csv");
Pathfinder.writeToCSV(file_one, segment_one);
file_one = new File("X_X_SWITCH_2.csv");
Pathfinder.writeToCSV(file_one, segment_two);
file_one = new File("X_X_SWITCH_1.traj");
Pathfinder.writeToFile(file_one, segment_one);
file_one = new File("X_X_SWITCH_2.traj");
Pathfinder.writeToFile(file_one, segment_two);
break;
case 5:
generateSegments(5);
file_one = new File("CENTER_RIGHT_SWITCH.csv");
Pathfinder.writeToCSV(file_one, segment_one);
file_one = new File("CENTER_RIGHT_SWITCH_1.traj");
Pathfinder.writeToFile(file_one, segment_one);
file_one = new File("CENTER_RIGHT_SWITCH_2.traj");
Pathfinder.writeToFile(file_one, segment_two);
file_one = new File("CENTER_RIGHT_SWITCH_3.traj");
Pathfinder.writeToFile(file_one, segment_three);
break;
default:
System.out.println("Hold this even bigger L");
Expand All @@ -171,52 +178,65 @@ public void saveTrajectoriesAll()
{ //Kobe: "Just save them all"
File file_one;
generateSegments(1);
file_one = new File("CENTER_LEFT_SWITCH_1.csv");
Pathfinder.writeToCSV(file_one, segment_one);
file_one = new File("CENTER_LEFT_SWITCH_2.csv");
Pathfinder.writeToCSV(file_one, segment_two);
file_one = new File("CENTER_LEFT_SWITCH_3.csv");
Pathfinder.writeToCSV(file_one, segment_three);
//file_one = new File("CENTER_LEFT_SWITCH_1.traj");
file_one = new File("CLS1.traj");
System.out.println("Attempted to save center left switch 1");
Pathfinder.writeToFile(file_one, segment_one);
System.out.println("Successfully saved center left switch 1");
file_one = new File("CENTER_LEFT_SWITCH_2.traj");
Pathfinder.writeToFile(file_one, segment_two);
file_one = new File("CENTER_LEFT_SWITCH_3.traj");
Pathfinder.writeToFile(file_one, segment_three);
generateSegments(2);
file_one = new File("X_X_SWITCH_1.csv");
Pathfinder.writeToCSV(file_one, segment_one);
file_one = new File("X_X_SWITCH_2.csv");
Pathfinder.writeToCSV(file_one, segment_two);
file_one = new File("X_X_SWITCH_1.traj");
Pathfinder.writeToFile(file_one, segment_one);
file_one = new File("X_X_SWITCH_2.traj");
Pathfinder.writeToFile(file_one, segment_two);
generateSegments(5);
file_one = new File("CENTER_RIGHT_SWITCH.csv");
Pathfinder.writeToCSV(file_one, segment_one);
file_one = new File("CENTER_RIGHT_SWITCH_1.traj");
Pathfinder.writeToFile(file_one, segment_one);
file_one = new File("CENTER_RIGHT_SWITCH_2.traj");
Pathfinder.writeToFile(file_one, segment_two);
file_one = new File("CENTER_RIGHT_SWITCH_3.traj");
Pathfinder.writeToFile(file_one, segment_three);

System.out.println("All paths saved to csv");
}

public void loadTrajectories(int choice) { //now this is the good stuff, this is what you wanna run 25/7
File file_one;
switch (choice)
{
case 1:
file_one = new File("CENTER_LEFT_SWITCH_1.csv");
segment_one = Pathfinder.readFromCSV(file_one);
file_one = new File("CENTER_LEFT_SWITCH_2.csv");
segment_two = Pathfinder.readFromCSV(file_one);
file_one = new File("CENTER_LEFT_SWITCH_3.csv");
segment_three = Pathfinder.readFromCSV(file_one);
file_one = new File("CENTER_LEFT_SWITCH_1.traj");
segment_one = Pathfinder.readFromFile(file_one);
file_one = new File("CENTER_LEFT_SWITCH_2.traj");
segment_two = Pathfinder.readFromFile(file_one);
file_one = new File("CENTER_LEFT_SWITCH_3.traj");
segment_three = Pathfinder.readFromFile(file_one);
autonomousCommand = new Center_LeftSwitch();
break;
case 2:
file_one = new File("X_X_SWITCH_1.csv");
segment_one = Pathfinder.readFromCSV(file_one);
file_one = new File("X_X_SWITCH_2.csv");
segment_two = Pathfinder.readFromCSV(file_one);
file_one = new File("X_X_SWITCH_1.traj");
segment_one = Pathfinder.readFromFile(file_one);
file_one = new File("X_X_SWITCH_2.traj");
segment_two = Pathfinder.readFromFile(file_one);
autonomousCommand = new Left_LeftSwitch();
break;
case 3:
file_one = new File("X_X_SWITCH_1.csv");
segment_one = Pathfinder.readFromCSV(file_one);
file_one = new File("X_X_SWITCH_2.csv");
segment_two = Pathfinder.readFromCSV(file_one);
file_one = new File("X_X_SWITCH_1.traj");
segment_one = Pathfinder.readFromFile(file_one);
file_one = new File("X_X_SWITCH_2.traj");
segment_two = Pathfinder.readFromFile(file_one);
autonomousCommand = new Right_RightSwitch();
break;
case 5:
file_one = new File("CENTER_RIGHT_SWITCH.csv");
segment_one = Pathfinder.readFromCSV(file_one);
file_one = new File("CENTER_RIGHT_SWITCH_1.traj");
segment_one = Pathfinder.readFromFile(file_one);
file_one = new File("CENTER_RIGHT_SWITCH_2.traj");
segment_two = Pathfinder.readFromFile(file_one);
file_one = new File("CENTER_RIGHT_SWITCH_3.traj");
segment_three = Pathfinder.readFromFile(file_one);
autonomousCommand = new Center_RightSwitch();
break;
default:
Expand Down
19 changes: 14 additions & 5 deletions src/org/usfirst/frc/team1160/robot/TrajectoryWaypoints.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ public interface TrajectoryWaypoints {

//From the center to the left switch
public static final Waypoint[] CENTER_LEFT_SWITCH_1 =
new Waypoint[] {new Waypoint(0,0,0),new Waypoint(3,0,0)};
new Waypoint[] {new Waypoint(0,0,0),new Waypoint(2,0,0)};
public static final Waypoint[] CENTER_LEFT_SWITCH_2 =
new Waypoint[] {new Waypoint(0,0,0),new Waypoint(40*Math.pow(2, 0.5)/12,0,0)};
new Waypoint[] {new Waypoint(0,0,0),new Waypoint(5.0*Math.pow(2, 0.5),0,0)};
public static final Waypoint[] CENTER_LEFT_SWITCH_3 =
new Waypoint[] {new Waypoint(0,0,0),new Waypoint(64/12,0,0)};
new Waypoint[] {new Waypoint(0,0,0),new Waypoint(2.0,0,0)};

//From the center to the left switch BACKWARDS
public static final Waypoint[] CENTER_LEFT_SWITCH_1_BACKWARDS =
Expand All @@ -38,14 +38,23 @@ public interface TrajectoryWaypoints {
new Waypoint[] {new Waypoint(0,0,0),new Waypoint(-64/12,0,0)};

//From the center to the right switch

/* THIS IS FROM PRE-THURSDAY LV CODE
public static final Waypoint[] CENTER_RIGHT_SWITCH =
new Waypoint[] {new Waypoint(0,0,0),new Waypoint(140/12,0,0)};
*/
public static final Waypoint[] CENTER_RIGHT_SWITCH_1 =
new Waypoint[] {new Waypoint(0,0,0),new Waypoint(2,0,0)};
public static final Waypoint[] CENTER_RIGHT_SWITCH_2 =
new Waypoint[] {new Waypoint(0,0,0),new Waypoint(4.5*Math.pow(2, 0.5),0,0)};
public static final Waypoint[] CENTER_RIGHT_SWITCH_3 =
new Waypoint[] {new Waypoint(0,0,0),new Waypoint(2,0,0)};

//From the X side to the X switch where X is either left or right
public static final Waypoint[] X_X_SWITCH_1 =
new Waypoint[] {new Waypoint(0,0,0),new Waypoint(168.0/12.0,0,0)};
new Waypoint[] {new Waypoint(0,0,0),new Waypoint(12.4,0,0)};
public static final Waypoint[] X_X_SWITCH_2 =
new Waypoint[] {new Waypoint(0,0,0),new Waypoint(42.0/12.0,0,0)};
new Waypoint[] {new Waypoint(0,0,0),new Waypoint(1.5,0,0)};

//Straight line from start to switch
public static final Waypoint[] START_SWITCH =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.usfirst.frc.team1160.robot.commands.auto.drive.FollowTrajectory;
import org.usfirst.frc.team1160.robot.commands.auto.drive.TurnAngle;
import org.usfirst.frc.team1160.robot.commands.auto.intake.AutoBoxSpit;
import org.usfirst.frc.team1160.robot.commands.auto.lift.BangBangMove;
import org.usfirst.frc.team1160.robot.commands.intake.IntakeExtend;
import org.usfirst.frc.team1160.robot.commands.intake.Toggle;

Expand All @@ -19,6 +20,13 @@ public Center_RightSwitch() {
addSequential(new IntakeExtend());
addSequential(new ResetEncoderYaw());
addSequential(new FollowTrajectory(Robot.segment_one));
addSequential(new TurnAngle(45));
addSequential(new ResetEncoderYaw());
addSequential(new FollowTrajectory(Robot.segment_two));
addSequential(new TurnAngle(-45));
addSequential(new BangBangMove());
addSequential(new ResetEncoderYaw());
addSequential(new FollowTrajectory(Robot.segment_three));
addSequential(new AutoBoxSpit());

//and then now we manipulate the lift
Expand Down

0 comments on commit d631b73

Please sign in to comment.