Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change clean intake/eject to a PID command #57

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 3 additions & 20 deletions src/main/java/frc/robot/commands/Teleop/CleanIntake.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,31 +29,14 @@ public CleanIntake(PivotIntake intakePivot, Intake intake) {
// Called when the command is initially scheduled.
@Override
public void initialize() {
isReversed = false;
if (intakePivot.getPosition() < Constants.IntakeConstants.CLEAN) {
intakePivot.setHingePower(Constants.IntakeConstants.PIVOT_IN_SPEED);
} else {
isReversed = true;
intakePivot.setHingePower(-Constants.IntakeConstants.PIVOT_IN_SPEED);
}
intakePivot.goToClean();
intake.setRollerPower(-Constants.IntakeConstants.ROLLER_SPEED_CLEAN);
}

// can be improved tolerance with PID
// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {
if (isReversed) {
if (intakePivot.getPosition() < Constants.IntakeConstants.CLEAN) {
intakePivot.setHingePower(0);
intake.setRollerPower(-Constants.IntakeConstants.ROLLER_SPEED_CLEAN);
}
} else {
if (intakePivot.getPosition() > Constants.IntakeConstants.CLEAN) {
intakePivot.setHingePower(0);
intake.setRollerPower(-Constants.IntakeConstants.ROLLER_SPEED_CLEAN);
}
}
}
public void execute() {}

// Called once the command ends or is interrupted.
@Override
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/frc/robot/subsystems/PivotIntake.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ public void liftIntake() {
public void dropIntake() {
hinge.set(ControlMode.Position, Constants.IntakeConstants.DROPPED);
}

public void goToClean() {
hinge.set(ControlMode.Position, Constants.IntakeConstants.CLEAN);
}

public void setEncoderPos(double position) {
hinge.setSelectedSensorPosition(position);
Expand Down