-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from FIRST-Team-2557-The-SOTABots/dev
Final 2020 Code
- Loading branch information
Showing
34 changed files
with
957 additions
and
392 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/*----------------------------------------------------------------------------*/ | ||
/* Copyright (c) 2019 FIRST. All Rights Reserved. */ | ||
/* Open Source Software - may be modified and shared by FRC teams. The code */ | ||
/* must be accompanied by the FIRST BSD license file in the root directory of */ | ||
/* the project. */ | ||
/*----------------------------------------------------------------------------*/ | ||
|
||
package frc.robot.commands; | ||
|
||
import edu.wpi.first.wpilibj.Timer; | ||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; | ||
import edu.wpi.first.wpilibj2.command.CommandBase; | ||
import frc.robot.RobotContainer; | ||
import frc.robot.subsystems.IntakeSub; | ||
|
||
public class AutoIntakeIntake extends CommandBase { | ||
|
||
public AutoIntakeIntake() { | ||
addRequirements(RobotContainer.intakeSub); | ||
// Use addRequirements() here to declare subsystem dependencies. | ||
} | ||
|
||
// Called when the command is initially scheduled. | ||
@Override | ||
public void initialize() { | ||
System.out.println("Intake intake Command init"); | ||
SmartDashboard.putBoolean("Exist", true); | ||
SmartDashboard.putBoolean("Not Exist", false); | ||
SmartDashboard.putBoolean("Exist Execute", false); | ||
} | ||
|
||
// Called every time the scheduler runs while the command is scheduled. | ||
@Override | ||
public void execute() { | ||
SmartDashboard.putBoolean("Exist Execute", true); | ||
System.out.println("Intake intake Command exe"); | ||
RobotContainer.intakeSub.intakeOut(); | ||
RobotContainer.intakeSub.runIntake(IntakeSub.intakeSpeed); | ||
} | ||
|
||
// Called once the command ends or is interrupted. | ||
@Override | ||
public void end(boolean interrupted) { | ||
RobotContainer.intakeSub.runIntake(0); | ||
SmartDashboard.putBoolean("Not Exist", true); | ||
} | ||
|
||
// Returns true when the command should end. | ||
@Override | ||
public boolean isFinished() { | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package frc.robot.commands; | ||
|
||
import edu.wpi.first.wpilibj.DriverStation; | ||
import edu.wpi.first.wpilibj.Timer; | ||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; | ||
import edu.wpi.first.wpilibj2.command.CommandBase; | ||
import edu.wpi.first.wpilibj2.command.RunCommand; | ||
import frc.robot.RobotContainer; | ||
import frc.robot.subsystems.FlywheelSub; | ||
import frc.robot.subsystems.IntakeSub; | ||
|
||
public class AutoShootIntake extends CommandBase { | ||
|
||
boolean runConveyor = false; | ||
boolean finalBall = false; | ||
int numBall = 0; | ||
boolean shoot; | ||
boolean intaking; | ||
boolean startTimer = false; | ||
double tim = 0; | ||
Timer t = new Timer(); | ||
public static boolean finished = false; | ||
|
||
public AutoShootIntake(boolean intaking) { | ||
addRequirements(RobotContainer.intakeSub, RobotContainer.flywheelSub); | ||
this.intaking = intaking; | ||
} | ||
|
||
@Override | ||
public void initialize() { | ||
t.reset(); | ||
shoot = false; | ||
countBalls = 0; | ||
finished = false; | ||
RobotContainer.intakeSub.intakeIn(); | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
System.out.println("Intaking: " + intaking); | ||
if(!intaking){ | ||
RobotContainer.flywheelSub.spinFlywheels(1); | ||
if(RobotContainer.flywheelSub.getFlywheelSpeed() > 16000) {//16000 | ||
shoot = true; | ||
if(!startTimer){ | ||
t.start(); | ||
startTimer = true; | ||
tim = DriverStation.getInstance().getMatchTime(); | ||
} | ||
} | ||
|
||
if(shoot){ | ||
RobotContainer.intakeSub.runConveyorAndCPM(IntakeSub.starWheelAndCPMSpeed); | ||
RobotContainer.intakeSub.runTurretFeeder(IntakeSub.conveyorMotorSpeed); | ||
} | ||
}else{ | ||
RobotContainer.intakeSub.intakeOut(); | ||
RobotContainer.intakeSub.runIntake(IntakeSub.intakeSpeed); | ||
} | ||
if(t.get() != 0){ | ||
System.out.println("Timer is: " + t.get()); | ||
} | ||
|
||
} | ||
|
||
@Override | ||
public void end(boolean interrupted) { | ||
RobotContainer.intakeSub.runConveyorAndCPM(0); | ||
RobotContainer.intakeSub.runTurretFeeder(0); | ||
RobotContainer.intakeSub.intakeOut(); | ||
finished = true; | ||
} | ||
|
||
@Override | ||
public boolean isFinished() { | ||
return countBalls()>=3 || t.get()>5 || DriverStation.getInstance().getMatchTime()-tim > 5; | ||
} | ||
|
||
int countBalls = 0; | ||
boolean prevTrue = false; | ||
public int countBalls(){ | ||
if(!prevTrue && RobotContainer.touchThree.get()){ | ||
countBalls++; | ||
} | ||
|
||
if(!RobotContainer.touchThree.get()) prevTrue = false; | ||
else prevTrue = true; | ||
|
||
System.out.println("counting: " + countBalls); | ||
System.out.println("prevTrue: " + prevTrue); | ||
return countBalls; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.