-
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.
Incorperate beambreak sensors into codriver controls
- Loading branch information
Showing
8 changed files
with
126 additions
and
40 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
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 |
---|---|---|
@@ -1,28 +1,34 @@ | ||
package frc.robot.robotcomponents; | ||
|
||
import frc.robot.Robot; | ||
import frc.robot.auton.AutonIntake; | ||
import frc.robot.auton.AutonFloorIntake; | ||
import frc.robot.auton.AutonSourceIntake; | ||
|
||
public class Intake { | ||
|
||
public static void autoIntake() { | ||
Robot.getTeleopActionRunner().removeActionsOfType(AutonIntake.class); | ||
Robot.getTeleopActionRunner().removeActionsOfType(AutonFloorIntake.class); | ||
// Robot.getTeleopActionRunner().addActionToRun(new AutonIntake()); | ||
} | ||
|
||
public static void startFloorIntake() { | ||
// Robot.motors.getIntake().set(Constants.INTAKE_SPEED); | ||
Robot.getTeleopActionRunner().addActionToRun(new AutonFloorIntake()); | ||
} | ||
|
||
public static void startSourceIntake() { | ||
Robot.getTeleopActionRunner().addActionToRun(new AutonSourceIntake()); | ||
} | ||
|
||
/* This will spin the motor backwards in an attempt to eject a stuck note*/ | ||
public static void backtrack() { | ||
// Robot.motors.getIntake().set(Constants.MOTOR_BACKTRACK_SPEED_PERCENT); | ||
} | ||
|
||
public static void stopSourceIntake() { | ||
Robot.getTeleopActionRunner().removeActionsOfType(AutonSourceIntake.class); | ||
} | ||
|
||
public static void stopFloorIntake() { | ||
Robot.getTeleopActionRunner().removeActionsOfType(AutonIntake.class); | ||
// Robot.motors.getIntake().stopMotor(); | ||
Robot.motors.getLeftFlywheel().set(0); | ||
Robot.motors.getRightFlywheel().set(0); | ||
Robot.getTeleopActionRunner().removeActionsOfType(AutonFloorIntake.class); | ||
} | ||
} |
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,34 @@ | ||
package frc.robot.auton; | ||
|
||
import edu.wpi.first.wpilibj.Timer; | ||
import frc.robot.Constants; | ||
import frc.robot.Robot; | ||
|
||
public class AutonFloorIntake extends AutonAction { | ||
|
||
double targetTime = -1; | ||
|
||
@Override | ||
public boolean isDone() { | ||
if (Robot.getShooterBeambreakSensor().get() && targetTime == -1) { | ||
targetTime = Timer.getFPGATimestamp() + Constants.MOVEMENT_TIME_AFTER_FLOOR_INTAKE_BEAMBREAK_TRIGGER; | ||
Robot.motors.getFeeder().set(Constants.FEEDER_MOVEMENT_SPEED_AFTER_FLOOR_INTAKE_BEAMBREAK_TRIGGER); | ||
} | ||
if (targetTime != -1 && Timer.getFPGATimestamp() >= targetTime) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
public void initiate() { | ||
Robot.motors.getIntake().set(Constants.INTAKE_SPEED); | ||
Robot.motors.getFeeder().set(Constants.FEEDER_MOTOR_SPEED); | ||
} | ||
|
||
@Override | ||
public void shutdown() { | ||
Robot.motors.getIntake().stopMotor(); | ||
Robot.motors.getFeeder().stopMotor(); | ||
} | ||
} |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package frc.robot.auton; | ||
|
||
import edu.wpi.first.wpilibj.Timer; | ||
import frc.robot.Constants; | ||
import frc.robot.Robot; | ||
import frc.robot.robotcomponents.Shooter; | ||
|
||
public class AutonSourceIntake extends AutonAction { | ||
|
||
double targetTime = -1; | ||
boolean seenRing; | ||
|
||
private static boolean isCurrentlyPosititionRing = false; | ||
|
||
public static boolean isCurrentlyPosititionRing() { | ||
return isCurrentlyPosititionRing; | ||
} | ||
|
||
@Override | ||
public boolean isDone() { | ||
if (Robot.getShooterBeambreakSensor().get()) { | ||
seenRing = true; | ||
isCurrentlyPosititionRing = true; | ||
} else if (seenRing && targetTime == -1) { | ||
targetTime = Timer.getFPGATimestamp() + Constants.MOVEMENT_TIME_AFTER_SOURCE_INTAKE_BEAMBREAK_TRIGGER; | ||
Robot.motors.getFeeder().set(Constants.FEEDER_MOVEMENT_SPEED_AFTER_SOURCE_INTAKE_BEAMBREAK_TRIGGER); | ||
Robot.motors.getLeftFlywheel().set(Constants.FLYWHEEL_MOVEMENT_SPEED_AFTER_SOURCE_INTAKE_BEAMBREAK_TRIGGER); | ||
Robot.motors | ||
.getRightFlywheel() | ||
.set(Constants.FLYWHEEL_MOVEMENT_SPEED_AFTER_SOURCE_INTAKE_BEAMBREAK_TRIGGER); | ||
} | ||
if (targetTime != -1 && Timer.getFPGATimestamp() >= targetTime) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
public void initiate() { | ||
Robot.motors.getFeeder().set(Constants.FEEDER_MOTOR_SPEED); | ||
isCurrentlyPosititionRing = false; | ||
} | ||
|
||
@Override | ||
public void shutdown() { | ||
isCurrentlyPosititionRing = false; | ||
Shooter.stopShooterMotors(); | ||
} | ||
} |