Skip to content

Commit

Permalink
Gave autonomous sequences names based on driver's perspective, commen…
Browse files Browse the repository at this point in the history
…ted autonomous code, and added autonomous network table control.
  • Loading branch information
Lloyd7113 committed Feb 29, 2020
1 parent 4f42eb5 commit 729e0a0
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 34 deletions.
29 changes: 11 additions & 18 deletions src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

import com.ctre.phoenix.motorcontrol.ControlMode;
import com.ctre.phoenix.motorcontrol.FeedbackDevice;
import edu.wpi.first.networktables.NetworkTable;
import edu.wpi.first.networktables.NetworkTableEntry;
import edu.wpi.first.networktables.NetworkTableInstance;
import edu.wpi.first.wpilibj.PowerDistributionPanel;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import frc.robot.commands.auto.AutoSequenceCentre;
Expand Down Expand Up @@ -128,23 +125,19 @@ public void robotPeriodic() {

@Override
public void autonomousInit() {
//
// new AutoSequenceRight().start();
//
//// Drive.leftParent.set(ControlMode.PercentOutput, 0.75);
//// Drive.rightParent.set(ControlMode.PercentOutput, -0.75);
//
// int position = (int) SmartDashboard.getNumber("autoPos", SmartDashboard.getNumber("autoPos", 0));
//
// if (position == 0){
// new AutoSequenceLeft().start();
// }else if (position == 1){
// new AutoSequenceCentre().start();
// }else if (position == 2){
// new AutoSequenceRight().start();
// }else{
// new AutoSequenceTest().start();
// }
int position = (int) SmartDashboard.getNumber("autoPos", SmartDashboard.getNumber("autoPos", 0));

if (position == 0){
new AutoSequenceRight().start();
}else if (position == 1){
new AutoSequenceCentre().start();
}else if (position == 2){
new AutoSequenceLeft().start();
}else{
new AutoSequenceTest().start();
}
}

@Override
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/frc/robot/commands/auto/AutoSequenceCentre.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public class AutoSequenceCentre extends CommandGroup {

public AutoSequenceCentre(){

//The autonomous sequence beginning in the CENTRE of the field.

addSequential(new ResetEncoderCounts());
addSequential(new Shoot(SmartDashboard.getNumber("shooterCloseSpeed", SmartDashboard.getNumber("shooterCloseSpeed", 0))));
addSequential(new AngleOfAttack(45));
Expand Down
23 changes: 17 additions & 6 deletions src/main/java/frc/robot/commands/auto/AutoSequenceLeft.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,25 @@ public class AutoSequenceLeft extends CommandGroup {

public AutoSequenceLeft(){

//The autonomous sequence beginning on the LEFT side of the field, from the driver's perspective.
//Assumes the Limelight cannot initially see the target.

addSequential(new ResetEncoderCounts());
addSequential(new FindTarget());
addSequential(new Shoot(SmartDashboard.getNumber("shooterCloseSpeed", SmartDashboard.getNumber("shooterCloseSpeed", 0))));
addSequential(new AngleOfAttack(0));
addSequential(new ResetEncoderCounts());
addSequential(new RunIntake());
addSequential(new MoveToPoint("", 3));
addSequential(new StopIntake());
addSequential(new Shoot(SmartDashboard.getNumber("shooterFarSpeed", SmartDashboard.getNumber("shooterFarSpeed", 0))));
addSequential(new AngleOfAttack(70));
addSequential(new MoveToPoint("", 1.5));
addSequential(new TurnToDegrees("", -70));

//Optional trench run pickup code...

// addSequential(new RunIntake());
// addSequential(new MoveToPoint("",1.8288));
// addSequential(new Delay(500));
// addSequential(new StopIntake());
// addSequential(new MoveToPoint("", (-1.8288)));
// addSequential(new Shoot(SmartDashboard.getNumber("shooterFarSpeed", SmartDashboard.getNumber("shooterFarSpeed", 0))));
// addSequential(new StraightenOut());
}

}
15 changes: 7 additions & 8 deletions src/main/java/frc/robot/commands/auto/AutoSequenceRight.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,18 @@
public class AutoSequenceRight extends CommandGroup {

public AutoSequenceRight(){

//The autonomous sequence beginning on the right side of the field, from the driver's perspective;
//In line with the trench run, just right of being centred with the power port.

addSequential(new ResetEncoderCounts());
addSequential(new FindTarget());
addSequential(new Shoot(SmartDashboard.getNumber("shooterCloseSpeed", SmartDashboard.getNumber("shooterCloseSpeed", 0))));
addSequential(new AngleOfAttack(70));
addSequential(new MoveToPoint("", 1.5));
addSequential(new TurnToDegrees("", -45));
addSequential(new AngleOfAttack(0));
addSequential(new ResetEncoderCounts());
addSequential(new RunIntake());
addSequential(new MoveToPoint("",1.8288));
addSequential(new Delay(500));
addSequential(new MoveToPoint("", 3));
addSequential(new StopIntake());
addSequential(new MoveToPoint("", (-1.8288)));
addSequential(new Shoot(SmartDashboard.getNumber("shooterFarSpeed", SmartDashboard.getNumber("shooterFarSpeed", 0))));
addSequential(new StraightenOut());
}

}
4 changes: 2 additions & 2 deletions src/main/java/frc/robot/commands/auto/MoveToPoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public void initialize(){
Drive.leftParent.selectProfileSlot(0, 0);
Drive.rightParent.selectProfileSlot(0, 0);
Drive.leftParent.configMotionCruiseVelocity(2000);
Drive.leftParent.configMotionAcceleration(2000);
Drive.rightParent.configMotionAcceleration(2000);
Drive.leftParent.configMotionAcceleration(3105);
Drive.rightParent.configMotionAcceleration(3105);
Drive.rightParent.configMotionCruiseVelocity(2000);

double leftStart = Drive.leftParent.getSelectedSensorPosition();
Expand Down

0 comments on commit 729e0a0

Please sign in to comment.